Jump to content

[SOLVED] MySQL returning multiple rows on single row query


WRXHokie

Recommended Posts

I'm trying to do a query on my database in a php script in which i take a integer value from a form and then check it against a table in my database.  The integer value is a unique id for a person table, so there is only one id for each person in the table.  Thus a query on the table such as "SELECT * FROM $db.person WHERE id = 3"  should return only one row.  But it is in fact returning multiple rows.  I've checked my database... its setup correctly with 11 people in it... each with a unique id from 1-11.  Here's my php code:

 

$query = "SELECT * FROM $db.person WHERE id = $personid";
$result = mysql_query($query);
$r = mysql_fetch_array($result);
print count($r);

 

For some reason this query returns a count value of 6 where $personid is set to an integer value from 1-11. 

 

Any ideas why this is happening?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.