You get resource id #4 because $result is a resource, you have to extract the values contained in it in such a way
$result=mysql_query($sql); $values = mysql_fetch_array($result); var_dump($values);
More about variable resource
Update 2 (from OP comments)
You print the values using the field name. In this case, you will need to change to
while($rows=mysql_fetch_array($result,MYSQL_ASSOC))
Or you can directly use mysql_fetch_assoc () , which in your case will be
while($rows=mysql_fetch_assoc($result)){ echo $rows['id']; }
source share