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
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);
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.