我的代码中出现此错误。
Parse error : syntax error, unexpected $end in /../messenger.php on line 304
我已经检查了我的剧本几次,我没有找到任何遗漏的分号或括号。如果有人可以提供帮助,请给我你的建议。
这是我的剧本
<?php
mysql_connect ("localhost","root","");
mysql_select_db ("aplydroidmessenger");
extract ($_REQUEST, EXTR_OVERWRITE);
if ($c=="r"){
$reg = " ";
$h = ereg_replace ("~", $reg, $h);
$n = ereg_replace ("~", $reg, $n);
if ($s == "user") {
$sql = "SELECT * FROMhe tbl_user where nick = '$k'";
$result = mysql_query ($sql);
$total = mysql_num_rows ($result);
if ($total == 0) {
$sql = "INSERT INTO tbl_user
(name,email,password,nick,status,cdate)";
$sql .= "VALUES ('$n','$e','$p','$k','offline',NOW())";
$result = mysql_query($sql) or die("gagal");
$status = 1;
$msgReg = "============================\n";
$msgReg .= " SELAMAT\n";
$msgReg .= "===========================\n";
$msgReg .= "Kamu Telah Terdaftar\n";
$msgReg .= "Nick anda adalah : $k \n";
echo $msgReg;
}
else {
echo "Nick anda telah terdaftar";
}
}
else if ($s == "room"){
$sql = "SELECT * FROM tbl_user where nick = '$k'";
$result = mysql_query($sql);
$total = mysql_num_rows($result);
if ($total == 0){
$sql = "INSERT INTO tbl_user
(name,email,password,nick,status,cdate)";
$sql .= "VALUES ('$n','$e','$p','$k','room',NOW())";
$result = mysql_query($sql) or die ("gagal");
$status = 1;
$msgReg = "SUKSES";
echo $msgReg;
}
else {
echo "Room is exist";
}
}
}
if ($c=="s"){
$sql = "SELECT * FROM tbl_user";
$sql .= "WHERE nick = '$k' AND password = '$p'";
$result = mysql_query($sql) or die ("3");
$row = mysql_num_rows($result);
if ($row > 0){
$sql = "UPDATE tbl_user set status = 'online'";
$sql .= "WHERE nick = '$k'";
$result = mysql_query($sql) or die ("2");
if ($result) {
echo "1";
}
}
else {
echo "2";
}
}
if ($c=="f"){
if ($z=="on"){
$sql = "SELECT * FROM tbl_user";
$sql .= "WHERE status='online' AND nick != '$k'";
$result = mysql_query($sql) or die ("gagal");
$spce = "_";
$con = "1";
$row = mysql_num_rows($result);
if (!$row == 0){
while ($data = mysql_fetch_array($result)){
$nama .= $data["nick"].$spce;
}
echo "$con$nama";
}
else {
echo "1";
}
}
else if ($z=="off"){
$sql = "SELECT * FROM tbl_user";
$sql .= "WHERE status='offline' AND nick != '$k'";
$result = mysql_query($sql) or die ("gagal");
$spce = "_";
$con = "0";
$row=mysql_num_rows($result);
if (!$row == 0){
while ($data = mysql_fetch_array($result)){
$nama .= $data["nick"].$spce;
}
echo "$con$nama";
}
else {
echo "0";
}
}
if ($c=="a"){
$spce = "_";
$con = "1";
$sqla = "SELECT * FROM tbl_user";
$sqla .= "WHERE nick = '$k'";
$reslt = mysql_query($sqla);
if (mysql_num_rows($reslt) > 0){
while ($data = mysql_fetch_array($reslt)){
$userid = (int) $data ["id"];
}
}
$sqlb = "SELECT * FROM tbl_room_user";
$sqlb .= "WHERE id_user = '$userid'";
$hasil = mysql_query($sqlb);
if (mysql_num_rows($hasil) > 0){
$i=1;
while ($data = mysql_fetch_array($hasil)){
$roomid[$i] = (int) $data ["id_room"];
$i++;
}
}
for ($i=1;$i <=count($roomid);$i++){
$sql_rm = "SELECT * FROM tbl_room";
$sql_rm .= "WHERE id = '$roomid[$i]'";
$resultq = mysql_query($sql_rm) or die ("gagal");
$row=mysql_num_rows($resultq);
if (!$row == 0){
while ($data = mysql_fetch_array($resultq)){
$nama .= $data["nama"].$spce;
}
}
}
echo "$con$nama";
}
if ($c=="o"){
$sql = "UPDATE tbl_user set status = 'offline'";
$sql .= "WHERE nick = '$k'";
$result = mysql_query($sql) or die ("2");
}
if ($c=="k"){
$spasi = " ";
$null = "";
$m = ereg_replace("~", $spasi, $m);
$t = ereg_replace("~", $null, $t);
if ($m != ""){
$sql .= "INSERT INTO tbl_msg(dari,ke,msg,status)";
$sql .= "VALUES ('$n','$t','$m','0')";
$result = mysql_query($sql);
}
}
if ($c=="p"){
$pisah = "_";
$batas = " : ";
if ($r == "person"){
$sql_tm = "SELECT * FROM tbl_msg";
$sql_tm .= "WHERE dari='$a'";
$sql_tm .= "AND ke='$n' AND status = '0'";
$result = mysql_query($sql_tm);
if (mysql_num_rows($result) > 0){
while ($data = mysql_fetch_array($result)){
$msg = $data["msg"];
$dari = $data["dari"];
echo "$dari$batas$msg$pisah";
}
}
$sql_rd = "UPDATE tbl_msg set status = 1";
$sql_rd .= "WHERE dari = '$a' AND ke = '$n'";
$result_rd = mysql_query($sql_rd);
}
else if ($r == "room"){
$sql_rm = "SELECT * FROM tbl_room";
$sql_rm .= "WHERE nama='$a'";
$result = mysql_query($sql_rm);
if (mysql_num_rows($result) > 0){
while ($data = mysql_fetch_array($result)){
$idroom = $data["id"];
}
}
$sql_rm = "SELECT * FROM tbl_room_user";
$sql_rm .= "WHERE id_room='$idroom'";
$result = mysql_query($sql_rm);
if (mysql_num_rows($result) > 0){
$i=1;
while ($data = mysql_fetch_array($result)){
$from[$i] = $data["id_user"];
$i++;
}
}
for ($i=1;$i <=count($from);$i++){
$sql_rm = "SELECT * FROM tbl_user";
$sql_rm .= "WHERE id='$from[$i]'";
$result = mysql_query($sql_rm);
if (mysql_num_rows($result) > 0){
while ($data = mysql_fetch_array($result)){
$name[$i] = $data["nick"];
}
}
}
for ($i=1;$i<=count($name);$i++){
$sql_tm = "SELECT * FROM tbl_msg";
$sql_tm .= "WHERE dari='$name[$i]'";
$sql_tm .= "AND ke= '$n' AND status = '0'";
$result = mysql_query($sql_tm);
if (mysql_num_rows($result) > 0){
while ($data = mysql_fetch_array($result)){
$msg = $data["msg"];
$dari = $data["dari"];
echo "$dari$batas$msg$pisah";
}
}
$sql_rd = "UPDATE tbl_msg set status = 1";
$sql_rd .= "WHERE dari = '$name[$i]' AND ke ='$n'";
$result_rd = mysql_query($sql_rd);
}
} }
?>
答案 0 :(得分:0)
lain kali codingnya lebih rapi biar kalau ada error kayak gini gak kesusahan nih masalahnya ada disini:
下次将其设为更具代码性的代码,这样如果出现这样的错误,您就不难找到错误(谷歌翻译)
else if ($c=="f"){
if ($z=="on"){
$sql = "SELECT * FROM tbl_user";
$sql .= "WHERE status='online' AND nick != '$k'";
$result = mysql_query($sql) or die ("gagal");
$spce = "_";
$con = "1";
$row = mysql_num_rows($result);
if (!$row == 0){
while ($data = mysql_fetch_array($result)){
$nama .= $data["nick"].$spce;
}
echo "$con$nama";
}
else {
echo "1";
}
}
}&lt; - kurang 1
}&lt; - 小于1(谷歌翻译)