Xtremer360 Posted January 13, 2011 Share Posted January 13, 2011 I keep getting this error because of my coding and I'm not sure why all I know is it has to do wiht the query itself. <b>Warning</b>: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in <b>C:\wamp\www\E-Fed Manager (localhost)\processes\template.php</b> on line <b>37</b><br /> $query = "SELECT * FROM `templates` WHERE `templatename` = $templatename"; $result = mysqli_query ( $dbc, $query ); // Run The Query $rows = mysqli_num_rows($result); Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 13, 2011 Share Posted January 13, 2011 $query = "SELECT * FROM `templates` WHERE `templatename` = $templatename"; if( $result = mysqli_query ( $dbc, $query ) ) { // Run The Query $rows = mysqli_num_rows($result); } else { echo "<br>Query: $query<br>Produced error:" . mysqli_error($dbc) . '<br>'; } Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted January 13, 2011 Author Share Posted January 13, 2011 <br>Query: SELECT * FROM `templates` WHERE `templatename` = Testing Template 2<br>Produced error: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 'Template 2' at line 1<br><br /> <b>Notice</b>: Undefined variable: rows in <b>C:\wamp\www\E-Fed Manager (localhost)\processes\template.php</b> on line <b>42</b><br /> Which means my only issue is the rows variable not being defined, correct? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 13, 2011 Share Posted January 13, 2011 No, it actually looks like the cause of the query failure is the lack of quotes around $templatename in the query string. The undefined variable $rows warning is a probably a result of the first error, unless there's another query further along in the script. Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted January 13, 2011 Author Share Posted January 13, 2011 That's right I noticed it after comparing some other queries. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.