sanchit — 2010-12-12T06:07:29-05:00 — #1
I'm facing a problem here.
I bought 'Build your own database driven website using PHP & MySQL' yesterday.
I installed Apache, PHP & MySQL on Ubuntu, following the instructions given in the book.
However, when I include functions such as mysql_connect() or other mysql related functions in PHP files, they don't work!
Even the following snippet of code didn't work out -
$con = mysqli_connect("localhost","root",<my password>);
echo "Try again";
// some code
It didn't give any output! There was a blank page!
Otherwise, PHP files are running accurately(which means even Apache is working fine).
MySQL is also running fine when I access it in the terminal.
However, I'm unable too run mysql functions.
I think I squandered my money on the book.
Please help me out!!!!!
anthonysterling — 2010-12-12T06:09:00-05:00 — #2
Place the following at the top of your script, it should help you pinpoint the problem.
You would have only squandered you money if you were not learning anything, as you don't know how to get this working...
dibley — 2010-12-12T06:16:58-05:00 — #3
Make sure you run your text editor that you wrote the code in as administrator.
sanchit — 2010-12-12T06:25:22-05:00 — #4
Thanx for your reply!!
I got the following error -
Fatal error: Call to undefined function mysqli_connect() in /var/www/try.php on line 4
Looks like PHP hasn't configured MySQL.
Moreover, phpMyAdmin says 'MySQL extension is missing' whereas MySQL is running. To ensure that I had followed the book correctly, I reinstalled everything.
Please help me out!
Maybe if I'm able to get the scripts running, my investment in the book won't seem to be squandering
anthonysterling — 2010-12-12T06:30:16-05:00 — #5
I'm not familiar with the books installation procedure, but have you tried...
sudo apt-get install php5-mysql
sanchit — 2010-12-12T20:56:49-05:00 — #6
I have been doing that. Thanks anyway!
sanchit — 2010-12-12T21:46:16-05:00 — #7
Thanx! Got the following error -
Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /var/www/try.php on line 4 Could not connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
sanchit — 2010-12-12T22:18:36-05:00 — #8
I deleted the mysql directory & reinstalled mysql using
sudo apt-get install mysql-server
Things seem to be fine now. Thanks for your help!