我正在尝试创建一个给出警告的用户登录表单,这是我的所有脚本
连接.php
<?php
$con = mysql_connect("localhost" , "xxx" , "xxxxxx");
if(!$con)
{
die('Could Not Connect' . mysql_error());
}
else
{
echo "User Connect". "<br>";
}
mysql_select_db("xxxx" , $con)
or die('Error: could not connect' . mysql_error());
echo "Database connected" . "<br>";
function dbQuery($sql)
{
return mysql_query($sql) or die('Query Failed. ' . mysql_error());
}
function dbAffectedRows()
{
global $dbConn;
return mysql_affected_rows($dbConn);
}
function dbFetchArray($result, $resultType = MYSQL_NUM)
{
return mysql_fetch_array($result, $resultType);
}
function dbFetchAssoc($result)
{
return mysql_fetch_assoc($result);
}
function dbFetchRow($result)
{
return mysql_fetch_row($result);
}
function dbFreeResult($result)
{
return mysql_free_result($result);
}
function dbNumRows($result)
{
return mysql_num_rows($result);
}
function dbSelect($dbName)
{
return mysql_select_db($dbName);
}
?>
函数.php
<?php
require_once 'connect.php';
$userName = $_POST['txtUserName'];
$password = $_POST['txtPassword'];
//$sql = mysql_query("SELECT user_id FROM user WHERE user_name = '$userName' AND user_password = '$password'") or die('error in query!' . mysql_error());
$sql = "SELECT user_id FROM user WHERE user_name = '$userName' AND user_password = '$password'";
echo $result = dbQuery($sql);
if(dbNumRows($result)==1){
$row = dbFatchAssoc($result);
echo '$row[user_id]';
}
?>
它在下面的connect.php中给出警告
警告:mysql_num_rows() 期望参数 1 是资源,在 connect.php 中给出布尔值
有人请帮助我,在此先感谢
我添加了整个警告表看看
( ! ) 警告:mysql_num_rows() 期望参数 1 是资源,布尔值在 C:\wamp\www\tb_ad\connect.php 第 48 行调用堆栈中给出
# Time Memory Function Location
1 0.0032 367408 {main}( ) ..\function.php:0
2 0.0130 385640 dbNumRows( ) ..\function.php:15
3 0.0130 385672 mysql_num_rows ( ) ..\connect.php:48