I'm new to the forum
After I worked through a PHP book, I'm working on my first actual program now.Yesterday I stumbled upon a problem, I wasn't able to solve and I couldn't find a solution through google.
I have this code:
- Code: Select all
$sqlab = "select * from children";
$sqlab .= " where index = " .$kknumber;
$res = mysql_query($sqlab);
$num = mysql_num_rows($res);
if($num==0)
{
echo "no matching data / no hay datos coincidentes";
}
After that I just read out the fields with mysql_fetch_assoc.
index is the primary key of the table and has auto increment.
With the code as it is I get following error:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in ***\***\***.php on line 67
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'index = 2' at line 1
Line 67 is "$num = mysql_num_rows($res);"
I tried to change the line:
- Code: Select all
$sqlab .= " where index = " .$kknumber;
into that (witout the " ")
- Code: Select all
$sqlab .= " where index = $kknumber";
without luck
Than I tired that (with index in ' ')
- Code: Select all
$sqlab .= " where 'index' = $kknumber";
And I dont get an error anymore, but the program doesn't find any result.
Can anybody help me please?
Thanks,
mitti2000


