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!!!!!
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...
Make sure you run your text editor that you wrote the code in as administrator.
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
I'm not familiar with the books installation procedure, but have you tried...
sudo apt-get install php5-mysql
I have been doing that. Thanks anyway!
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)
I deleted the mysql directory & reinstalled mysql using
sudo apt-get install mysql-server
Things seem to be fine now. Thanks for your help!