Hi guys,
I just started to learn MySql and php and am relatively new to how databases work. I setup my database and wrote the following code and I get the error:
[code=php]
mysql_select_db ("breedknowledg e", $con);
$qheight = $_POST["height"];
$qminwgt = $_POST["minwgt"];
$qmaxwgt = $_POST["maxwgt"];
$qexercize = $_POST["exercize"];
$qgrooming = $_POST["grooming"];
if ($qheight == "") { $qheight = "99"; }
if ($qminwgt == "") { $qminwgt = "1"; }
if ($qmaxwgt == "") { $qmaxwgt = "999"; }
$result = mysql_query("SE LECT * FROM breeds WHERE weight >= $qminwgt AND weight <= $qmaxwgt AND exercize = $qexercize ORDER BY breedname");
$numrows = mysql_num_rows( $result);
[/code]
Now when I remove "AND exercize = $qexercize" I don't get the error. The only difference is that this field is a text field. I can run the query just fine in my MySQL admin program through my hosting site. The code looks fine I don't get it! Please help! Thanks!
I just started to learn MySql and php and am relatively new to how databases work. I setup my database and wrote the following code and I get the error:
Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource
mysql_select_db ("breedknowledg e", $con);
$qheight = $_POST["height"];
$qminwgt = $_POST["minwgt"];
$qmaxwgt = $_POST["maxwgt"];
$qexercize = $_POST["exercize"];
$qgrooming = $_POST["grooming"];
if ($qheight == "") { $qheight = "99"; }
if ($qminwgt == "") { $qminwgt = "1"; }
if ($qmaxwgt == "") { $qmaxwgt = "999"; }
$result = mysql_query("SE LECT * FROM breeds WHERE weight >= $qminwgt AND weight <= $qmaxwgt AND exercize = $qexercize ORDER BY breedname");
$numrows = mysql_num_rows( $result);
[/code]
Now when I remove "AND exercize = $qexercize" I don't get the error. The only difference is that this field is a text field. I can run the query just fine in my MySQL admin program through my hosting site. The code looks fine I don't get it! Please help! Thanks!
Comment