still getting an error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bruceg
Forum Contributor
Posts: 174
Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:

still getting an error

Post 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";
}
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

your quotes are misplaced. Look at the highlighted text.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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>'";
bruceg
Forum Contributor
Posts: 174
Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:

Post 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") {

??
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

what's the error?
bruceg
Forum Contributor
Posts: 174
Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:

Post by bruceg »

Parse error: parse error, unexpected T_ELSE in /hsphere/local/home/bruceg/inspired-evolution.com/Contact_Menu.php on line 4
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you have nesting issues with your if..else sets. Only 1 else can exist for any given if.
Post Reply