0

Hi Experts,
I am getting this error message, "Error connecting to mysql"
whenever i am running the below scripts:

<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'petstore';
mysql_select_db($dbname);
?>

I've just set-up everything and still getting such error...
By the way, I am using Windows Vista and IIS 7.0, Could you please help me? suggestions please, recommendations...

4
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by phpbeginners
0

Replace the connect with this:

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die (mysql_error());

It will show you what's wrong, or guide you in the right direction.

0

make sure that u have entered the right password and use mysql_error(); function to find out what the problem is.

0

Hi Experts,
I am getting this error message, "Error connecting to mysql"
whenever i am running the below scripts:

<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'petstore';
mysql_select_db($dbname);
?>

I've just set-up everything and still getting such error...
By the way, I am using Windows Vista and IIS 7.0, Could you please help me? suggestions please, recommendations...

check if all your services are working.

Control Panel\Administrative Tools\Services look for MySQL is started

Checked also the system properties environment variables if your MYSQL is in PATH.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.