PHP/MySQL Question

Dross

New Member
I've been fooling around with PHP and MySQL recently and have run into a problem. I am trying to get some really simple php code to call up a mysql table, but I just keep getting error messages. The code is as follows:

<html>
<head>
<title>Test Table</title>
</head>

<body>
<h1>MySQL Test</h1>

<?

//values for $host, $user, $pass are here

mysql_connect($host, $user, $pass);

$db = "test_vote";

mysql_list_tables($db);

?>

</body></html>


the error message I am getting is as follows:
"Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\htdocs\test_work.php on line 14"

I suspect that the problem isn't in the code, but with MySQL. But MySQL is definitely running and the database "test_vote" does exist. It also might be noteworthy that I'm having no problem using Apache and PHP, it's just when I try to integrate MySQL into the mix. Any help would be appreciated! Thanks!
 
Not sure, but it sounds like mysql is not enabled on your build of php.

Make a page with just this on it:
<?php
echo phpinfo();
?>

save it to your web server and then see what it says.

If mysql is enabled, you should see a table called mySQL and the next column should say 'enabled'
 
what version of PHP are you running? It sounds like you are either running pre-version 3 or it's not setup properly
 
"what version of PHP are you running? It sounds like you are either running pre-version 3 or it's not setup properly"


I'm running PHP 5.0.4. I think PHP is set up properly with regard to Apache...I was using it with no problem until I tried to use it with MySQL.



"If mysql is enabled, you should see a table called mySQL and the next column should say 'enabled'"


There's no MySQL table on my info...

:confused:
 
For anyone looking at this thread in the future, I figured out my problem. By default, PHP5 does not recognize the mysql client library. You can change this in php.ini. Find "Windows Extensions" in php.ini and remove the ";" before "extension=php_mysql.dll"...it should look like this:

;Windows Extensions

;extension=php_mssql.dll
;extension=php_msql.dll
extension=php_mysql.dll
;extension=php_mysqli.dll
;extension=php_oci8.dll



Then you just have to make sure your web server knows where to find php_mysql.dll. It is probably in the "ext" folder in your php folder. A sloppy fix is to just copy the file and paste it into the same folder as your php.ini. If your using windows, it's probably C:\Windows.

This link put me on the right track: http://forums.mysql.com/read.php?10,33368,33430#msg-33430
 
ah, I didn't realize you were using windows, when I see PHP + MySQL + Apache I just assume it's linux/unix
 
Back
Top