0

Hello i've got a problem with "else" it says unexpected T_ELSE but i have no idea what could be wrong here

if ($id == "funkcijos")
{
    if($vardas != "" && $slaptazodis != "" && $el_pastas != "")
    {

        $query = "INSERT INTO vartotojai SET vardas = '$vardas', slaptazodis = '$slaptazodis', el_pastas = '$el_pastas', avataras = '$avataras', parasas = '$parasas'";
        mysql_query($query);

        
        print "Welcome to the Naruto-Clash. <a href='registracija_ir_login.php'>Log In.</a>";
    }
    else
    {
    print "Empty fields.";
    }
               //[B]Here[/B]
		else
		{
		if ($_POST['Naruto'] == "ON")
		{
		
		$query = "INSERT INTO vartotojai SET character = 'Naruto'";
        mysql_query($query);
				}
		}
2
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by DeadlyLife
0

You need another '}' before the second 'else'.

<?php
if ($id == "funkcijos"){
    if($vardas != "" && $slaptazodis != "" && $el_pastas != ""){
        $query = "INSERT INTO vartotojai SET vardas = '$vardas', slaptazodis = '$slaptazodis', el_pastas = '$el_pastas', avataras = '$avataras', parasas = '$parasas'";
        mysql_query($query);
        print "Welcome to the Naruto-Clash. <a href='registracija_ir_login.php'>Log In.</a>";
    }else{
	print "Empty fields.";
    }
               //Here
}else{
	if ($_POST['Naruto'] == "ON"){
		$query = "INSERT INTO vartotojai SET character = 'Naruto'";
                mysql_query($query);
	}
}
?>

Sorry for reformatting your code, but braces on their own lines really confuse the hell out of me - especially if the indentation has gone to pot.

0

Thanks for that but there's another problem

if ($_POST['Naruto'] == "ON"){
		$query = "INSERT INTO vartotojai SET character = 'Naruto'";
                mysql_query($query);

it supposed to insert "Naruto" into database when a checkbox is checked but nothing is happening?

0

ok last problem :O the query in the end doesnt work i tried everything (1st one works)

<?php
if ($id == "funkcijos"){
    if($vardas != "" && $slaptazodis != "" && $el_pastas != ""){
        $query = "INSERT INTO vartotojai SET vardas = '$vardas', slaptazodis = '$slaptazodis', el_pastas = '$el_pastas', avataras = '$avataras', parasas = '$parasas'";
        mysql_query($query);
        print "Welcome to the Naruto-Clash. <a href='registracija_ir_login.php'>Log In.</a>";
    }else{
	print "Empty fields.";
    }
               //Here
}else{
	if(isset($_POST['Naruto'])){
//[B]HERE[/B]
		$query = "INSERT INTO vartotojai SET character = 'Naruto'";
                mysql_query($query);
	}
}
?>
0

Perhaps you need to place the fieldname "character" in backticks as I suggested. I think "character" is a reserved word in SQL - I may be wrong.
So:

`character`

0

should i post you the whole code it might be some mistakes somewhere else?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.