SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Aug 2007
    Posts
    318
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post Database fetching gives warning

    I am using the following code to extract info from db and display it. The extracted info is basically a link to a stored image.

    I get the following warning after $sql data is printed as shown

    SELECT * FROM reflections WHERE `trusted` = 1 AND `catid` = 1 ORDER BY `id` ASC LIMIT 8, 1
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mysite/public_html/addons/class.upload/pages.php on line 66

    PHP Code:
    $sql "SELECT * FROM reflections WHERE `trusted` = 1 AND `catid` = 1 ORDER BY `id` ASC LIMIT $from$max_results";

    mysql_query($sql);
    echo 
    $sql;
    while(
    $row mysql_fetch_array($sql))
    {
      if(
    strlen(isset($_GET['tcheck']))>&& $_GET['tcheck']==$safeurl->make_safe_url($row['title'])){
           
    $tcheck=trim(mysql_real_escape_string($_GET['tcheck']));
      }else{
            echo 
    "invalid query";
            exit;}

        echo 
    "<!--start-->";                
        echo 
    "<font size=3><b>";
        echo 
    $row['title']."</b><br /></font>";
        echo 
    "<font size=2>";
        echo 
    "Added On ";    
        echo 
    date("jS F Y H:i:s"$row['date'])."<p>";    
        echo 
    '<img src="/addons/class.upload/test/'.$name.'" border="0" height="50%" width="50%" alt="' $row['title']  .'" />';
        echo 
    "<!--end-->";


  2. #2
    Chessplayer kleineme's Avatar
    Join Date
    Apr 2004
    Location
    Germany
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    change
    echo $sql;
    into
    echo mysql_error();
    and let us know what it says
    Never ascribe to malice,
    that which can be explained by incompetence.
    Your code should not look unmaintainable, just be that way.

  3. #3
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    change mysql_query($sql); to mysql_query($sql) or die(mysql_error());

  4. #4
    SitePoint Addict
    Join Date
    Aug 2007
    Posts
    318
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by longneck View Post
    change mysql_query($sql); to mysql_query($sql) or die(mysql_error());
    Ya i made few changes in the query itself and then it worked after adding mysql_error()

    Thanks for your help


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
  •