Page 1 of 1

Problem connecting to MySQL

Posted: Thu Apr 03, 2008 8:29 pm
by utsavgupta
Hello,

I'm trying to connect to MySQL with the following code:

Code: Select all

 
<html>
<head>
<title>Hello</title>
</head>
<body>
<?php
    $dbhost = 'localhost';
    $dbuser = 'root';
    $dbpass = '';
    
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
 
    $dbname = 'bands';
    mysql_select_db($dbname);
?>
</body>
</html>
 
But i am getting this error message:
"Fatal error: Call to undefined function mysql_connect() in G:\www\test.php on line 11"

Please help!

Thanks in advance...

Cheers,
Utsav

Re: Problem connecting to MySQL

Posted: Fri Apr 04, 2008 1:01 am
by Christopher
Your PHP installation appears to not have the mysql extension included. Perhaps PDO or mysqli are available. use phpinfo() to show what is available.