-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");}}}}


?>

( ! ) 解析エラー: C:\wamp\www\mybbeklents\rapor\gonder.php の 11 行目に構文エラー、予期しない '}' があります

  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");}}}}

ところで。使用しない場合は、netbeans や phpdesigner などの IDE の使用を開始する必要があります。エラーの場所が表示されます。

新しいコード:

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");


}}}}

この新しいコードを試してみてください。変更点はほとんどありません。

まず、db に送信される前にクエリを作成することです。そのため、クエリが機能しない場合は、phpmyadmin で直接試して、正しいかどうかを確認できます。2つ目は、このコードはクエリが完了したかどうかをチェックし、そうでない場合はエラーメッセージをスローしてプログラムを終了することです

あなたへの警告: Mysql_* 関数の使用をやめてください。それらは非推奨です。Mysqli または PDO の使用を開始すると、はるかに安全です

于 2013-09-15T06:53:13.410 に答える
0

セミコロンが欠落しており、不要な場所で if 条件を閉じています (「else」の後に「else if」の間に「}」を入れています)。そして、最後の行に不必要に 4 つの '}' があります。次のコードを確認してください。

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 に答える
0

terminator(Semicolon)--> ; at 行がありません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

3 行の後にセミコロン (;) がありません

{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 に答える