I've been spending the last couple of weeks installing PHP and mySQL on my G4 with the intention of developing some database driven websites and maybe hosting them from my machine. I'm running Mac OS X Panther and I installed both from installer packages at entropy.ch and mysql.com respectively.
Both seem to work fine alone. The machine will parse straight PHP commands such as those that display date and time fine. I can also log onto mySQL from the Terminal application and play around with tables there.
The problem comes when I try and access a database from PHP. I can execute the following commands:
$sql="show status";
$result = mysql_query($sql);
along with a loop to output a table of '$result' to get a long list of variables. I can also induce an error message at this point
'Error 1045: Access denied for user: 'root@localhost' (Using password: NO)'
By giving the PHP file incorrect user name and password details. Strangely though whatever user name I use the error message always reads 'root@localhost'. This may or may not be part of the problem, either way I find it strange.
Moving on, as soon as I try and access databases via PHP with code such as:
mysql_select_db($database);
$query = stripSlashes($query) ;
$result = mysql_query($query);
I am just presented with a blank screen. I can't seem to induce any error messages perhaps implying that the database is not being connected too at all. The code I've shown here comes from sample files that are provided with the book I am learning PHP and mySQL from so the problem is very likely to be with my installation. All the same I have posted the source code at
http://www.mr-jenner.co.uk/php_problem/mysql_up_code.html (This works so far as presenting a table of variables.
http://www.mr-jenner.co.uk/php_problem/mysql_send_code.html (This will not return queries or errors. All it does is show you the blank form again. Other attempts at returning database queries yield a blank web page.)
I am hoping this is a simple problem like I haven't configured PHP to connect to mySQL properly but after trying for three days I am unable to overcome it.
Regards,
Tom
Both seem to work fine alone. The machine will parse straight PHP commands such as those that display date and time fine. I can also log onto mySQL from the Terminal application and play around with tables there.
The problem comes when I try and access a database from PHP. I can execute the following commands:
$sql="show status";
$result = mysql_query($sql);
along with a loop to output a table of '$result' to get a long list of variables. I can also induce an error message at this point
'Error 1045: Access denied for user: 'root@localhost' (Using password: NO)'
By giving the PHP file incorrect user name and password details. Strangely though whatever user name I use the error message always reads 'root@localhost'. This may or may not be part of the problem, either way I find it strange.
Moving on, as soon as I try and access databases via PHP with code such as:
mysql_select_db($database);
$query = stripSlashes($query) ;
$result = mysql_query($query);
I am just presented with a blank screen. I can't seem to induce any error messages perhaps implying that the database is not being connected too at all. The code I've shown here comes from sample files that are provided with the book I am learning PHP and mySQL from so the problem is very likely to be with my installation. All the same I have posted the source code at
http://www.mr-jenner.co.uk/php_problem/mysql_up_code.html (This works so far as presenting a table of variables.
http://www.mr-jenner.co.uk/php_problem/mysql_send_code.html (This will not return queries or errors. All it does is show you the blank form again. Other attempts at returning database queries yield a blank web page.)
I am hoping this is a simple problem like I haven't configured PHP to connect to mySQL properly but after trying for three days I am unable to overcome it.
Regards,
Tom