Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   PHP (https://www.askmehelpdesk.com/forumdisplay.php?f=454)
-   -   Connecting to MySQL with PHP on Apache 2.2 (https://www.askmehelpdesk.com/showthread.php?t=69265)

  • Mar 6, 2007, 08:43 AM
    sypher373
    Hello all,

    Just a little background on my system.

    I am running Windows XP Pro SP2. Firewall is disabled.

    Running Apache 2.2, PHP5 and MySQL server 5.1.

    I am trying to simple interface with my MySQL database using a webpage running PHP. I have tried using the mysql_connect(host, name, password) function, checked all the parameters 50,000 times and I still cannot connect. As a test, I wrote a small script that resembled this:

    <?php

    Echo "start";
    Mysql_connect($host, $name, $pass);
    Echo "end";

    ?>

    The problem with that is, only the "start" printed. I have no indication that I ever got connected to the database, as the insertion of a create db command yielded nothing. I have even tried the connection function using the 'or die("Error"); part. No error, no connection.

    MY firewall is turned off, MySQL operates fine at the command line, and apache is working fine. All PHP commands work, I just can't seem to interface with MySQL.

    Any suggestions? :confused: :confused:

    I forgot to mention, this is all being run on the same machine, making my hostname localhost. I have tried localhost as well as 127.0.0.1
  • May 10, 2007, 11:25 PM
    BenReilly
    Try the following:
    <?PHP
    $db_server = 'localhost';
    $db_name = 'whateveritis';
    $db_user = 'root';
    $db_passwort = 'password';

    $db = @mysql_connect($db_server, $db_user, $db_passwort)
    or die ('The Connection could not be established');

    $db_check = @mysql_select_db($db_name);

    if($db)
    echo 'Connection to Database is established';
    ?>
    If you are connected to the db you will receive the last message.
  • Jan 11, 2008, 04:48 PM
    interinfinity
    Make sure mysql services running in services.msc, try restarting apache and msql servies

  • All times are GMT -7. The time now is 03:11 PM.