배열 MYSQL_ASSOC 내에서 SQL SELECT가 작동하지 않습니다.
문제
아래 스크립트에서 오류를 찾을 수 없는 것 같습니다.지금 한동안 확인하고 있었어요.죄송합니다. 저는 SQL과 PHP를 처음 접했습니다.
$tCompany_SQLselect = "SELECT ";
$tCompany_SQLselect .= "ID, preNAME, Name, RegType ";
$tCompany_SQLselect .= "FROM ";
$tCompany_SQLselect .= "tCompany ";
$tCompany_SQLselect_Query = mysql_query($tCompany_SQLselect);
$index = 1;
while ($row = mysql_fetch_array($tCompany_SQLselect_Query, MYSQL_ASSOC)) {
$preNAME = $row['preNAME'];
$Name = $row['Name'];
$RegType = $row['RegType'];
echo $index.".".$preNAME."".$Name."".$RegType" <br />;
$index++;
}
해결책
문제 방법 연결 이 변수입니다.
당신이 잊고 점하고 있습니다.변경 .$RegType" <br />;
하기 . $RegType . "<br />";
echo $index . "." . $preNAME . " " . $Name . " " . $RegType "<br /> ;
^ dot ^ quote
그것을 변경하기:
echo $index . "." . $preNAME . " " . $Name . " " . $RegType . "<br />";
를 제거할 수 있는 공간에서 " "
당신이 원하는 경우.
다른 팁
첫째 :
를 사용할 수 있습니다 :$tCompany_SQLselect_Query = mysql_query($tCompany_SQLselect) or die(mysql_error());
.
이렇게하면 오류를 디버깅 할 수 있습니다.
두 번째 : 사용할 수 있습니다 :
$row = mysql_fetch_assoc($tCompany_SQLselect_Query)
.
구문을 단축합니다.
그만큼 echo
라인은 다음과 같아야 합니다:
echo $index.".".$preNAME." ".$Name." ".$RegType." . "<br />";
주변에 인용문이 누락되었습니다. <br />
, 그리고 .
그 전에 연결을 위해.
제휴하지 않습니다 StackOverflow