GodAtum Posted December 3, 2009 Share Posted December 3, 2009 Hi all, I'm new to PHP and have been following the various tutorials. I have come across a problem on the first page I have coded. Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\... My code is: public function verify_user_credentials ($name, $password){ return mysql_num_rows(mysql_query("SELECT * FROM t_users WHERE user = '" . $name . "' AND password = '" . $password . "'")); } User and password are CHAR fields. Link to comment https://forums.phpfreaks.com/topic/183858-help-with-my-1st-php-page/ Share on other sites More sharing options...
cags Posted December 3, 2009 Share Posted December 3, 2009 Common error, get used to it. It means that the call to mysql_query is failing and hence returning false, therefore mysql_num_rows cannot get a number of rows from the value FALSE. You will need to add some error trapping. echo out mysql_error to after running mysql_query to find out what the error may be. Link to comment https://forums.phpfreaks.com/topic/183858-help-with-my-1st-php-page/#findComment-970545 Share on other sites More sharing options...
rajivgonsalves Posted December 3, 2009 Share Posted December 3, 2009 where is your resource identifier ? mysql_query($sql, $link), it think it won't pick up the global $link in the function, not to sure on this though you'll have to check Link to comment https://forums.phpfreaks.com/topic/183858-help-with-my-1st-php-page/#findComment-970546 Share on other sites More sharing options...
GodAtum Posted December 3, 2009 Author Share Posted December 3, 2009 Many thanks for all help. After echoing mysql_error() I discovered the problem, I misspelled the database name in my connection script I am now tring to implement the Google Maps API. I am currently pulling a postcode from a databse into a table on a page. I need some help in passing that postcode into a text box on another page. Address page: <table border="black"> <tr> <th>Postcode</th> <th>Latitude</th> <th>Longitude</th> </tr> <?php $result = TiaDB::getInstance()->get_postcodes_by_person_id($personID); while($row = mysql_fetch_array($result)) { $postcode = $row["postcode"]; $lat = $row["latitude"]; $long = $row["longitude"]; echo "<tr><td>" . strip_tags($postcode,'<br><p><h1>')."</td>"; echo "<td>". strip_tags($lat)."</td>\n"; echo "<td>". strip_tags($long)."</td></tr>\n"; } ?> </table> Maps page: <body> Postcode: <input type="text" id="postcode" size="10" /> <input type="submit" value="Place Marker" onclick="javascript:usePointFromPostcode(document.getElementById('postcode').value, placeMarkerAtPoint)" /> <input type="submit" value="Center Map" onclick="javascript:usePointFromPostcode(document.getElementById('postcode').value, setCenterToPoint)" /> <input type="submit" value="Show Lat/Lng" onclick="javascript:usePointFromPostcode(document.getElementById('postcode').value, showPointLatLng)" /> <div id="map"> </div> </body> Link to comment https://forums.phpfreaks.com/topic/183858-help-with-my-1st-php-page/#findComment-970661 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.