php - Why can't I use mysql_num_rows? -
php - Why can't I use mysql_num_rows? -
this question has reply here:
mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row() expects parameter 1 resource or mysqli_result, boolean given 32 answerson line 25 in code, wrote this:
$check = mysql_num_rows($u_check);
and gave me error:
warning: mysql_num_rows() expects parameter 1 resource, boolean given in d:\download\htdocs\hoping.php on line 25
here entire code of file:
<?php include ("./header.inc.php"); ?> <?php $reg = @$_post['reg']; $fn = ""; $ln = ""; $un = ""; $em = ""; $em2 = ""; $pswd = ""; $pswd2 = ""; $d = ""; $u_check = ""; $fn = strip_tags(@$_post['fname']); $ln = strip_tags(@$_post['lname']); $un = strip_tags(@$_post['username']); $em = strip_tags(@$_post['email']); $em2 = strip_tags(@$_post['email2']); $pswd = strip_tags(@$_post['password']); $pswd2 = strip_tags(@$_post['password2']); $d = date("y-m-d"); if($reg){ if($em==$em2){ $u_check = mysql_query("select username test username='$un'"); $check = mysql_num_rows($u_check); if($check == 0){ if($fn&&$ln&&$un&&$em&&$em2&&$pswd&&$pswd2){ if($pswd==$pswd2){ if(strlen($un)>25||strlen($fn)>25||strlen($ln)>25){ echo "the maximum limit username/first name/last name 25 characters!"; } else { if(strlen($pswd)>30||strlen($pswd)<5){ echo "your password must between 5 , 30 characters long!"; } else { $pswd =md5($pswd); $pswd2 = md5($pswd2); $query = mysql_query("insert test values ('', '$un', '$fn', '$ln','$em', '$pswd', '$d','0')"); die("<h2>welcome communicate</h2>login business relationship started ..."); } } } else { echo "your passwords don't match!"; } } else { echo "please fill in of fields"; } } else { echo "username taken ..."; } } else { echo "your e-mails don't match!"; } } if(isset($_post["user_login"]) && isset($_post["password_login"])) { $user_login = preg_replace('#[^a-za-z0-9]#i', '', $_post["user_login"]); $password_login = preg_replace('#[^a-za-z0-9]#i', '', $_post["password _login"]); } ?> <td width="40%"> <h2>sign below!</h2> <form action="#" method="post"> <input type="text" name="fname" size="25" placeholder="first name" /><p /> <input type="text" name="lname" size="25" placeholder="last name"/><br /><br /> <input type="text" name="username" size="25" placeholder="username"/><br /><br /> <input type="text" name="email" size="25" placeholder="email address"/><br /><br /> <input type="text" name="email2" size="25" placeholder="email address (again)"/><br /><br /> <input type="text" name="password" size="25" placeholder="password"/><br /><br /> <input type="text" name="password2" size="25" placeholder="password (again)"/><br /><br /> <input type="submit" name="reg" value="sign up!"> </td> </tr> </table> <?php include ("./footer.inc.php"); ?>
why giving me error?
mysql_query returns false on error (a boolean), maybe happening. seek , print error if so? example:
$u_check = mysql_query("select username test username='$un'"); if(!$u_check) { die('invalid query: ' . mysql_error()); }
that may point in right direction. note mysql_query , related functions long deprecated. should larn how utilize mysqli* functions.
php mysql phpmyadmin
Comments
Post a Comment