Fatal error at call mysql_connet();

Codes here !

Moderators: egami, macek, gesf

Post Reply
cho@
New php-forum User
New php-forum User
Posts: 39
Joined: Tue Aug 06, 2002 8:58 am
Location: UK

Tue Sep 02, 2003 8:02 am

Hello,

I have a small problem.
I am using Linux Debian woody 3.0 and I have installed Apache and php on several of my machines. On 2 another one I have installed MySQL (Master - Slave).

I can connect localy to my DB and run query no probs.
In an .inc file where i have
mysql_connect("host", "user", "pass");
But when i try to use the web site and log into the Db i have

Fata error: Call to undefined function mysql_connect(); in connection.inc


But I repeat in with local host my test were running OK

here my code

Code: Select all

<?php

    $username = "root";
    $password = "";
    $primary = "192.168.1.8";
    $backup = "192.168.1.6";
    $timeout = 15;  // timeout in seconds

    if($fp = fsockopen($primary, 3306, &$errno, &$errstr, $timeout)){
        fclose($fp);
        return $Link = mysql_connect($primary, $username, $password);
    }
   if($fp = fsockopen($secondary, 3306, &$errno, &$errstr, $timeout)){
        fclose($fp);
          return $Link = mysql_connect($secondary, $username, $password);
    }

    return 0;


?>


I have checked in the httpd.conf and the .inc files are treated by php

i ve tried as well to use
extension=mysql.so in the php.ini file but didnt work and anyway doesnt make any sence cuz MySQL not installed on this host

I have forgotten to add that I have a user with all the privilege who can connect (i though)from all the host (%)

but when I do a telnet 192.168.1.8 3306 from my apache web server, I login and then after 5 secs :

Connection closed by foreign host...


I dont knw if those two probs are related...

So I am a bit lost
Thanks

Francois

User avatar
swirlee
Moderator
Moderator
Posts: 2257
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Tue Sep 02, 2003 12:39 pm

cho@ wrote:
Fata error: Call to undefined function mysql_connect(); in connection.inc


...

i ve tried as well to use
extension=mysql.so in the php.ini file but didnt work and anyway doesnt make any sence cuz MySQL not installed on this host


Well, your problem is, indeed, that your installation of PHP doesn't have the MySQL extension loaded. Depending on how you have PHP installed, you may have to recompile PHP with MySQL installed. Refer to the documentation for more information.
Image

cho@
New php-forum User
New php-forum User
Posts: 39
Joined: Tue Aug 06, 2002 8:58 am
Location: UK

Wed Sep 03, 2003 2:17 am

I ve found my mistake....

apt-get install php4-mysql

MySQL module wasnt installed for php....
:oops:

francois

Post Reply