what's wrong with this syntax?

miocene2

New Member
Messages
15
Reaction score
0
Points
0
PHP:
$result2 = mysql_query("SELECT * FROM userpayments WHERE userid = $userid[$k] ORDER BY id ASC");

I suspect it's something to do with the userid = $userid[$k] bit but not sure what the correct suntax is.

Can someone help me out?? Cheers
 

Twinkie

Banned
Messages
1,389
Reaction score
12
Points
0
It has to be like this:

PHP:
$result2 = mysql_query("SELECT * FROM userpayments WHERE userid = {$userid[$k]} ORDER BY id ASC");
Other than simple variable calls, curly braces are needed.
 
Last edited:

miocene2

New Member
Messages
15
Reaction score
0
Points
0
Thanks. Got another prob now:

using this code:

PHP:
$result2 = mysql_query("SELECT * FROM userpayments WHERE userid = {$userid[$k]} AND paymentid = $payid ORDER BY paymentid ASC");
while($row2 = mysql_fetch_array($result2))
Gives me this error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/miocene1/public_html/includes/getdata.php on line 52

Edit: Nevermind got one of my column names wrong
 
Last edited:

Twinkie

Banned
Messages
1,389
Reaction score
12
Points
0
That would be because the mysql query is coming back with no results. You will have to go into PHPmyAdmin and see what wrong. Or, you can post whats in those variables (what the query resolves to, $userid, and page link), and the mysql database entry you are trying to find here as well as the table structure. To me, the first one is easier :)
 
Top