I'm trying to get my Centos 4.2 server up, and i've installed apache/php/mysql/phpmyadmin, but when I try to connect to mysql through a script it doesn't work. Not only does it not work, but it gives no error whatsoever. Just kills over. I'm using the following code:

<?php
$link = mysql_connect('localhost', 'myuser', 'mypass');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

and it just shows me a blank page when I run the script. It doesn't even make it past the first line, since i've put an echo statement below it and it won't spit anything out (putting one above it does, though).

Oh yeah, and the weird thing is, phpmyadmin works great.. so php must be talking to mysql some how, right?

    4 months later

    I have exactly the same problem. Your message is about 4 months old now.
    Have you found already a solution for this problem?
    Does anybody else know why this happen?????

      Look in the HTML source of the page... is there anything there? If you see "<?PHP" etc., then PHP wasn't installed properly.

      Though, if you've used phpMyAdmin as well... hmm.

        Ik have found the solution.
        You have to install the php4-mysql module.
        If you have php5 then of course the php5-mysql module.
        With ubuntu:
        sudo apt-get install php4-mysql
        than you must restart apache with:
        sudo apachectl graceful
        I hope I helped others with this solution.

          Nice job. I would have never figured that out :p

          Don't forget to mark the thread resovled!

            Write a Reply...