I am using Oops MySQLi to connect to my database. I checked my credentials and everything will be fine.
$mysqli = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB) or die('There was a problem connecting to the database.'); if (mysqli_connect_errno()) { printf("Can't connect to MySQL Server. Errorcode: %s\n", mysqli_connect_error()); exit; } if ($result = $mysqli->query('SELECT * FROM places WHERE place_id=' . mysql_real_escape_string($_GET['id']))) { while( $row = $result->fetch_assoc() ){ printf("%s (%s)\n", $row['name'], $row['place_id']); } $result->close(); } $mysqli->close();
This code generates an error:
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user '-removed-'@'localhost' (using password: NO) in /var/www/vhosts/communr.com/httpdocs/pbd/places.php on line 396 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /var/www/vhosts/communr.com/httpdocs/pbd/places.php on line 396
I cannot understand why I am getting these errors. They started showing up when I moved the servers recently. I am establishing a SQL connection before a query.
Do you all think that some settings may be corrupted on my new server?
Thanks!
php mysql mysqli
ATLChris
source share