PHP4 > PHP5 help

Discussion in 'PHP' started by BRUm, Nov 18, 2006.

  1. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #21
    Check that you're actually connecting to the MySQL server.

    mysql_connect (MySQL_Server_Hostname, Username, Password) or die ('I cannot connect to the database because: ' . mysql_error());
    mysql_select_db (MySQL_Database_Name);

    The Hostname might be localhost or dbserver17.dbserver.net or something along those lines.

    Try uploading this script and running it;

    <?php
    
    error_reporting (E_ALL);
    mysql_connect ('host', 'user', 'pass');
    echo 'mysql_connect error: '.mysql_error ().'<br>';
    mysql_select_db ('dbname');
    echo 'mysql_select_db error: '.mysql_error ().'<br>';
    $r = mysql_query ('select 1+1 as ans');
    echo 'mysql_query error: '.mysql_error ().'<br>';
    $r = mysql_fetch_assoc ($r);
    echo 'mysql_fetch_assoc error: '.mysql_error ().'<br>';
    echo 'answer: (should be 2): '.$r['ans'].'<hr>Done.';
    ?>
    PHP:
    Post the output here.
     
    exam, Nov 23, 2006 IP
  2. BRUm

    BRUm Well-Known Member

    Messages:
    3,086
    Likes Received:
    61
    Best Answers:
    1
    Trophy Points:
    100
    #22
    OK thanks for your help, I get this as the output:

     
    BRUm, Nov 27, 2006 IP