mysql_num_rows()期望参数1是资源 [英] mysql_num_rows() expects parameter 1 to be resource
问题描述
Helo编码器
我正在尝试将记录插入数据库表但我收到此错误
mysql_num_rows()期望参数1为资源,布线在第107行的C:\ wamp \ www.hn_nations_\\register.php中给出
我不知道出了什么问题。请帮助
include('localhost.php');
if(isset($ _ POST [SubmitButton])){< br $>
$ fullname = $ _ POST ['FirstName'];
$性别= $ _ POST ['YourGender'];
$ AgeGroup = $ _ POST ['AgeGroup'];
$ Organization = $ _ POST ['Org'];
$目的= $ _ POST ['目的'];
$ NRC = $ _ POST ['NRC'];
$省= $ _ POST ['省'];
$ dbDate = $ _ POST ['dbDate'] ;
$地址= $ _ POST ['地址'];
$ query = mysql_query(SELECT * FROM学生WHERE NRC ='$ NRC');
$ numrows = mysql_num_rows($ query); //这是我编辑中的第107行
if($ numrows == 0){
$ sql =(INSERT INTO`school`设置FullName ='$ fullname ',Gender ='$ Gender',AgeGroup ='$ AgeGroup',Organization ='$ Organization',目的='$目的',NRC ='$ NRC',省='$省',dbDate ='$ dbDate' ,Address ='$ Address');
$ result = mysql_query($ sql);
if($ result)
echo数据已保存;
}否则{
echo无法保存数据;
}
}
?>
Helo Coders
I'm trying to insert a record into a database table but i'm getting this error
mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\United_Nations\register.php on line 107
I do not know what is wrong. Please help
include('localhost.php');
if (isset($_POST["SubmitButton"])){
$fullname=$_POST['FirstName'];
$Gender=$_POST['YourGender'];
$AgeGroup=$_POST['AgeGroup'];
$Organisation=$_POST['Org'];
$Purpose=$_POST['Purpose'];
$NRC=$_POST['NRC'];
$Province=$_POST['Province'];
$dbDate=$_POST['dbDate'];
$Address=$_POST['Address'];
$query=mysql_query("SELECT * FROM students WHERE NRC='$NRC'");
$numrows=mysql_num_rows($query); // this is line 107 in my editor
if($numrows==0){
$sql = ("INSERT INTO `students` set FullName='$fullname', Gender='$Gender', AgeGroup='$AgeGroup', Organisation='$Organisation', Purpose='$Purpose', NRC='$NRC', Province='$Province', dbDate='$dbDate', Address='$Address'");
$result=mysql_query($sql);
if($result)
echo " Data has been Saved ";
}else {
echo "Could not Save Data";
}
}
?>
推荐答案
_POST [SubmitButton])){
_POST["SubmitButton"])){
fullname =
fullname=
_POST ['FirstName'];
_POST['FirstName'];
这篇关于mysql_num_rows()期望参数1是资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!