我的网站错误日志中出现了很大的错误。喜欢这个
[2014年3月15日12:34:34 America / New_York] PHP警告:mysql_query() 期望参数2是资源,布尔值在 第58行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:34 America / New_York] PHP警告:mysql_close() 期望参数1为资源,布尔值为 第138行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:34 America / New_York] PHP警告: mysql_fetch_array()期望参数1为resource,null为null 第87行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:34 America / New_York] PHP警告:mysql_connect() [function.mysql-connect]:太 许多联系 第34行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:34 America / New_York] PHP警告: mysql_select_db()期望参数2是资源,布尔值在 第42行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:34 America / New_York] PHP警告:mysql_query() 期望参数2是资源,布尔值在 第58行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:34 America / New_York] PHP警告:mysql_close() 期望参数1为资源,布尔值为 第138行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:34 America / New_York] PHP警告: mysql_fetch_array()期望参数1为resource,null为null 第87行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:34 America / New_York] PHP警告:mysql_connect() [function.mysql-connect]:太 许多联系 第34行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:34 America / New_York] PHP警告: mysql_select_db()期望参数2是资源,布尔值在 第42行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:34 America / New_York] PHP警告:mysql_query() 期望参数2是资源,布尔值在 第58行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:34 America / New_York] PHP警告:mysql_close() 期望参数1为资源,布尔值为 第138行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:34 America / New_York] PHP警告: mysql_fetch_array()期望参数1为resource,null为null 第87行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:34 America / New_York] PHP警告:mysql_connect() [function.mysql-connect]:太 许多联系 第34行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:34 America / New_York] PHP警告: mysql_select_db()期望参数2是资源,布尔值在 第42行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:34 America / New_York] PHP警告:mysql_query() 期望参数2是资源,布尔值在 第58行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:34 America / New_York] PHP警告:mysql_close() 期望参数1为资源,布尔值为 第138行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:34 America / New_York] PHP警告: mysql_fetch_array()期望参数1为resource,null为null 第87行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:38 America / New_York] PHP警告:mysql_connect() [function.mysql-connect]:太 许多联系 第34行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:38 America / New_York] PHP警告: mysql_select_db()期望参数2是资源,布尔值在 第42行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:38 America / New_York] PHP警告:mysql_query() 期望参数2是资源,布尔值在 第58行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:38 America / New_York] PHP警告:mysql_close() 期望参数1为资源,布尔值为 第138行/home/ticket4t/public_html/management/include/connect.php [15-Mar-2014 12:34:38 America / New_York] PHP警告: mysql_fetch_array()期望参数1为resource,null为null 第87行/home/ticket4t/public_html/management/include/connect.php
下面给出的是connect.php的代码
`
function dbcore()
{
global $db_org;
$this->getdblinks($db_org);
}
function getdblinks($pm_dbvars)
{
$this->dbhost = $pm_dbvars["dbhost"];
$this->dbuser = $pm_dbvars["dbuser"];
$this->dbpass = $pm_dbvars["dbpass"];
$this->dbname = $pm_dbvars["dbname"];
}
function setdblinks($pm_dblink, $pm_dbhost, $pm_dbuser, $pm_dbpass, $pm_dbname)
{
$this->dbhost = $pm_dbhost;
$this->dbuser = $pm_dbuser;
$this->dbpass = $pm_dbpass;
$this->dbname = $pm_dbname;
}
function siri_open()
{
global $wwwroot;
$t_link = mysql_connect($this->dbhost, $this->dbuser, $this->dbpass);
if(!$t_link)
{
// header("Location: ".$wwwroot."page-error");
$this->Errno = mysql_errno();
//$this->Error = mysql_error();
$this->error("Unable to Connect the Server".$this->dbhost);
}
$bool = mysql_select_db($this->dbname, $t_link);
if(!$bool)
{
// header("Location: ".$wwwroot."page-error");
$this->Errno = mysql_errno();
//$this->Error = mysqli_error();
$this->error("Database Not Found :".$this->dbname);
}
return $t_link;
break;
}
function siri_query($my_qry)
{
$this->link = $this->siri_open();
$qid= mysql_query ($my_qry, $this->link);
$this->siri_close($this->link);
if(!$qid){
$this->Errno = mysql_error();
$this->Error = mysql_error();
$this->error("Problem In Executing the Query:" . $my_qry);
}
return $qid;
}
function siri_count($my_qry)
{
// returns the count value.
$this->link = $this->siri_open();
$qid = mysqli_query ($this->link, $my_qry);
$this->siri_close($this->link);
if(!$qid){
$this->Errno = mysqli_errno();
$this->Error = mysqli_error();
$this->error("Problem In Executing the Query:" . $my_qry);
}
$count = $this->siri_fetch_array($qid);
return $count[0];
}
function siri_fetch_array($qid)
{
return mysql_fetch_array($qid);
}
function siri_fetch_accos($qid)
{
return mysqli_fetch_assoc($qid);
}
function siri_real_escape_string($qid) {
$this->link = $this->siri_open();
return mysqli_real_escape_string($qid);
}
function siri_fetch_row($qid) {
return mysqli_fetch_row($qid);
}
function siri_fetch_object($qid) {
return @mysqli_fetch_object($qid);
}
function siri_num_rows($qid) {
$quy = mysql_num_rows($qid);
return $quy;
}
function siri_affected_rows() {
// for insert, update, delete reasons.
return mysqli_affected_rows();
}
function siri_insert_id() {
return mysqli_insert_id($link);
}
function siri_insert_id1() {
return mysqli_insert_id();
}
function siri_free_result($qid) {
mysqli_free_result($qid);
}
function siri_num_fields($qid) {
return mysqli_num_fields($qid);
}
function siri_close($link)
{
mysql_close($link);
}
function error($msg) {
printf("<b>Error : </b> %s<br>\n", $msg);
printf("<b>MySQL Error</b>: %s (%s)<br>\n", $this->Errno, $this->Error);
}
function siri_fquery($qry,$val)
{
$qid = $this->siri_query($qry);
while($re = $this->siri_fetch_array($qid))
{
print"<option value=$re[0]"; ?> <?= ($val==$re[0])? "selected": "";?> <? print ">$re[1] </option>\n";
}
}
function siri_sinvalue($qry)
{
$qid = $this->siri_query($qry);
$rs = $this->siri_fetch_array($qid);
return $rs[1];
}
function siri_drawNavigation($start,$total,$link)
{
if(($start%100)==0)
{
$j=$start/10+1;
}
else if($start/100>=1){
$j=intval(($start/100))*10+1;
}
else
{
$j=1;
}
if((intval($start/100))>1)
{
$temp=intval(($start/100-1))*10*10;
}
print "<div align=center>";
global $len;
$check=$total%$len;
if($check >=1 ) $lim=intval(($total/$len))+1;
else
$lim=intval($total/$len);
print "<table cellpading=0 cellspacing=0 align=center width=100% nowrap><tr><td width=100%><table width=100% align=center ><tr><td width=100%>";
$en = $start +$len;
// if($start==0 && $total>0){$start1=1;} else {$start1 = $start+1;}
if($start==0){
if($total>0){
$start1=1;
}
else {
$start1=0;
}
}
else {
$start1=$start+1;
}
if($en>$total)
$en = $total;
print "<font face=Verdana, Arial, Helvetica, sans-serif size=0 class='links1'>Showing $start1 - $en of $total <a href='$link&start=0'>Go to First Record</a> </font></td><td><!--<img src='../img/prev_button.gif' align=center>--><font face=Verdana, Arial, Helvetica, sans-serif size=1 class='links1'>" ;
if($en>$len)
{
$en1=$start-$len;
print "<a href='$link&start=$en1' class='links1'>Previous</a>" ;
}
else
print "Previous";
print "</font>";
$temp1=1;
print " <font face=Verdana, Arial, Helvetica, sans-serif size=1 class='links1'>" ;
if($en<$total){
$en2=$start+$len;
print "<a href='$link&start=$en2' class='links1'>Next</a>" ;
}
else
print "Next";
print "</font></td></tr></table></td></tr></table></div>";
}
function shrstr($string, $num="50") {
// Check string length if grater then $num
if (strlen($string) > $num) {
// Shorten the string with ...
$string = substr( $string, 0, $num-2);
$string .= "...";
return $string;
} else {
// If $num is less then
return $string;
}
}
////////////////////////////////
function siri_insert_query($my_qry)
{
$this->link = $this->siri_open();
$qid = mysqli_query ($this->link, $my_qry);
$lid = mysqli_insert_id($this->link);
$this->siri_close($this->link);
if(!$qid){
$this->Errno = mysql_errno();
$this->Error = mysql_error();
$this->error("Problem In Executing the Query:" . $my_qry);
}
return $lid;
}
}// end of the class
?>
`
答案 0 :(得分:0)
将它们作为块读取:
[15-Mar-2014 12:34:38 America / New_York] PHP警告:mysql_connect()[function.mysql-connect]:/home/ticket4t/public_html/management/include/connect.php中的连接太多在第34行
这告诉你,你的mysql服务器已经有太多的连接了,所以你的尝试失败了,
[15-Mar-2014 12:34:38 America / New_York] PHP警告:mysql_select_db()期望参数2是资源,在/home/ticket4t/public_html/management/include/connect.php中给出布尔值42
这告诉您,您忽略了连接失败并尝试使用它的事实;这意味着它失败了,因为没有有效的连接。
[15-Mar-2014 12:34:38 America / New_York] PHP警告:mysql_query()期望参数2是资源,在/home/ticket4t/public_html/management/include/connect.php中给出布尔值58
这也告诉你,你忽略了你的连接失败并尝试使用它的事实;这意味着它失败了,因为没有有效的连接。
[15-Mar-2014 12:34:38 America / New_York] PHP警告:mysql_close()期望参数1是资源,在/home/ticket4t/public_html/management/include/connect.php中给出布尔值138
这告诉您,您忽略了连接失败的事实,并且您尝试关闭不存在的连接。
[2014年3月15日12:34:38 America / New_York] PHP警告:mysql_fetch_array()期望参数1为资源,在/home/ticket4t/public_html/management/include/connect.php中为null提供null 87
这也告诉你,你忽略了你的查询失败的事实,你试图读取结果;这意味着它也失败了,因为没有有效的查询。
简而言之,如果你没有在MySQL服务器上获得那么多的负载,你的代码可能会工作。
您可能想要重新考虑错误处理,提前失败或验证函数的返回结果,如果仅为了您的错误日志的完整性...