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); Link to comment https://forums.phpfreaks.com/topic/224273-mysqli_num_rows/ 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>'; } Link to comment https://forums.phpfreaks.com/topic/224273-mysqli_num_rows/#findComment-1158724 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? Link to comment https://forums.phpfreaks.com/topic/224273-mysqli_num_rows/#findComment-1158726 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. Link to comment https://forums.phpfreaks.com/topic/224273-mysqli_num_rows/#findComment-1158731 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. Link to comment https://forums.phpfreaks.com/topic/224273-mysqli_num_rows/#findComment-1158734 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.