Hi I made a query to a table below and when I tried to get the value in each column , it returns the same value from the first column for all the other columns.
To elaborate
In my database table I have the following:
owner_id = 21
pet_id = 1
name = fluffy
color = green
type = dog
sub_type = boxer
location = LA
however whenever I try to access one column, say the name column, it returns 21 which is the value in the owner_id column corresponding to that pet_id. I am not sure why this is happening.
$query = sprintf("SELECT * FROM `petAttributes` where pet_id ='%d'",$p_id);
$result = performQuery($query);
$owner_id = stripslashes(mysql_result($result,"owner_id"));
$pet_id = stripslashes(mysql_result($result,"pet_id"));
$name = stripslashes(mysql_result($result,"name"));
$color = stripslashes(mysql_result($result,"color"));
$type = stripslashes(mysql_result($result,"type"));
$sub_type = stripslashes(mysql_result($result,"sub_type"));
$loc = stripslashes(mysql_result($result,"location"));
Information on my environment
PHP Version 5.2.14
MYSQL version 5.0.67