Results 1 to 4 of 4
  1. #1
    Join Date
    May 2011
    Posts
    6

    Unanswered: Database not connecting - Wamp Server

    Hi

    I got to develop my whole database in Wampserver 2.1 (it's the latest set). But now I cannot connect to MySQL through PHP in Wamp. I have searched a lot but still have no clue as to what is causing problems.

    No errors are being displayed. I have tried a number of code combination including "if(!)" and nothing has worked.

    CAN ANYONE HELP PLEASE.

    Here is the current code I am trying which returns blank page:

    <?php
    $dbhost = 'localhost';
    $dbuser = 'root';
    $dbpass = 'xyz';
    $db = 'scorecard';

    $conn = mysql_connect($dbhost,$dbuser,$dbpass);
    if (!$conn)
    die('Could not connect: ' . mysql_error());
    }
    echo 'Connected successfully';
    ?>

  2. #2
    Join Date
    May 2011
    Posts
    4
    From what I've seen, variables can be a little testy sometimes in PHP script. I would try not defining quite so much of the script. Instead perhaps use

    PHP Code:

    <?php
    $db 
    'scorecard';

    $conn mysql_connect("localhost""root""xyz");
    if (!
    $conn)
    {
    die(
    'Could not connect: ' mysql_error());
    }
    echo 
    'Connected successfully';
    ?>
    You were also missing a bracket on your "if" statement, that could be the issue.

    If neither of those fixes work, I would double check and make sure that the account information you are using is correct and that the user that you have named has the proper permissions to access the database you are trying to connect to.

    Hope that helps a little!

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    why are you asking the same question in a new thread?
    it just causes confusion, please do not do this

    if you are having problems in getting an answer to your problem then bump the old post or add further infortmation


    as suggested in http://www.dbforums.com/php/1666803-...mp-server.html then first things you need to do are:-

    prove you have a working PHP insterpreter ont he web server. I suggested using a PHP script that uses the PHPinfo() function to display how the server is configured

    prove you are getting PHP error messages. I'd suggest error_reporting.... in the absence of that you will not be able to develop anything in PHP.
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Jun 2011
    Posts
    40
    You are getting a parse error:

    PHP Code:
    <?php
    $dbhost 
    'localhost';
    $dbuser 'root';
    $dbpass 'xyz';
    $db 'scorecard';

    $conn mysql_connect($dbhost,$dbuser,$dbpass);
    if (!
    $conn)    // <<<  MISSING CURLY BRACKET HERE!!!!
    die('Could not connect: ' mysql_error());
    }
    echo 
    'Connected successfully';
    ?>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •