mysql_fetch_array()期望参数1是给定的资源布尔值 [英] mysql_fetch_array() expects parameter 1 to be resource boolean given

查看:106
本文介绍了mysql_fetch_array()期望参数1是给定的资源布尔值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行代码时出现此错误

mysql_fetch_array()期望参数1为资源布尔值。



< pre lang =xml> <? php



$ con = mysql_connect( localhost,username,password);

if(!$ con)

{

die(connectivity error.mysql_error());

}

mysql_select_db(cool,$ con);

if(isset($ _ POST ['ok']))

{

$ s = 从*中选择* ogin,其中username ='$ _ POST [uname]'和password ='$ _ POST [pwd]' ;

$ name = mysql_query($ s) die(mysql_error());

$ i = 0;

while($ row = mysql_fetch_array($ name))

< span class =code-summarycomment> {

$ i ++;



}



if($ i > 0)
{

回波( HI);
}
其他
{
echo< script language =' javascript' > ;
echoalert('抱歉,你不能来找我');;
echo< / script > ;
}
}
?>
< html >
< head > < / head >
< body >
< 表格 操作 = 方法 = 发布 >
< 输入 type = text name = uname / >
< 输入 类型 = text name = pwd / >
< 输入 type
= submit 名称 = ok value = 登录 / >
< span class =code-keyword>< / form >
< / body >
< / html >
< / body >

请给出正确的编码

解决方案

con = < span class =code-keyword> mysql_connect( localhost,username,password);

if(!


< blockquote> con)

{

die(connectivity error.mysql_error()); < span class =code-summarycomment>

}

mysql_select_db(cool,


con);

如果(isset(

I am getting this error while i running the code
mysql_fetch_array() expects parameter 1 to be resource boolean given.

<?php



$con=mysql_connect("localhost","username","password");

if(!$con)

{

die("connectivity error".mysql_error());

}

mysql_select_db("cool",$con);

if(isset($_POST['ok']))

{

$s="select * from login where username='$_POST[uname]' and password='$_POST[pwd]'";

$name=mysql_query($s) or die(mysql_error());

$i=0;

    while($row=mysql_fetch_array($name))

    {

    $i++;



    }



    if($i>0)
    {

    echo("hi");
        }
        else
        {
        echo "<script language='javascript'>";
        echo "alert('sorry you cant come to me');";
        echo "</script>";
        }
}
?>
<html>
<head></head>
<body>
<form action="" method="post">
<input type="text" name="uname"/>
<input type="text" name="pwd"/>
<input type="submit" name="ok" value="Login"/>
</form>
</body>
</html>
</body>

pls give the correct coding

解决方案

con=mysql_connect("localhost","username","password"); if(!


con) { die("connectivity error".mysql_error()); } mysql_select_db("cool",


con); if(isset(


这篇关于mysql_fetch_array()期望参数1是给定的资源布尔值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆