Question:
Why can't I connect to my 'mysql' server using php?
Smoothie
2008-05-03 07:04:44 UTC
This is the php file:
-----



$con = mysql_connect (localhost, username, password);
?>



-----

This is the error I get:
-----
Fatal error: Call to undefined function mysql_connect() in C:\ Program Files\ Apache Group\ Apache2\ htdocs\ test03.php on line 5
-----

I have the Apache 2 server installed and working with php, and the mysql server is installed and works (at least when I log in from the command prompt). I'm sending the actual password and username. I've checked the server status to make sure its still just called 'localhost' and it is.

Just wondering if anyone knows what I'm doing wrong. Thanks!

*note: the spaces in odd places are to keep the long text strings from being terminated after so many characters*
Four answers:
greigmcl
2008-05-03 07:12:57 UTC
The version of php you have hasn't been compiled with mysql support. Normally on a linux distribution I'd say recompile with mysql support, not sure about windows binaries though.
mcmillian
2016-11-07 03:45:08 UTC
No Javascript is a shopper area language which skill that's unable to deliver or get carry of records from a internet server on my own you will prefer al server area language like very own dwelling house page to hook up with the server then deliver the suggestions to javascript to be processed.
2008-05-03 07:11:46 UTC
Sounds as if you don't have the mysql module loaded. Try:




phpinfo();

?>



And look through the list (it's alphabetical). (You can put that on a page of its own or you can just include it on your page (before the line that creates the error) to see whether mysql is loaded.)
2008-05-03 07:15:24 UTC
Make sure you have MySQL installed on your server.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...