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...

Recommended Answers

All 3 Replies

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.

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.