如果语句显示关闭括号的错误

时间:2012-04-18 10:54:02

标签: php syntax-error

你好我试着制作一些随机数并做一个简单的mysql更新但由于某些原因Dreamweaver在结束括号上显示错误。

<?php


if (isset($_POST['battle_move'])) {

$battle_move= mysql_real_escape_string($_POST['battle_move']);
$battle_move22 = strip_tags($battle_move);
$random_number = rand(1, 50); 
$a = $random_number ;
$b = 5;
$random_number1 = ($a * $b) ;


$random_number2 = rand(1, 50); 
$c = $random_number2 ;
$d = 5;
$random_number22 = ($c * $d) ;

mysql_query("UPDATE maplog SET wildpokemonhp=wildpokemonhp+".$random_number1." WHERE username = '".$_SESSION['username']."'")
mysql_query("UPDATE maplog SET userpokemonhp=userpokemonhp+".$random_number22." WHERE username = '".$_SESSION['username']."'")

    }
?>

我将它上传到我的服务器并获得一个白页。我从来没有遇到过这样的事情......它说的最后一个}就是问题......

6 个答案:

答案 0 :(得分:4)

mysql_query("UPDATE maplog SET wildpokemonhp=wildpokemonhp+".$random_number1." WHERE username = '".$_SESSION['username']."'")
mysql_query("UPDATE maplog SET userpokemonhp=userpokemonhp+".$random_number22." WHERE username = '".$_SESSION['username']."'")

每个mysql_query

后需要;

答案 1 :(得分:3)

;上遗漏mysql_query似乎是个问题。

答案 2 :(得分:2)

你离开了;在查询更新中。请纠正它们。

mysql_query("UPDATE maplog SET wildpokemonhp=wildpokemonhp+".$random_number1." WHERE username = '".$_SESSION['username']."'");
mysql_query("UPDATE maplog SET userpokemonhp=userpokemonhp+".$random_number22." WHERE username = '".$_SESSION['username']."'");

答案 3 :(得分:2)

;语句末尾尝试终结符(mysql_query()):

mysql_query("UPDATE maplog SET wildpokemonhp=wildpokemonhp+".$random_number1." WHERE username = '".$_SESSION['username']."'");
mysql_query("UPDATE maplog SET userpokemonhp=userpokemonhp+".$random_number22." WHERE username = '".$_SESSION['username']."'");

答案 4 :(得分:1)

失踪;于:

mysql_query("UPDATE maplog SET wildpokemonhp=wildpokemonhp+".$random_number1." WHERE username = '".$_SESSION['username']."'")

mysql_query("UPDATE maplog SET userpokemonhp=userpokemonhp+".$random_number22." WHERE username = '".$_SESSION['username']."'")

答案 5 :(得分:1)

PLS。写“;”在每个php命令之后。