mysql_fetch_array problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
dave1909
Forum Newbie
Posts: 22
Joined: Sat Jul 25, 2009 8:56 pm

mysql_fetch_array problem

Post 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
Last edited by dave1909 on Fri Jan 22, 2010 7:09 pm, edited 1 time in total.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: mysql_fetch_array problem

Post 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);
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
dave1909
Forum Newbie
Posts: 22
Joined: Sat Jul 25, 2009 8:56 pm

Re: mysql_fetch_array problem

Post 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
Post Reply