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


?>

( ! ) Parse error: syntax error, unexpected '}' in C:\wamp\www\mybbeklents\rapor\gonder.php on line 11

  1. Line is {if($email=="" line please help!

5 Answers5

1

You are missing semicolons:

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

Btw. if you don't use, then you should start using some IDE like netbeans or phpdesigner, it will show you where error is

NEW CODE:

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


}}}}

Try this new code, there are few changes.

First is that you create query before is is sended to db, so if query don't work you can try it in phpmyadmin directly and find out if it is correct. Second is that this code check if query was acomplished, if not it throw you error message and terminate program

and WARNING for you: stop using Mysql_* functions. They are deprecated. Start using Mysqli or PDO, they are much safer

M.Svrcek
  • 5,485
  • 4
  • 25
  • 33
0

You are missing the terminator(Semicolon) --> ; at line 11,12,13

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

and SO on

Moeed Farooqui
  • 3,604
  • 1
  • 18
  • 23
0

You have omitted the semi-colon on this line:

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

and similarly on the next couple of lines.

0

You are missing semicolon (;) following three lines

{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
MD SHAHIDUL ISLAM
  • 14,325
  • 6
  • 82
  • 89
0

You are missing semicolons and have closed (you have put '}' after 'else' between every 'else if') the if condition in unnecessary place. And there are four '}' in last line unnecessarily. Check following code.

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");
}
nirosha rathnayaka
  • 188
  • 2
  • 6
  • 18