我似乎无法在下面的脚本中找到错误。我一直在检查。对不起,我是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++;
}
答案 0 :(得分:0)
echo
行应为:
echo $index.".".$preNAME." ".$Name." ".$RegType." . "<br />";
<br />
周围缺少引号,而.
之前的引号错过了。
答案 1 :(得分:0)
首先:您可以使用:
$tCompany_SQLselect_Query = mysql_query($tCompany_SQLselect) or die(mysql_error());
这将允许您调试错误。
第二:你可以使用:
$row = mysql_fetch_assoc($tCompany_SQLselect_Query)
缩短语法。
答案 2 :(得分:0)
问题在于你concatenated变量的方式。
你忘记了一个点和一个引用。将.$RegType" <br />;
更改为. $RegType . "<br />";
echo $index . "." . $preNAME . " " . $Name . " " . $RegType "<br /> ;
^ dot ^ quote
将其更改为:
echo $index . "." . $preNAME . " " . $Name . " " . $RegType . "<br />";
如果需要,您可以删除" "
中的空格。