By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,426 Members | 3,152 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,426 IT Pros & Developers. It's quick & easy.

Parse error: syntax error, unexpected T_ELSE(please help)

P: 2
Hi im new in php and i got a problem(T_ELSE) with this code please help!

"Parse error: syntax error, unexpected T_ELSE in C:\xampp\htdocs\update.php on line 15"

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     include 'db_connect.php';
  3.  
  4. $name = $_POST['Fname'];
  5. $surname = $_POST['Sname'];
  6. $pass = $_POST['Pname'];
  7. $user = $_POST['Uname'];
  8.  
  9. if (!$_post['submit']);    
  10.   {
  11.     echo "echo please fill out the form";
  12.     header('location: hello.php');
  13.    }
  14.  
  15.    else 
  16.    {
  17.    $sql_insert = "INSERT INTO membersinfo ('name', 'surname', 'pass', 'user') 
  18.     values ('Fname', 'Sname',  'Pname',  'Uname')};
  19.    echo "user has been created!";
  20.    header('location: hello.php');
  21.  
  22.    ?>
Feb 13 '12 #1
Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,366
You didn't close your else statement.
Feb 13 '12 #2

P: 2
Thank you Rabbit... now i closed the else statement with "}" but still I got the same "Parse error: syntax error, unexpected T_ELSE".

<?php
include 'db_connect.php';

$name = $_POST['Fname'];
$surname = $_POST['Sname'];
$pass = $_POST['Pname'];
$user = $_POST['Uname'];


if (!$_post['submit']);
{
echo "echo please fill out the form";
header('location: hello.php');
}

else
{
$sql_insert = "INSERT INTO membersinfo ('name', 'surname', 'pass', 'user')
values ('Fname', 'Sname', 'Pname', 'Uname')";
echo "user has been created!";
header('location: hello.php');
}
?>
Feb 13 '12 #3

Rabbit
Expert Mod 10K+
P: 12,366
You shouldn't have a semicolon after your if statement.
Feb 13 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.