Problem connecting to MySQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
utsavgupta
Forum Newbie
Posts: 3
Joined: Thu Apr 03, 2008 1:51 am
Location: India

Problem connecting to MySQL

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Problem connecting to MySQL

Post 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.
(#10850)
Post Reply