PHP version 4.03 -
I have a function that determines which query to run on a mysql database. However, it always returns 0 results even though I know results are in there. Here's what I have:
$usertable = tablename;
$stval = userentry;
$lim = 0;
function nex($lim) {
global $usertable;
global $stval;
global $lim;
$query = "Select * from $usertable where issn1 like '%$stval%' order by issnum limit $lim, 10";
return $query;
}
$query = nex($lim);
$resultlst = mysql_query($query);
$number = mysql_num_rows($resultlst);
This always returns 0 matches. If I do it the following way it works but I need the query statement inside the function:
$resultlst = mysql_query("Select * from $usertable where issn1 like '%$stval%' order by issnum limit $lim, 10");
Can anyone help? I don't understand why this is not working. I do an echo $query after pulling the value from the function and the statement is being passed correctly.
I just starting using php about a week ago and thought maybe I was missing something. Thanks in advance to anyone who can help!