QAIX > MySQL database development > Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\mysqlconnect.php
on l 29 January 2009 00:36:45
Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\mysqlconnect.php
on l
Tony Aldemir 25 August 2005 22:31:04
Hello There,
I am getting the "Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\mysqlconnect.php on line 2" error when I try to connect to the MySQL DB using: <?php $conn = mysql_connect("localhost", "joeuser", "somepass"); echo $conn; ?>
I have made sure that my PHP.INI file is adjusted to reflect the following:
Uncommented the line "extension=php_mysql.dll" exposing this DLL to PHP. I added the following line extension_dir = "c:\php\ext"
I copied the libmySQL.dll to the c:\inetpub\wwwroot folder (I am using the IIS on this machine, but I have the same configuration using the latest APACHE Server on my home machine and when It try the same code on that machine, I get no response showing me the value of the $conn, but I do not get any error message either). Confusing situation!
I do have the php_mysql.dll in the C:\php\ext folder
Well, none of this seem to matter. I am still getting the error listed above using IIS .
Here is my setup: I have MySQL 4.1.13a-nt installed. I am able to run MySQL Admin to add users, add tables to the TEST DB, add records to the new table via the command line as well as via the MySQL Query Browser. So I am pretty sure that my MySQL is installed and working fine.)
I have the MySQL program installed on the default location "C:\Program Files\MySQL\MySQL Server 4.1" as oppose to changing it to c:\MySQL folder during the installation. I am hoping that this is not the reason for this problem, but I am not sure.
I am able to run other non-MySQL related simple PHP code via my browser just fine. (Example: <html> <?php echo '<p>Hello World</p>'; ?> and a few other simlar stuff. That all works fine.
But when I use the <?php $conn = mysql_connect("localhost", "joeuser", "somepass"); echo $conn; ?> code it just does not want to work. I get the "Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\mysqlconnect.php on line 2" error.
Daniel da Veiga 26 August 2005 00:19:33 [ permanent link ]
On 8/25/05, Tony_Aldemir@edwards.com <Tony_Aldemir@edwards.com> wrote:> Hello There,>
I am getting the "Fatal error: Call to undefined function mysql_connect()> in c:\Inetpub\wwwroot\mysqlconnect.php on line 2" error when I try to> connect to the MySQL DB using:> <?php> $conn = mysql_connect("localhost", "joeuser", "somepass");> echo $conn;> ?>>
I have made sure that my PHP.INI file is adjusted to reflect the following:
You can always use the phpinfo() function to generate a page with all the information about the php installation, maybe your php isn't configured correctly. Check for the mysql section and see if its all working...
Uncommented the line "extension=php_mysql.dll" exposing this DLL to PHP.> I added the following line> extension_dir = "c:\php\ext">
I copied the libmySQL.dll to the c:\inetpub\wwwroot folder (I am using the> IIS on this machine, but I have the same configuration using the latest> APACHE Server on my home machine and when It try the same code on that> machine, I get no response showing me the value of the $conn, but I do not> get any error message either). Confusing situation!
I know nothing about IIS, so, I can't help you there. But you see, $conn is an object, so, it can't be "echoed", I get "Resource id #3" from the echo.
I do have the php_mysql.dll in the C:\php\ext folder>
Well, none of this seem to matter. I am still getting the error listed> above using IIS .>
Here is my setup:> I have MySQL 4.1.13a-nt installed. I am able to run MySQL Admin to add> users, add tables to the TEST DB, add records to the new table via the> command line as well as via the MySQL Query Browser. So I am pretty sure> that my MySQL is installed and working fine.)>
I have the MySQL program installed on the default location "C:\Program> Files\MySQL\MySQL Server 4.1" as oppose to changing it to c:\MySQL folder> during the installation. I am hoping that this is not the reason for this> problem, but I am not sure.>
I am able to run other non-MySQL related simple PHP code via my browser> just fine.> (Example:> <html>> <?php echo '<p>Hello World</p>'; ?>> and a few other simlar stuff. That all works fine.>
But when I use the> <?php> $conn = mysql_connect("localhost", "joeuser", "somepass");> echo $conn;> ?>> code it just does not want to work. I get the "Fatal error: Call to> undefined function mysql_connect() in c:\Inetpub\wwwroot\mysqlconnect.php> on line 2" error.>
Any help would be greatly appreciated.>
Regards,> Tony Aldemir>
It's clearly a problem with PHP that's not recognizing the MySQL extension... I don't see why this is happening, since PHP should be compiled with mysql support... Anyway, try the phpinfo() and see what it says about mysql...
-- Daniel da Veiga Computer Operator - RS - Brazil -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCM/IT/P/O d-? s:- a? C++$ UBLA++ P+ L++ E--- W+++$ N o+ K- w O M- V- PS PE Y PGP- t+ 5 X+++ R+* tv b+ DI+++ D+ G+ e h+ r+ y++ ------END GEEK CODE BLOCK------
I had the same problem with the following setup: PC with Windows XP Pro SP3 IIS MySQL 5.0 PHP 5.2.6 It turned out that with PHP 5+ the extension used is MySQLi and I had to use mysqli_connect() instead of mysql_connect(). As soon as I changed the function name, it worked.
QAIX > MySQL database development > Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\mysqlconnect.php
on l 29 January 2009 00:36:45