Jump to content

[SOLVED] MySQL returning multiple rows on single row query


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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.