Page 1 of 1

what's this error all about?

Posted: Sat Aug 27, 2005 9:15 am
by bruceg
Parse error: parse error, unexpected T_STRING in /hsphere/local/home/bruceg/inspired-evolution.com/Contact_Menu.php on line 2

here is the code...

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";
}

}

$form_block = "<h1>Login</h1>
<form method=POST action=\"$_SERVER[PHP_SELF]\">
$msg
<p><strong>username:</strong><br />
<input type=\"text\" name=\"username\" size="15" maxlength="25"></p>
<input type=\"hidden\" name=\"op\" value=\"ds\">
<p><input type=\"submit\" name=\"submit\" value=\"login\"></p>
$menu_block = "<h1> Inspired Evolution Contact Administration System</h1>
<p><strong>Administration</strong>
<ul>
<li><a href="show_addcontact.php">Add a Contact</a></li>
<li><a href="pick_modcontact.php">Modify a Contact</a></li>
<li><a href="pick_delcontact.php">Delete a Contact</a></li>
</ul>
<p><strong>View Records</strong></p>
<ul>
<li><a href="show_contactsbyname.php">Show Contacts, Ordered by Name</a>
</ul>";
if ($show_form =="yes") {
       $display_block = form_block;
} else if ($show_menu =="yes") {
        $display_block = $menu_block;
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US" dir="ltr">
<head>
<meta http-equiv="Content-type" content="text/html; charset=ISO-8859-1" />
<title>Inspired Evolution :: Contact Management System</title>
<?php require('includes/meta_tags.inc'); ?>
<link rel="stylesheet" href="Gilbert.css" type="text/css" media="screen, handheld" />
<link rel="alternate" type="application/rss+xml" title="RSS news feed " href="http://www.inspired-evolution.com/RSS/Inspired-Evolution.xml" />
</head>
<body>
<!-- begin outer wrapper div --> 

<div id="wrapper_outer">
<a class="skiplink" href="#startcontent">Skip over navigation</a>

<!-- begin header div --> 
<div id="header"><img src="/images/logo_header1.jpg" height="100" width="650" alt="inspired evolution - let the evolution begin"/></div>

<!-- top nav list --> 
<div id="navcontainer">
<ul id="navlist">
<li><a href="About_Me.php" title="you know you want to learn more about me">About Me</a></li>
<li><a href="Skillset.php" title="I've got skillz">Skill set</a></li>
<li><a href="Hireme.php" title="I can do wonders for your web presence">Hire Me</a></li>
<li><a href="Portfolio.php" title="web sites, graphics, newsletters">Portfolio</a></li>
<li><a href="Contact.php"  title="how to get in touch with me">Contact</a></li>
<li><a href="Resume.php"  title="my beautiful resume">R&eacute;sum&eacute;</a></li>
<li><a href="/bruce_blog/index.php"  title="daily musings on everyday life" >Blog</a></li>
<li><a href="RSS.php"  title="Syndication that is really simple" >RSS</a></li>

</ul>
</div>
<!-- inner content wrapper div --> 
<div id="wrapper_inner">
<!-- breadcrumbs div --> 
<div id="breadcrumbs"><a href="index.php" title="home link" accesskey="h">Home</a>  > >  Contact Management System</div>
<!-- text div --> 
<div id="main_content">
<a name="startcontent" id="startcontent"></a>
<h1 title="Contact Management System">Contact Management System</h1>
<? echo "$display_block;?>

<div id="bottom_links2"><ul id="horizontal_list2"><li><a href="Sitemap.php" title="Site Map">Site Map</a></li><li><a href="Recent_Updates.php" title="Recent Updates">Recent Updates</a></li><li><a href="About_This_Site.php" title="About this site">About This Site</a></li><li><a href="FAQ.php" title="links to FAQ page"><abbr title="Frequently Asked Questions"> FAQ</abbr></a></li><li><a href="CSS_tips.php" title="links to page chocked full of great CSS tips"> CSS tips</a></li><li><a href="Accessibility.php" title="Accessibility">Accessibility</a></li><li><a href="Link_Exchange.php" title="Link Exchange">Link Exchange</a></li><li><a href="SEO.php" title="SEO"><abbr title="search engine optimization">SEO</abbr></a></li></ul></div>
</div>

<!-- begin footer --> 
<div id="footer">
<p class="footertag">Inspired-Evolution - Web Site: Design, Development, Marketing for Raleigh/Durham, Chapel Hill, Cary, North Carolina.</p>

<?php require('includes/footer.inc'); ?>
<span class="date"><?
$last_modified = filemtime("index.php");
print("Last Modified ");
print(date("m/j/y h:i", $last_modified));
?></span>
</div>

</div>
</div>

</body>

</html>





thanks!

Posted: Sat Aug 27, 2005 9:18 am
by feyd
you have lots of unescaped double quotes in your string, as you'll see in the highlight code above.

Posted: Sat Aug 27, 2005 9:30 am
by shiznatix
plus this line

Code: Select all

if ()$_POST[username] !="admin") || ($_POST[password] !="abc123" )) {
is really messed up and i think you where trying to do this...

Code: Select all

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

Posted: Sat Aug 27, 2005 9:32 am
by feyd
there's also a space between <? and php, remove it, and quote your named array indices. i.e. $_SESSION[valid] :arrow: $_SESSION['valid']

Posted: Sat Aug 27, 2005 11:57 am
by bruceg
so whenever I have something like this

Code: Select all

if ($_SESSION[valid] =="yes")
it should be

Code: Select all

if ($_SESSION['valid'] =="yes")
?

also, I am still getting errors with this block:

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: Sat Aug 27, 2005 12:07 pm
by feyd
bruceg wrote:so whenever I have something like this

Code: Select all

if ($_SESSION[valid] =="yes")
it should be

Code: Select all

if ($_SESSION['valid'] =="yes")
?
yep
bruceg wrote:also, I am still getting errors with this block:

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";
}
you have unescaped quotes on the $msg line: "red"


I highly suggest you use an editor with good syntax highlighting. Look through the recommendations and preferences in the Favourite Editors thread.