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
bruceg
Forum Contributor
Posts: 174 Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:
Post
by bruceg » Mon Aug 29, 2005 8:56 pm
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";
}
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Aug 29, 2005 9:19 pm
your quotes are misplaced. Look at the highlighted text.
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Mon Aug 29, 2005 9:20 pm
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 » Mon Aug 29, 2005 9:28 pm
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") {
??
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Aug 29, 2005 10:54 pm
what's the error?
bruceg
Forum Contributor
Posts: 174 Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:
Post
by bruceg » Mon Aug 29, 2005 11:14 pm
Parse error: parse error, unexpected T_ELSE in /hsphere/local/home/bruceg/inspired-evolution.com/Contact_Menu.php on line 4
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Aug 29, 2005 11:38 pm
you have nesting issues with your if..else sets. Only 1 else can exist for any given if.