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.
Erro
I had that problem and solved it with prefixing the table name with the database name, so
select * from database.table
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';
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.