I will try to give as much info as I can with a view to saving ppls time asking me, “Did you try… ?”, when the answer almost certainly is, yes I did.
PHP 5.3, MySQL 5.1, Apache 2.2, Windows 7.
Everything is installed and working fine–EXCEPT when I try to connect to MySQL I get the message: ‘Call to undefined function mysql_connect()’
The code is written correctly:
$link = mysql_connect(localhost, root, xyz1);
if(!$link) {
die('Failed to connect to server: ’ . mysql_error());
}
Yes I have included all three to the PATH, all directories are named correctly, I have uncommented what needs to be uncommented in the PHP.ini file, copies are in Windows system and system32, libmysql.dll
is NOT included in PHP 5.3 (gawd knows why) but I have taken it from PHP 5.2 and copied into the PHP
and the PHP/ext folders and system32.
TheLoadModule php5_module “C:/Program Files (x86)/PHP/php5apache2_2.dll” is in httpd.conf.
I have done EVERYTHING and still I only get ‘Call to undefined function mysql_connect()’
I don’t know how much time I have spent on this but I AM GOING APE SHIRT over it.
phpinfo does not show anything under Modules, and only mentions MySQL where it happens to display
the PATH.
Does anybody really KNOW how to make this work?
The code is written correctly: $link = mysql_connect(localhost, root, xyz1); if(!$link) { die('Failed to connect to server: ' . mysql_error()); }
Are the localhost, root and xyz1 defined as constants in your script?
If not, the correct code would be:
[php]
$link = mysql_connect(‘localhost’, ‘root’, ‘xyz1’);
[/php]
No, I just wrote it that way here for simplicity, it’s actually written:
<?php //Start session session_start(); //Include database connection details require_once('config.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } I wonder if the answer might be to just use a PHP 4 something? I don't want to, but I have spent toooo many hours on this one aspect... where I should be a good ways into putting the site together and writing a database for it, instead I am still trying to get the bloody thing to work: thing is, I have done this before and had it work, so I am really wondering just what is going on here...From your code, it is not obvious that you have set DB_HOST, DB_USER, DB_PASSWORD parameters properly. What is the error message from MySQL?
Fatal error: Call to undefined function mysql_connect() in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\register-exec.php on line 15.
You have been very quick in all your responses, thank you… .
OK, I have managed to get it working properly. Here is what is necessary.
First, for whatever reason, PHP omitted a critical file for MySQL support from their PHP 5.3.2, so I would use that one at all: I used PHP 5.2.8–and you have to download it twice! once with the installer and once as a zip file–because the installer version doesn’t have all the files required for MySQL support in it. Install PHP as usual, into say C:\PHP , oh so easy, andunzip the zip file to wherever you like, copy everything (just makes it easy and doesn’t hurt to include everthing) into the “ext” file, and then copy the ext file and paste in C:\PHP. In the php.ini file make an entry like this:
;
extension_dir = C:\PHP\ext
libmysql.dll should be copied–not moved–into C:\PHP and also to Windows\system32.
I can’t believe how long I worked at this—sheesh.
So then, Apache 2.2, PHP 5.2.8 and MySQL 5.1 on Windows 7.
Praise be to the powers that be–and fk Oracle for screwing up a good thing.