Where select

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
after_shox
Forum Newbie
Posts: 13
Joined: Wed Mar 10, 2004 11:53 am

Where select

Post by after_shox »

Having a bit of a headache with this :roll:

Code: Select all

<?php
			
mysql_pconnect("localhost","**********","******");
mysql_select_db("douple_Newdata");
$result = mysql_query("select * from counter where id='3'");
mysql_fetch_array($result);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
extract ($row);
echo "$count";



?>
but if i take where id='3' out of the query it works? Even though there is a "3" id in the table.

i get this error: "extract(): First argument should be an array"
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

try taking this line out:

Code: Select all

mysql_fetch_array($result);
after_shox
Forum Newbie
Posts: 13
Joined: Wed Mar 10, 2004 11:53 am

Post by after_shox »

cool it worked :wink: But why ?

Thanks
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

Code: Select all

mysql_fetch_array($result);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
It's because mysql_fetch_array() was occuring twice. Which it shouldn't. On the note, you can also do:

Code: Select all

$row = mysql_fetch_assoc($result);
-Nay
after_shox
Forum Newbie
Posts: 13
Joined: Wed Mar 10, 2004 11:53 am

Post by after_shox »

nice one, thanks for everyones help :)
Post Reply