2012-04-18 72 views
-1

您好,我試圖做一些隨機數並做一個簡單的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']."'") 

    } 
?> 

我將它上傳到我的服務器並獲得一個白頁。我從來沒有遇到過這是爲...它說最後}是問題.....

+1

您錯過了兩個mysql_query ...語句末尾的分號。 – Prabhuram 2012-04-18 10:56:25

回答

3

缺少;後的mysql_query似乎是問題。在mysql_query()語句結束

+0

注意。通常在php中的錯誤消息並不直接與它指向你的東西有關。那就是錯誤被抓住了。它往往更容易看看以前的行或以前的聲明.... :)只是一個提示 – encodes 2012-04-19 12:00:39

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']."'"); 
+0

感謝不能相信我忘了 – user1121083 2012-04-18 10:57:13

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

+0

感謝不能相信我忘了 – user1121083 2012-04-18 10:56:52

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']."'"); 
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']."'") 
1

請注意。寫「;」在每個php命令之後。