Page 1 of 1

mysql_fetch_array problem

Posted: Fri Jan 22, 2010 6:49 pm
by dave1909

Code: Select all

$you = mysql_fetch_array(mysql_query("SELECT * FROM $tab[pimp] WHERE id='$id';"));
the above code returns 7 for every field and i have no idea why. has anybody ever seen anything like this before?
when i pasted that line into a different page it worked perfectly. there are no records in the database table which have every field set to 7

Re: mysql_fetch_array problem

Posted: Fri Jan 22, 2010 6:59 pm
by AbraCadaver
Well your query looks borked, try:

Code: Select all

$you = mysql_fetch_array(mysql_query("SELECT * FROM " . $tab['pimp'] . " WHERE id='$id'"));
But I would split it (more readable and less prone to errors):

Code: Select all

$result = mysql_query("SELECT * FROM " . $tab['pimp'] . " WHERE id='$id'");
$you = mysql_fetch_array($result);

Re: mysql_fetch_array problem

Posted: Fri Jan 22, 2010 7:06 pm
by dave1909
thanks, that seems to have done the job. why would it work on some pages but not others?

on a separate note, any idea why a mysql field would be set to the maximum value when its not told to? its happened a few times now but i cant pinpoint where or why. kinda important seeing as my site is a game and somebody suddenly gets 4.94 billion turns from nowhere