Forum Moderators: coopster

Message Too Old, No Replies

MySQL Problem. Or Not.

         

webfoo

9:11 pm on Jul 21, 2008 (gmt 0)

10+ Year Member



I'm having trouble connecting to a database. I've looked over it with a fine-tooth comb, but is there anything wrong with this code? I'm convinced that it's a problem with the database, not with my code.


$host='server.name';
$user='user_name';
$pass='my_password';
@mysql_connect($host,$user,$pass) or die("Unable to connect to database server: " . mysql_error());
@mysql_select_db("database") or die("Unable to open database: " . mysql_error());
$sql="INSERT INTO table (field1, field2, etc) VALUES ($value1, $value2, $etc)";
@mysql_query($sql) or die("Unable to query database: " . mysql_error());
echo "Record added to database";

It's giving me the following error:

Access denied for user 'user_name'@'ip.add.ress' (using password: YES)

eelixduppy

9:17 pm on Jul 21, 2008 (gmt 0)



Have you been able to get into the database server before from PHP? It might be an issue with your password, in which case follow the instruction here: [dev.mysql.com...]

You can also use the mysqli [php.net] extension and that should work, too, if the above is your problem.