我为生成器创建了一个名为look_api.php的脚本。
但是当我尝试它时,我得到了这个:
Parse error: syntax error, unexpected ';' in C:\xampp\htdocs\look_api.php on line 3
页面:
<?php
error_reporting(1);
$user = str_replace("'", "\\\'", str_replace('"', '\\"', $_GET['user']);
if($username = NULL) { $username = "Yvan" };
$con=mysqli_connect("MYSQL_IP","USER","PASSWORD","DATABASE");
// Mysql Connection
if (mysqli_connect_errno())
{
echo "Ai, check je mysql connection!: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT look FROM users WHERE username = '".$username."'");
while($row = mysqli_fetch_array($result))
{
?>
<?php
}
mysqli_close($con);
?>
</div> </div>
当我删除;在线我得到这个错误:
Parse error: syntax error, unexpected T_IF in C:\xampp\htdocs\look_api.php on line 4
脚本中的代码就在那一刻:
<?php
error_reporting(1);
$user = str_replace("'", "\\\'", str_replace('"', '\\"', $_GET['user'])
if($username = NULL) { $username = "Yvan" };
$con=mysqli_connect("MYSQL_IP","USER","PASSWORD","DATABASE");
// Mysql Connection
if (mysqli_connect_errno())
{
echo "Ai, check je mysql connection!: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT look FROM users WHERE username = '".$username."'");
while($row = mysqli_fetch_array($result))
{
?>
<?php
}
mysqli_close($con);
?>
</div> </div>
那么......我该如何解决?
答案 0 :(得分:3)
你错过了)
:
$user = str_replace("'", "\\\'", str_replace('"', '\\"', $_GET['user']);
应该是:
$user = str_replace("'", "\\\'", str_replace('"', '\\"', $_GET['user']));
你也有错误:
if($username = NULL) { $username = "Yvan" };
应该是:
if($username == NULL) { $username = "Yvan"; };
答案 1 :(得分:0)
第3行和第4行出错
你遗失的第3行)
第4行分号应在if
语句
替换它..
$user = str_replace("'", "\\\'", str_replace('"', '\\"', $_GET['user']));
if($username == NULL) { $username = "Yvan"; }
答案 2 :(得分:-2)
替换
if($username = NULL) { $username = "Yvan" };
使用:
if($username = NULL) { $username = "Yvan"; }