SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    cd /pub; more beer diacono's Avatar
    Join Date
    Dec 2000
    Location
    Horsham, West Sussex, UK
    Posts
    277
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well started mucking around with kev's mega article on php & mySql database driven site. it was going all right untill i got to the part the information is pulled from the db with php.

    nothing happened! not even those erros that are meant to say:
    Code:
    {  echo( "<P>Unable to connect to the " .
             "database server at this time.</P>" );
    so how do i know that mysql is working?
    i can pull the data from the mysql prompt:
    mysql-->SELECT * From blah....

    if ipchains (my firewall) was blocking the port (i think it is) why dont i get the error?

    thanks for any help from this mess!
    DIEGO MOORE

  2. #2
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    really need to see more of your code .... post your connection code , just mask the username & password.

    also try <? echo mysql_error();?> right after your connection for better error reporting.

  3. #3
    cd /pub; more beer diacono's Avatar
    Join Date
    Dec 2000
    Location
    Horsham, West Sussex, UK
    Posts
    277
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok here are some more details...
    Code:
    <HTML><HEAD><TITLE>Access db</TITLE><HEAD><BODY>
    <?php
      // Connect to db
      $dbcnx = @mysql_connect "localhost",
               "root", "password");
      if (!$dbcnx) {
        echo( "<P>Unable to connect to the " .
              "database server at this time.</P>" );
        exit();
      }
      // Select the Contacts database
      if (! @mysql_select_db("Contacts") ) {
        echo( "<P>Unable to locate the joke " .
              "database at this time.</P>" );
        exit();
      }
    ?>
    <P>The db:</P><BLOCKQUOTE>
    <?php
        // Request the Names from the Contacts db
      $result = mysql_query(
                "SELECT Surname FROM Contacts");
      if (!$result) {
        echo("<P>Error performing query: " .
             mysql_error() . "</P>");
        exit();
      }
      // Display the the results
      while ( $row = mysql_fetch_array($result) ) {
        echo("<P>" . $row["Surname"] . "</P>");
      }
    ?>
    
    </BLOCKQUOTE></BODY></HTML>
    i'm running suse6.4 and i'm not connected to any network.
    i've tried changing localhost to box.mibstar.com and 127.0.0.1.
    nothing happens, no errors.

    if i delibaratly make a mistake, like deleting a ";" or something similar i get an error parsing code on line xx. (which means that php is working).

    i also changed the password and username into ones that were wrong, but still error.

    when i "view source code" i only get:
    Code:
    <HTML><HEAD><TITLE>Access db</TITLE><HEAD><BODY>
    i hope this helps!
    DIEGO MOORE

  4. #4
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $dbcnx = @mysql_connect "localhost","root", "password");
    You are missing a "(". The code should read

    $dbcnx = @mysql_connect ("localhost","root", "password");

    The reason you do not get any of your built in error reporting displaying is because PHP never actually executes the code - it parses it, sees that it has bad syntax and doesn't bother trying to execute it.

    There are settings you can set to let PHP output the parse errors. Someone who actually has an in-depth knowledge of PHP can post what these are.

    While I have the reader's attention - can someone please explain to this PHP newbie what the significance of the "@" is in @mysql_connect as opposed to writing mysql_connect.

    Thanks

  5. #5
    Database Jedi MattR's Avatar
    Join Date
    Jan 2001
    Location
    buried in the database shell (Washington, DC)
    Posts
    1,107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The "@" signifies that PHP is going to ignore any errors that the any expression (the function call to connect to MySQL in this case) might spit out. You might want to go ahead and remove that so you can see if the connect function is dying on anything.
    .
    http://www.php.net/manual/en/languag...rorcontrol.php

    for the skinny.

  6. #6
    cd /pub; more beer diacono's Avatar
    Join Date
    Dec 2000
    Location
    Horsham, West Sussex, UK
    Posts
    277
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanx everyone...
    give me some time and i'll try it (i've just upgraded my pc and sus didnt like my new video card!)
    DIEGO MOORE


Bookmarks

Posting Permissions

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