OranniS Posted September 24, 2006 Share Posted September 24, 2006 hii was making a start page, where one must register a personal code, as in password, to proceed to the main site.to check if the code has already been used by someone else, i used the mysql_num_rows() function, but somethings making it fail...this is where i define a function wich is causing the whole jam. ive tried echoeing here and there, turns out the line with the error is the one with the$count = mysql_num_rows($result) or die(mysql_error());...[code]PHP Code:<?php session_start(); require_once('vars.php'); //connectie maken met DB $db = mysql_connect("localhost", "dieetopmaat_be", "dieetDB") or die(mysql_error()); mysql_select_db(dieetopmaat_be, $db) or die(mysql_error()); function check_presence($table, $row, $value){ $sql = "SELECT * FROM $table WHERE $row = '$value'"; $result = mysql_query($sql) or die(mysql_error()); $count = mysql_num_rows($result) or die(mysql_error()); if($count >= 1) { return TRUE; }else { return FALSE; }[/code]thanks to anyone who replies!OranniSps: dont mind the language, its written in dutch Link to comment https://forums.phpfreaks.com/topic/21826-somethings-wrong-with-the-mysql_num_rows/ Share on other sites More sharing options...
alpine Posted September 24, 2006 Share Posted September 24, 2006 [code]<?phpfunction check_presence($table, $row, $value){$sql = mysql_query("SELECT * FROM $table WHERE $row = '$value'") or die(mysql_error());if(mysql_num_rows($sql)=="0"){return false;}else{return true;}}?>[/code] Link to comment https://forums.phpfreaks.com/topic/21826-somethings-wrong-with-the-mysql_num_rows/#findComment-97518 Share on other sites More sharing options...
fenway Posted September 25, 2006 Share Posted September 25, 2006 To elaborate, 0 is a valid result, but will return false when used as a numerical comparison. Link to comment https://forums.phpfreaks.com/topic/21826-somethings-wrong-with-the-mysql_num_rows/#findComment-97938 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.