使用 mysql_error() 函数没有显示错误。msqli_query() 工作正常,但是当我在它旁边添加 mysql_error 时,即使查询无效并且连接错误,我也不会在网页中收到任何信息。
example. mysqli_query($link, $query) or die(mysql_error()); <--- Nothing comes up
链接脚本:
<?php
#SET DATABASE CREDENTIALS
$mysql_host = 'localhost';
$mysql_username = 'root';
$mysql_password = 'root';
$mysql_db = 'attendance';
$mysql_error = 'Error: connection';
//TEST CONNECTION
$link = mysqli_connect( $mysql_host, $mysql_username, $mysql_password, $mysql_db) or die($mysql_error);
if(mysqli_connect_errno())
{
printf("Connection Failed: %s\n", mysqli_connect_error());
exit();
}
?>
查询脚本:
<?php
require('conn.php'); <--- **No Problem**
$query = "SELsECT * FROM `$TBL` WHERE `textFromDate` >= '".mysql_real_escape_string($date1)."' AND `textToDate` <= '".mysql_real_escape_string($date2)."' AND `Scheme`='Paid'";
$resultwholeday = mysqli_query($link, $wholeday) or die(mysql_error()); <--- **might have problem**
?>