November 28th, 2012, 03:01 AM
Call to undefined function mysql_connect() in /Users/praveenvasireddy/localhost/test/
I am a newbie to LAMP stack. I believe I have setup apache,php and mysql correctly. I am using Mac Pro, and OS version is 10.8.2
While installation I modified php.ini to include mysql.default_socket = /tmp/mysql.sock
Modified httpd.conf to uncomment php module.
When I run a webpage with phpinfo(), below is a snippet from the same.
Version mysqlnd 5.0.8-dev - 20102224 - $Id: 65fe78e70ce53d27a6cd578597722950e490b0d0 $
Command buffer size 4096
Read buffer size 32768
Read timeout 31536000
Collecting statistics Yes
Collecting memory statistics Yes
Code which fails is on line 2 of the test page.
$con = mysql_connect("127.0.0.1","root","");
die('Could not connect: ' . mysql_error());
$fname = $_POST["fname"];
$lname = $_POST["lname"];
$add1 = $_POST["add1"];
FYI ... prior to setting up apache,php and mysql seperately I tried XAMPP and the same code back worked.
Please help me what need to get configured to make sure that php connects to localhost mysql.
Thank you in advance.
November 28th, 2012, 03:26 AM
try installing apache, mysql and php by downloading and installing xampp
Then, if you're new to PHP bypass the whole mysql_* functions and concentrate on PDO (PHP Data Objects) - its a neater, cleaner set of objects and functions to use when interfacing to a database