Jump to content

[SOLVED] Unknown mysql_connect problem


Phobios

Recommended Posts

When I try to connect from my php-script to my mysql server on localhost it will not work. This is the test code I am using while trying to get it to work:

 

<?php

 

    $user = "user";

        $password = "password";

        $host = "localhost";

        $db = "db";

 

        echo first;

        $conn = mysql_connect($host,$user,$password) or die("Problems connecting: " . mysql_error());

        echo second;

        $db = mysql_select_db($conn);

        mysql_close($conn);

 

?>

 

After the mysql_connect call nothing will be displayed and I get no error message whatsoever. I have set all the right privileges in the mysql database. I have looked through the php.ini file and found no fault in there. I have googled alot on the subject, but I haven't found anything of help yet.

 

On my real page, which I will use it on, the css on the page gets screwed up as well.

 

I am using fedora core 11.

 

I hope someone out there can help me out.

Link to comment
https://forums.phpfreaks.com/topic/173025-solved-unknown-mysql_connect-problem/
Share on other sites

try something like this instead:

 

<?php
  $user = "user";
  $password = "password";
  $host = "localhost";
  $db = "db";

  echo "Connecting...";
  $conn = mysql_connect($host,$user,$password)
    or die("Problems connecting: " . mysql_error());
  echo "Done<br />";     

  echo "Selecting DB...";
  if(!mysql_select_db($db, $conn))
    echo "Failed";
  else
    echo "Done<br />";

  mysql_close($conn);
?>

Now I see the error! It says:

Fatal error: Call to undefined function mysql_connect() in /var/www/html/test.php on line 12

 

How do I fix this problem?

 

edit:

It still echoed first, but I have added quotation marks now since it gave me a warning... didn't think about that.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.