read db error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anfetienne
    Contributor
    • Feb 2009
    • 424

    read db error

    i have this code that reads a database so i can echo specific things back to the page....i had help on it before and when i left the code it was working i go back to it to check it works and it wont display any values from the db on a page

    here is the code

    Code:
    <?
    $errorM = '<div align="center"><h2><center>NOTE: Please make sure that you have saved your editorial before uploading any images.</center></h2></div>';
    
    $user="********";
    $pass="********";
    $data="auctionTemps";
    
    mysql_connect(localhost,$user,$pass);
    
    @mysql_select_db($data) or die( "Unable to select database");
    
    // Select column 1 from table name where column name = $your_var.
    $sql = "SELECT * FROM savedTemps WHERE tempID = '{$tempID}'";
    // If mysql_query returns false, we'll die with the error.
    $result = mysql_query( $sql ) or die( mysql_error );
     
    // If a there is a match
    if ( mysql_num_rows( $result ) > 0 )
    {
    $row = mysql_fetch_array( $result );
    
    }
    
    else{
    echo $errorM;
    }
    
    mysql_close();
    ?>
    I am using <? echo $row['title'];?> to show values to a page.....is something wrong? should it be print instead of echo?
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Code:
    or die( mysql_error );
    
    // should be:
    or die( mysql_error() );
    Do a print_r() on $row to see it's contents.

    Comment

    • anfetienne
      Contributor
      • Feb 2009
      • 424

      #3
      like this print_r($row)?

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by anfetienne
        like this print_r($row)?
        yes .

        Comment

        • anfetienne
          Contributor
          • Feb 2009
          • 424

          #5
          ok thanks again markus

          Comment

          Working...