Submitted by Fredrik-s on Tue, 07/20/2010 - 07:00
Hello,
I try to connect to my MySQL database with the following code:
$con = mysql_connect('localhost', 'MY_USERNAME', 'MY_PASSWORD');
if (!$con) {
die('Could not connect: ' . mysql_error());
} else {
echo "It works";
}
// some code
But I got the following error Fatal error: Call to undefined function mysql_connect() in /home/XXX/XXX/XXX/XXX/myfile.php on line 2
I have done a little re-search at Google. And have came up with that MySQL should be standing - at least something about - in my php.ini file. So i made a file with phpinfo() in it. And there is nothing about MySQL. So I think there is no connection between PHP and MySQL. Is my thoughts correct?
What could be the problem?
Status:
Closed (fixed)
Comments
Submitted by andreychek on Tue, 07/20/2010 - 08:01 Comment #1
Howdy -- you'll want to make sure that you have PHP's MySQL module installed.
On Debian, you can do that by running the following from the command line:
apt-get install php5-mysql
Submitted by Fredrik-s on Tue, 07/20/2010 - 08:23 Comment #2
Thanks! That was the deal!