-6
    <?php
$con = mysql_connect("localhost","root","")or die (mysql_error());
$db  = mysql_select_db("mybbeklenti",$con)or die(mysql_error());

$ad = mysql_real_escape_string($_POST["ad"]);
$email = mysql_real_escape_string($_POST["email"]);
$mesaj = $_POST["mesaj"];
$kiriklink = $_POST["kiriklink"];

if($ad==""){header("location:index.php?kls=1");}else
{if($email==""){header("location:index.php?kls=2")}else
{if($mesaj==""){header("location:index.php?kls=3")}else
{if($kiriklink==""){header("location:index.php?kls=4")}else
{mysql_query("INSERT INTO bildirim (`ad`,`email`,`acklama`,`kiriklink`,`tarih`) VALUES ('$ad','$email','$mesaj','$kiriklink',now())");header("location:index.php?kls=5");}}}}


?>

( ! ) 解析错误:语法错误,第 11 行 C:\wamp\www\mybbeklents\rapor\gonder.php 中的意外 '}'

  1. 行是 {if($email=="" 行请帮忙!
4

5 回答 5

1

您缺少分号:

if($ad==""){header("location:index.php?kls=1");}else
{if($email==""){header("location:index.php?kls=2");}else
{if($mesaj==""){header("location:index.php?kls=3");}else
{if($kiriklink==""){header("location:index.php?kls=4");}else
{mysql_query("INSERT INTO bildirim (`ad`,`email`,`acklama`,`kiriklink`,`tarih`) VALUES ('$ad','$email','$mesaj','$kiriklink',now())");header("location:index.php?kls=5");}}}}

顺便提一句。如果你不使用,那么你应该开始使用一些 IDE,比如 netbeans 或 phpdesigner,它会告诉你错误在哪里

新代码:

if($ad==""){header("location:index.php?kls=1");}else
{if($email==""){header("location:index.php?kls=2");}else
{if($mesaj==""){header("location:index.php?kls=3");}else
{if($kiriklink==""){header("location:index.php?kls=4");}else

{
    $query = "INSERT INTO bildirim (`ad`,`email`,`acklama`,`kiriklink`,`tarih`) 
    VALUES ('$ad','$email','$mesaj','$kiriklink',now())";

    $result = mysql_query($query);
    if (!$result) {
        $message  = 'Invalid query: ' . mysql_error() . "\n";
        $message .= 'Whole query: ' . $query;
        die($message);
    }   
    header("location:index.php?kls=5");


}}}}

试试这个新代码,变化很少。

首先是您在发送到数据库之前创建查询,因此如果查询不起作用,您可以直接在 phpmyadmin 中尝试并确定它是否正确。其次是这段代码检查查询是否完成,如果没有,它会抛出错误消息并终止程序

并警告您:停止使用 Mysql_* 函数。它们已被弃用。开始使用 Mysqli 或 PDO,它们更安全

于 2013-09-15T06:53:13.410 回答
0

您缺少terminator(Semicolon)-->;11,12,13

{if($email==""){header("location:index.php?kls=2");}else
                                                  ^Here

等等

于 2013-09-15T06:55:12.277 回答
0

您省略了这一行的分号:

{if($email==""){header("location:index.php?kls=2");}else
                                                  ^

在接下来的几行中也是如此。

于 2013-09-15T06:55:17.930 回答
0

您在三行之后缺少分号 (;)

{if($email==""){header("location:index.php?kls=2");}else
                                                  ^ missing semicolon here
{if($mesaj==""){header("location:index.php?kls=3");}else
                                                  ^ missing semicolon here
{if($kiriklink==""){header("location:index.php?kls=4");}else
                                                      ^ missing semicolon here
于 2013-09-15T06:57:05.103 回答
0

您缺少分号,并且在不必要的地方关闭了 if 条件(您在每个 'else if' 之间的 'else' 之后放置了 '}')。最后一行不必要地有四个'}'。检查以下代码。

if($ad==""){
   header("location:index.php?kls=1");
}else if($email==""){
   header("location:index.php?kls=2"); 
}else if($mesaj==""){
   header("location:index.php?kls=3");
}else if($kiriklink==""){
   header("location:index.php?kls=4");
}else{
   mysql_query("INSERT INTO bildirim (`ad`,`email`,`acklama`,`kiriklink`,`tarih`) VALUES ('$ad','$email','$mesaj','$kiriklink',now())");
   header("location:index.php?kls=5");
}
于 2013-09-15T07:07:06.217 回答