mysql_connect question

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
kermit
Forum Newbie
Posts: 2
Joined: Fri Aug 22, 2003 5:53 pm

mysql_connect question

Post by kermit »

Hi, I am learning how to connect to mysql with php, and so I was trying to use a little connect script that looks like this:

Code: Select all

<?php

$username = "username....";
$password = "pass....";
$hostname = "localhost";	

$link = mysql_connect($hostname, $username, $password) 
	or die("Unable to connect to MySQL");
print ( "Connected to MySQL" );

mysql_close($link);

?>

Now when I try and open this script in my browser, I get this message:

Fatal error: Call to undefined function: mysql_connect() in /var/www/html/connect.php on line 7
Any suggestions as to what might be wrong?

thanks

kermit
User avatar
trollll
Forum Contributor
Posts: 181
Joined: Tue Jun 10, 2003 11:56 pm
Location: Round Rock, TX
Contact:

Post by trollll »

That leads me to believe that the mysql option did not get enabled upon installation. Can you upload a file with contents of

Code: Select all

<?php phpinfo(); ?>
so we can check out the installation settings?
kermit
Forum Newbie
Posts: 2
Joined: Fri Aug 22, 2003 5:53 pm

Post by kermit »

That is exactly what was wrong - I did not install with the MySQL option. I was quite pleased to find that I could upgrade it with my install disk, and it was all quite painless. I ran the script again, and it works just fine. Thanks for your help.
Post Reply