저는 이것을 알아 내려고 노력해 왔고 Stackoverflow와 다른 사이트를 찾아서 내 문제와 관련이 있습니다.PHP와 MySQL은 완벽하게 작동하지만 경고를 얻고 있습니다
사람들이 각각의 페이지를 열 때 mysql 테이블을 업데이트하는 PHP 스크립트가 있습니다. 모든 것은 잘 작동합니다 (데이터가 존재하는지 확인하기 위해 각 단계마다 텍스트를 인쇄하도록하고 있습니다. 업데이트는 페이지를 방문하지 않았거나 업데이트하지 않은 경우 URL과 다른 데이터를 테이블에 저장합니다. 방문당 total_votes 및 current_vote. total_votes는 다른 페이지에서 사용되는 통계보고 용이며, current_vote는 매주 값이 감소합니다.
몇 가지 이유로 경고가 표시됩니다. 모든 것이 싫어서 해결할 수없는 경고 및 오류 (최종 결과에 문제가없는 경우에도 마찬가지 임)
데이터베이스가 utf8_general_ci로 설정되어 있으므로 URL 정보가 문제가되지 않아야합니다. .
여기내가 (경고가 동안 ($ 행 = mysqli_fetch_array ($ 쿼리)) {
<?php
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
$cururl = curPageURL();
echo $cururl;
require_once "scripts/connect.php";
$sqlCommand = "SELECT Count(*) as `Counter` FROM `hot_topics` WHERE `article_url` = '". $cururl ."'";
$query = mysqli_query($myconnection,$sqlCommand) or die (mysqli_error());
while ($row = mysqli_fetch_array($query)){
$Count = $row["Counter"];
echo $Count;
if ($Count == 1) {
echo '1';
require_once "scripts/connect.php";
$sqlCommand = "UPDATE `hot_topics` SET `total_votes` = `total_votes`+1, `current_vote` = `current_vote`+1 WHERE `article_url` = '". $cururl ."'";
$query = mysqli_query($myconnection,$sqlCommand) or die (mysqli_error());
} elseif ($Count == '0') {
echo '2';
$yearHead=$_GET["yearrange"];
$weekHead=$_GET["weekrange"];
if ($weekHead == 'Current') {
$type=$_GET["type"];
$yearHead = date("Y");
$weekHead = date("W");
$Startdate = new DateTime();
$Startdate->setISODate($yearHead, $weekHead);
$Enddate = new DateTime();
$Enddate->setISODate($yearHead, $weekHead, 7);
require_once "scripts/connect.php";
$sqlCommand = "INSERT INTO `hot_topics` (`total_votes`, `current_vote`, `article_url`, `article_title`) VALUES ('1', '1', '". $cururl ."', '". $type ." Chart: ". $Startdate->format('d/F/Y') ." - ". $Enddate->format('d/F/Y') ."')";
$query = mysqli_query($myconnection,$sqlCommand) or die (mysqli_error());
} elseif ($weekHead == 'All') {
$type=$_GET["type"];
require_once "scripts/connect.php";
$sqlCommand = "INSERT INTO `hot_topics` (`total_votes`, `current_vote`, `article_url`, `article_title`) VALUES ('1', '1', '". $cururl ."', '". $type ." Chart: All Weeks')";
$query = mysqli_query($myconnection,$sqlCommand) or die (mysqli_error());
} else {
$type=$_GET["type"];
$yearHead=$_GET["yearrange"];
$weekHead=$_GET["weekrange"];
echo $yearHead;
echo $weekHead;
$Startdate = new DateTime();
$Startdate->setISODate($yearHead, $weekHead);
$Enddate = new DateTime();
$Enddate->setISODate($yearHead, $weekHead, 7);
require_once "scripts/connect.php";
$sqlCommand = "INSERT INTO `hot_topics` (`total_votes`, `current_vote`, `article_url`, `article_title`) VALUES ('1', '1', '". $cururl ."', '". $type ." Chart: ". $Startdate->format('d/F/Y') ." - ". $Enddate->format('d/F/Y') ."')";
$query = mysqli_query($myconnection,$sqlCommand) or die (mysqli_error());
}
}
}
?>
에 내가 받고있다 경고는이 섹션이 코드의 체크입니다 : 경고 : mysqli_fetch_array는()는 통지를하지 않은 경우
경고 메시지가 무엇입니까? –
경고 메시지의 출처는 어디입니까? IDE, Apache 로그, MySQL 로그? –
경고 : "경고 : mysqli_fetch_array()는 매개 변수 1이 mysqli_result로 간주하고"다음과 같이 경로와 줄을 입력하십시오. 인터넷 브라우저에 표시되었습니다. 필자는 보통 두 대의 PC에서 Chrome, Firefox 및 Internet Explorer의 모든 것을 테스트합니다. 따라서 경고는 일관성이 있습니다. 그러나 나는 그 이유를 모릅니다. 이 프로세스는 3 가지 브라우저 모두에서 작동합니다. –