GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 22-Jul-2005, 05:04
siaca siaca is offline
New Member
 
Join Date: Jul 2005
Posts: 1
siaca is on a distinguished road

Vague Parse Error!


Hi guys,

Please help. I keep getting the following error which I can't quite understand:

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/egp9/web/cartaction.php on line 18

PHP Code:

<?
session_start();
session_register('totalPrice');
session_register('panName');
session_register('panAction');
session_register('panPrices');
session_register('cartItems');
session_register('postage');
session_register('postagex');
$_SESSION['totalPrice'] = 0;
$_SESSION['panName'] = $_POST['item'];
$_SESSION['panAction'] = $_POST['cartaction'];
$_SESSION['postage'] = 350 / 100;
$_SESSION['postagex'] = 200 / 100;
/*Check to see if both the hidden fields that hold the panName and panAction have both been posted*/ 
if (($_SESSION['panName']) && ($_SESSION['panAction']) && ($_SESSION['cartItems'] <= 1)) {
    $_SESSION['totalPrice'] = "$_SESSION['panPrices']["$_SESSION['panName']"] * $_SESSION['cartItems'] + $_SESSION['postage']";// multiply price by quantity created as variable SESSION_cartItems
    $msg = "Added to your cart: $_SESSION['panName'], value &pound";
} else if (($_SESSION['panName']) && ($_SESSION['panAction']) && ($_SESSION['cartItems'] > 1)); {
$_SESSION['totalPrice'] = $_SESSION['panPrices']["$_SESSION['panName']"] * $_SESSION['cartItems'] + $_SESSION['postage'] + $_SESSION['postagex'];
} else {
    $msg = " Your Cart is empty";
    }
    
// Create iamge variables to be later used to dynamically display shopping cart images
$img1 = '<IMG SRC="images/coppercasserole.jpg" ALT="copper casserole pan">';
$img2 = '<IMG SRC="images/coppersaucepan.jpg" ALT="copper sauce pan">';
$img3 = '<IMG SRC="images/coppersaute.jpg" ALT="copper saute">';
$img4 = '<IMG SRC="images/steelcasserole.jpg" ALT="steel casserole">'; 
$img5 = '<IMG SRC="images/steelfrying.jpg" ALT="steel frying pan">';
$img6 = ''; //Create an empty space 

$c1 = 2199 / 100;
$c2 = 1988 / 100;
$c3 = 1299 / 100;
$s1 = 2099 / 100;
$s2 = 899 / 100;
$_SESSION['panPrices'] = array(
"coppercasserole" => "$c1",
"coppersaucepan" => "$c2",
"coppersaute" => "$c3",
"steelcasserole" => "$s1",
"steelfrying" =>"$s2"
);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<TITLE>Pans for your kitchen</TITLE>

</HEAD>
<BODY>
<h2><? echo $msg ?> <? print($_SESSION['panPrices']["$_SESSION['panName']"]); ?></h2>

<CENTER>
<FORM ACTION="checkout.php"  METHOD="post" name="purchase_form" id="purchase_form">
<p>
    <INPUT TYPE="submit" NAME="submit" VALUE="Goto Checkout">
    <input type="submit" name="Submit" value="Remove">
</p>
</FORM>
<TABLE>
<TR><TD>
<? if ($_SESSION['panName'] == "coppercaserole") {
echo $img1;
} else if ($_SESSION['panName'] == "coppersaucepan") {
echo $img2;
} else if ($_SESSION['panName'] == "coppersaute") {
echo $img3;
} else if ($_SESSION['panName'] == "steelcaserole") {
echo $img4;
} else if ($_SESSION['panName'] == "steelfrying") {
echo $img5;
} else {
echo $img6; // This variable holds space
} 
?>
</TD>
<TD>
<? if (($_SESSION['panName']) && ($_SESSION['panAction'])) {
echo "$panName = $_SESSION[cartItems] += 1";
} else {
echo '';
} ?><BR>

</TD>
<TD>
<FORM METHOD="post" ACTION="cartaction.php">
</FORM>
</TD>
</TR>

</TABLE>
<A HREF="index.php">Go Back Home</A>
<A HREF="copperrange.php">Copper Range</A>
<A HREF="steelrange.php">Steel Range</A>
</CENTER>
<HR>

</BODY>
</HTML>
Last edited by LuciWiz : 22-Jul-2005 at 05:45. Reason: Please insert your Php code between [php] & [/php] tags
  #2  
Old 22-Jul-2005, 07:48
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Hello siaca,

When dealing with arrays within a string, here are the 3 valid choices you have:

PHP Code:

<?php

// .... snipped code from your example.

// 1. using curly braces {} - VALID
$msg = "Added to your cart: {$_SESSION['panName']}, value &pound";

// 2. remove the 'SINGLE quotes' in the array index (name/key) - VALID
$msg = "Added to your cart: $_SESSION[panName], value &pound";

// 3. using the concatenation operator - VALID
$msg = "Added to your cart: " . $_SESSION['panName'] . ", value &pound";

// ... the rest of your example code
?>

 
 

Recent GIDBlogWelcome to Baghdad by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in ukrspp21 MySQL / PHP Forum 31 04-Jul-2006 21:41
[Tutorial] GUI programming with FLTK dsmith FLTK Forum 10 03-Oct-2005 15:41
What is "Ambigious symbol" ??*( a compilation error) small_ticket C++ Forum 2 07-Jan-2005 21:10
Error C2146: syntax error : missing ',' before identifier 'C4' mattchew008 C++ Forum 2 19-Dec-2004 06:06
Can enum have same name as class? crystalattice C++ Forum 3 08-Dec-2004 16:43

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:28.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.