Forum Moderators: coopster
I just cant spot the error, a pair of helping eyes would be nice :)
function func_select_random_members_pay($1, $2, $skip_uid)
{
@mysql_select_db('db');
$query = 'SELECT * FROM table'.
" WHERE value > '$1'".
" AND user_id!= '$skip_uid'".
" LIMIT '$2'";
$result = mysql_query($query) or die ("Error selecting random members from database");
if ($result){
return true;
}else{
return false;
}
} aside from the fact this isnt random, still have to modify the query from that...what is wrong here? :( been looking at it for half an hour now and it seems ok to me
<?
$query = 'SELECT * FROM table'.
" WHERE value > '$1'".
" AND user_id!= '$skip_uid'".
" LIMIT '$2'";
echo '<p>1: ',$query;
$query = '
SELECT * FROM table WHERE value > '.$1.'
AND user_id!= '.$skip_uid.' LIMIT '.$2;
echo '<p>2: ',$query;
?>
then I get
Parse error: parse error, unexpected T_DNUMBER, expecting T_VARIABLE or '$' in #*$! on line 10
so I make the second one a single line
$query = 'SELECT * FROM table WHERE value > '.$1.' AND user_id!= '.$skip_uid.' LIMIT '.$2;
and get
Parse error: parse error, unexpected T_DNUMBER, expecting T_VARIABLE or '$' in xxx on line 8
so we stop using numbers for varnames in the second query
$query = 'SELECT * FROM table WHERE value > '.$a1.' AND user_id!= '.$skip_uid.' LIMIT '.$b2;
and my output is
1: SELECT * FROM table WHERE value > '$1' AND user_id!= '' LIMIT '$2'
2: SELECT * FROM table WHERE value > AND user_id!= LIMIT
so the second one resolves properly but the first is still hooped
[php.net...]
A valid variable name starts with a letter or underscore,
There appears to be a problem in that you are using the period in your query. Try it without them. Also noticed a missing apostrophe on the variable $b2. Also, not sure, but there is no space after the field name, user_id. Finally, I quote the entire query string.
$query = "SELECT * FROM table WHERE value > '$a1' AND user_id!= '$skip_uid' LIMIT '$b2' ";
<edit> I think the missing space after user_id has something to do with the editing of the message. ie, it closes up and I know I've editied it twice now...
</edit>
really never knew you couldnt use a number for a variable name
$ROWNUM = 'ROW' . $row_number;
Gives me $ROW1, $ROW2, $ROW3.... whatever value is currently assigned to $row_number.
Otherwise, variable names must begin with a letter or underscore. So, $1 = 1 is illegal (but you discovered that already...)