Jump to content


Photo

displaying results problem


  • Please log in to reply
1 reply to this topic

#1 chuddyuk

chuddyuk
  • Members
  • PipPip
  • Member
  • 28 posts
  • LocationEngland

Posted 13 June 2006 - 06:25 PM

this is my code

<?php 

mysql_connect("localhost","********","***********"); 
    
//select which database you want to edit
mysql_select_db("grange"); 


$result = @mysql_query("select * from gallery");


while($r=@mysql_fetch_array($result))
{    

  
   $id=$r["id"];
   $name=$r["name"];
   $who=$r["src"];

   

   echo "$id <br> $name <br> $src ";
}

?>

Nothing is showing up at all, no errors. when i remove the "@"s then i start getting errors like:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/chuddyuk/public_html/grange/gallery/index.php on line 12

but i cant understand this. ive done this loads of times and its worked. anyone know y nothing shows up now?

any help is much appriciated!!!





#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 13 June 2006 - 06:31 PM

The @ symbol is error suppression and should be used EXTREMLY sparingly, unlike what you have there. You should be using "or die("some message")" after mysql_query calls.

That error is the result of a bad SQL query. Maybe you don't have a table called gallery or maybe you're not connected to the database.

You might want to read the "annoying errors" section of the FAQ found in the BIG RED LINK in my signature.

Info: PHP Manual





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users