i have installed Apache 2.0.52 + mysql 5.0.16 + php-5.1.0 + phpMyAdmin 2.6.4-pl4 exactly how it is described at "http://mpcon.org/apacheguide/apache.php" but i can't connect to the mysql server.
for example this script that i wrote only prints "1"
And thats why i think that i can't connect to the server

<?php
echo "1";
$db = mysql_connect("localhost");
echo "2";
.....
?>

help me fix this!

    I think you are going to need a username and password:

    try this:
    $db = mysql_connect("localhost", "username", "password") or
    die(mysql_error());

    if ($connection){
    $msg = "your are connected!";
    }

    echo "$msg";

      if i try this :
      <?php
      $db = mysql_connect("localhost","root","");
      if ($db) {
      $msg= "connected";
      }
      else {
      die(mysql_error());
      $msg= "not connected";
      }
      echo $msg;
      ?>
      i also get nothing.
      is this what you meant?

        My apologies - i did mean:

        if($db) NOT if($connection).

        try this and see what error message you get.
        <?

        $db = @mysql_connect("localhost","root","") or
        die(mysql_error());

        if($db) {
        $msg = "connected";
        }

        echo "$msg";

        ?>

          i get nothing, no error message, nothing

            did you create a user w/ a password on your mysql database?

            if not, in your MySQL monitor:

            Select your database:
            use mysql;

            type in this SQL statement:
            GRANT ALL ON . TO sebycot@localhost IDENTIFIED BY "password";

            Exit your mysql monitor:
            exit

            then reload the grant tables:
            mysqladmin reload

            this will be your new username and password:
            user = sebycot
            pass = password

            Let me know if that helps?

              i created the username as you said and now it works if i use "mysqli_connect" instead of "@mysql_connect" or "mysql_connect"
              thanks a lot

                Great! I am glad you got it to work.

                best-
                J.

                  Write a Reply...