警告:mysql_query()期望参数2为资源,在第15行的C:\ wamp \ www \ pyrll \ emlhome.php中给出布尔值 [英] Warning: mysql_query() expects parameter 2 to be resource, boolean given in C:\wamp\www\pyrll\emlhome.php on line 15
本文介绍了警告:mysql_query()期望参数2为资源,在第15行的C:\ wamp \ www \ pyrll \ emlhome.php中给出布尔值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试了其他与我类似的答案,但徒劳无功.
I've tried other answers similar to mine but in vain.
这是代码.
<?php
session_start();
$con=isset($_POST['con']);
include("header.php");
include("dbconnection.php");
$logindt = date("Y-m-d");
$qresult=mysql_query("SELECT * FROM attendance WHERE logintime > '$logindt 00:00:00' AND logintime < '$logindt 23:59:59' AND empid ='$_SESSION[emid]'");
$counts = mysql_num_rows($qresult);
$attid = date("Y-m-d h:i:s");
if(isset($_POST["login"]))
{
$insdb ="INSERT INTO attendance(empid,logintime) VALUES ('$_SESSION[emid]','$attid')";
mysql_query($insdb,$con);//line 15
推荐答案
问题恰恰是错误消息所说的.
The problem is exactly what the error message says.
第15行是:
mysql_query($insdb,$con);//line 15
$con
在第3行定义.
$con=isset($_POST['con']);
这确实是一个布尔值,指示$_POST['con']
是否存在. mysql_query
需要一个用于标识连接的第二个参数(无论mysql_connect
返回什么)(如果您定义了它).我认为这里不需要这样做,所以只需删除第二个参数,我认为它应该可以工作.
This is indeed a boolean indicating if $_POST['con']
exists. mysql_query
expects a 2nd parameter that indentifies the connection (whatever mysql_connect
returns) -if- you define it. I don't think that is needed here, so simply remove the second parameter and I think it should work.
这篇关于警告:mysql_query()期望参数2为资源,在第15行的C:\ wamp \ www \ pyrll \ emlhome.php中给出布尔值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文