我已连接到数据库并且正在尝试检索我在表单中捕获的数据。我知道我错过了一个endwhile语句,但添加它会产生错误。我的代码出了什么问题?
解析错误:语法错误,第29行.php中的意外T_ENDWHILE
<?php
include "connect.php";
error_reporting(E_ERROR);
$Link = mysqli_connect($Host, $User, $Password, $Database);
$Query = "SELECT * FROM {$Table_2}";
if($Result = mysqli_query($Link, $Query)){
while($row = mysqli_fetch_array($Result)){
$tcgname = $row['name'];
$tcgintelligence = $row['intelligence'];
$tcgstrength = $row['strength'];
$tcgspeed = $row['speed'];
$tcgenergy = $row['energy'];
$tcgfighting = $row['fighting'];
$tcggoogle = $row['google'];
$tcgbiography = $row['biography'];
echo $tcgname;
echo $tcgbiography;
echo $tcgintelligence;
echo $tcgstrength;
echo $tcgspeed;
echo $tcgenergy;
echo $tcgfighting;
echo $tcggoogle;
endwhile;
}
}
?>
</body>
</html>
答案 0 :(得分:0)
你不缺少一个结尾,语法是
while() {
}
或
while:
endwhile
什么是$ Table_2?
答案 1 :(得分:0)
您在连接字符串中缺少数据库,它应该是:
$Link = mysqli_connect($Host, $User, $Password, $Database);
无论如何,错误是什么?
while(){}的正确语法是:
while (expression) {
//instructions
}
while endwhile的语法是:
while (expression):
//instructions
endwhile;
选择一种使用语法的方式。