You are here: mysql_fetch_array yielding different results to MySQL's output « PHP SQL « IT news, forums, messages
mysql_fetch_array yielding different results to MySQL's output

Posted by J_K9 on 07/17/07 11:14

Hi,

I'm having a problem with a web app I am developing. The code in
question is:

$sql = "SELECT groupID FROM memberships WHERE userID = ".$uid;
$result = mysql_query($sql);
$result = mysql_fetch_array($result);
print_r($result);

Now, print_r($result) displays the following (when $uid = 1):

Array ( [0] => 1 [groupID] => 1 )

HOWEVER, that's not what it should be. If I run the same command at
the MySQL CLI I get the following:

+---------+
| groupID |
+---------+
| 1 |
| 2 |
+---------+

So, if I'm not mistaken, the $result array should contain ([0] => 1,
[1] => 2), NOT what PHP says it does. Can someone please tell me why
this is happening and how to correct it? I need to use the data
outputted by MySQL in my PHP script but if PHP is not receiving the
same data then I have no way of using it.

Thanks,

-Max

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация