sanchit
December 12, 2010, 11:07am
1
Hi!
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 -
<?php
$con = mysqli_connect("localhost","root",<my password>);
if (!$con)
{
echo "Try again";
}
echo $con;
// 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.
error_reporting(-1);
ini_set('display_errors', true);
You would have only squandered you money if you were not learning anything, as you don’t know how to get this working…
Dibley
December 12, 2010, 11:16am
3
Make sure you run your text editor that you wrote the code in as administrator.
sanchit
December 12, 2010, 11:25am
4
AnthonySterling:
Place the following at the top of your script, it should help you pinpoint the problem.
error_reporting(-1);
ini_set('display_errors', true);
You would have only squandered you money if you were not learning anything, as you don’t know how to get this working…
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
Please help!
I’m not familiar with the books installation procedure, but have you tried…
sudo apt-get install php5-mysql
sanchit
December 13, 2010, 1:56am
6
I have been doing that. Thanks anyway!
sanchit
December 13, 2010, 2:46am
7
AnthonySterling:
I’m not familiar with the books installation procedure, but have you tried…
sudo apt-get install php5-mysql
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)
Plzzz help!
sanchit
December 13, 2010, 3:18am
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!