where is the 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:

where is the error

Post by bruceg »

I am getting another error, I need help spotting please.

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 ($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>
</form>";
$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>
the error is:

Parse error: parse error, unexpected T_STRING in /hsphere/local/home/bruceg/inspired-evolution.com/Contact_Menu.php on line 18

thanks!
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

$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>';
Changed encapsulating double quotes to single quotes so you don't have to escape the other double quotes. :wink:


To help you understand better, you were doing this

Code: Select all

$var = "This is a var with double "quotes" in it. This will generate a parse error because the double quotes inside the string were not escaped";

Code: Select all

$var = "This is the proper way to deal with \"quotes\" in a variable";
or

Code: Select all

$var = 'This will work " without escaping any quotes but will never parse any $variables unless single quotes were parsed.';
Post Reply