Page 1 of 1

still getting an error

Posted: Mon Aug 29, 2005 8:56 pm
by bruceg
I am getting a parsing error on line 7 of the following code. can anyone help me out with what might be the cause?

Code: Select all

<?php
//start a session
session_start();
//check if user is coming from a form
if ($_POST['op'] == "ds") {
if ($_POST['username'] !="admin" || $_POST['password'] !="abc123") { 
$msg ="'<p><strong><span class='red'>Bad Login - Try Again</span></strong></p>"';
$show_form = "yes";
} else {
$_SESSION['valid'] = "yes";
$show_menu="yes";
} else {
if ($_SESSION['valid'] =="yes") {
     $show_menu ="yes";
} else {
    $show_form ="yes";
}

Posted: Mon Aug 29, 2005 9:19 pm
by feyd
your quotes are misplaced. Look at the highlighted text.

Posted: Mon Aug 29, 2005 9:20 pm
by John Cartwright

Code: Select all

$msg ="'<p><strong><span class='red'>Bad Login - Try Again</span></strong></p>"';
should be

Code: Select all

$msg ="'<p><strong><span class='red'>Bad Login - Try Again</span></strong></p>'";

Posted: Mon Aug 29, 2005 9:28 pm
by bruceg
thanks,

now I am getting an error on line 4

Code: Select all

<?php
//start a session
session_start();
//check if user is coming from a form
if ($_POST['op'] == "ds") {
if ($_POST['username'] !="admin" || $_POST['password'] !="abc123") { 
$msg ="'<p><strong><span class='red'>Bad Login - Try Again</span></strong></p>'";
$show_form = "yes";
} else {
$_SESSION['valid'] = "yes";
$show_menu="yes";
} else {
if ($_SESSION['valid'] =="yes") {
     $show_menu ="yes";
} else {
    $show_form ="yes";
}
does comment lines get ignored when php errors occur? so line four is actually

if ($_POST['username'] !="admin" || $_POST['password'] !="abc123") {

??

Posted: Mon Aug 29, 2005 10:54 pm
by feyd
what's the error?

Posted: Mon Aug 29, 2005 11:14 pm
by bruceg
Parse error: parse error, unexpected T_ELSE in /hsphere/local/home/bruceg/inspired-evolution.com/Contact_Menu.php on line 4

Posted: Mon Aug 29, 2005 11:38 pm
by feyd
you have nesting issues with your if..else sets. Only 1 else can exist for any given if.