Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6950619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:06:54+00:00 2026-05-27T14:06:54+00:00

I am trying to connect to my database and when I run the code,

  • 0

I am trying to connect to my database and when I run the code, I get an error. Can anybody tell me what is wrong also any errors in my PHP code? Thanks.

Error: No database selected

PHP Code:

include('.conf.php');
$prof = $_GET['profile'];
$prof = addslashes(htmlentities($prof));
$query = "SELECT * FROM aTable where id = '".mysql_real_escape_string($prof)."'";
$info_array = mysql_query($query, $con) or die (mysql_error()).;

while($row = mysql_fetch_array( $info_array )) 
{
    echo $row['num1'];
    echo "</br>";
    echo $row['num2'];
    echo "</br>";
    echo $row['num3'];
    echo "</br>";
    echo $row['num4'];
};

mysql_close($con);

.conf.php file:

<?php
    $conf['db_hostname'] = "xxx";
    $conf['db_username'] = "xxx";
    $conf['db_password'] = "xxx";
    $conf['db_name'] = "xxx";
    $conf['db_type'] = "mysql";

    $con = mysql_connect('xxx', 'xxx', 'xxx') or die (mysql_error());
    $db  = mysql_select_db("aTable", $con);
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:06:54+00:00Added an answer on May 27, 2026 at 2:06 pm

    Unless you have the password incorrect and need to fix it, run a GRANT statement to grant access to your database user:

    GRANT ALL PRIVILEGES ON aTable.* TO xxx@localhost IDENTIFIED BY 'password_for_xxx';
    

    The above grants all privileges. It’s often better to restrict to only what’s needed. For example, if you only intend to SELECT, but not modify data,

    GRANT SELECT ON aTable.* TO xxx@localhost IDENTIFIED BY 'password_for_xxx';
    

    Update

    Since you have identified the database name as dedbmysql, change your mysql_select_db() call to:

    $db = mysql_select_db("dedbmysql", $con);
    

    Following this, the GRANT statements above are probably unnecessary, as your host may have already worked out the correct database permissions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to connect to the database and get current state of a
I'm trying to connect to SQLite database with Ecplise but I have some errors.
I am trying to connect to a remote sql database and simply run the
Trying to get my first MVC + EF code first project to run. The
My php code fails to connect to the mysql database on my web server.
trying to get my first little PHP script to connect to a local mySql
im trying to create a xml file using php.everytime i run the code the
Hey guys i'm trying to connect to my database and run a query. it
While trying to connect to a database that's set to read only, the connection
So I'm trying to connect to my database at the specified location, and the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.