Php if语句中的多个命令引发错误
我在一些PHP代码中遇到了问题,在if语句后面有多个命令。我用分号终止了每个命令,但是php抛出以下错误:Php if语句中的多个命令引发错误,php,if-statement,printing,Php,If Statement,Printing,我在一些PHP代码中遇到了问题,在if语句后面有多个命令。我用分号终止了每个命令,但是php抛出以下错误: PHP Parse error: syntax error, unexpected T_VARIABLE in /test/process.php on line 18 引用此代码段的第4行: if (mysql_num_rows($duperaw) > 0) { print '<script type="text/javascript">'; print 'aler
PHP Parse error: syntax error, unexpected T_VARIABLE in /test/process.php on line 18
引用此代码段的第4行:
if (mysql_num_rows($duperaw) > 0)
{
print '<script type="text/javascript">';
print 'alert("'$img_id' is already in '$type'")';
print '</script>';
header("location: process.php?img_id=$img_id");
}
else
{
mysql_query("INSERT INTO $type (data) VALUES('$data')");
print '<script type="text/javascript">';
print 'alert("'$img_id' successfully added to '$type'")';
print '</script>';
}
if(mysql\u num\u行($duperaw)>0)
{
打印“”;
打印“警报”(“$img\U id”已在“$type”中);
打印“”;
标题(“location:process.php?img_id=$img_id”);
}
其他的
{
mysql_查询(“插入$type(数据)值(“$data”)”);
打印“”;
打印“警报”(“$img_id”已成功添加到“$type”中);
打印“”;
}
代码在每个{}中只有一行,但我认为{}的功能是允许在每个if语句中运行多个命令。我可能只是忽略了一些非常简单的东西,因为我对php还是相当陌生的。非常感谢您的帮助。您错过了连接字符串的句号: 所以 变成
print 'alert("'.$img_id.' is already in '.$type.'")';
我知道我错过了一些简单的事情。非常感谢你!我想我需要降低显示器的分辨率:/
print 'alert("'.$img_id.' is already in '.$type.'")';