Wrox Programmer Forums
|
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 5th, 2004, 07:37 AM
Registered User
 
Join Date: Apr 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Continual Parse error

Hi,

I'm working through Chapter 12. I'm stuck on creating the user.php page (page 437-439). I've double-checked everything but whenever I try to load the page in a browser I get the error:

Parse error: parse error, unexpected '=' in c:\Program Files\Apache Group\Apache2\htdocs\mailing_lists\user.php on line 72

I have downloaded the code from the P2P site but even that gives me the same error.

My code is:

<?php
require('config.php');
?>

<html>
<head>
<title>Mailing List Signup</title>
</head>
<body>

<form method="post" action="user_transact.php">

<p>
 Sign up for Mailing List:

</p>

<?php

$conn = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS)
 or die('Could not connect to MySQL database. ' . mysql_error());

mysql_select_db(SQL_DB,$conn);

if (isset($_GET['u']))
{
 $uid = $_GET['u'];
 $sql = "SELECT * FROM ml_users WHERE user_id = '$uid';";
 $result = mysql_query($sql)
  or die('Invalid query: ' . mysql_error());
 if (mysql_num_rows($result)) {
  $row = mysql_fetch_array($result);
  $e-mail = $row['e-mail'];
 } else {
  $e-mail = "";
 }
}
?>

<p>
 E-mail Address:

 <input type="text" name="e-mail" size="40" value="<?php echo
    $e-mail;?>"/>
</p>

<p>
 If you aren't currently a member, please provide
your name:


 First Name:

 <input type="text" name="firstname" />

 Last Name:

 <input type="text" name="lastname" />

</p>

<p>
 Select the mailing lists you want to receive:

 <select name="ml_id">

<?php
$result = mysql_query("SELECT * FROM ml_lists ORDER BY listname;")
 or die('Invalid query: ' . mysql_error());

while ($row = mysql_fetch_array($result))
{
 echo " <option value=\"" . $row['ml_id'] . "\">" .
    $row['listname'] . "</option>\n";
}

?>
 </select>
</p>

<p>
 <input type="submit" name="action"
    value="Subscribe" />
</p>

</form>

</body>
</html>

Is there anything I am doing wrong???
 
Old April 5th, 2004, 04:07 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

You are receiving this error because the 'dash' character is not a valid character in variable names. So change $e-mail to $email and all should be fine.

: )
Rich

::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::
 
Old April 7th, 2004, 10:41 AM
Registered User
 
Join Date: Apr 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks. It worked a treat and I've learnt something in the process rather than just getting a fix.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: syntax error, unexpected T_ELSE in /h vipin k varghese BOOK: XSLT Programmer's Reference, 2nd Edition 4 September 29th, 2011 01:19 AM
Ch 4: Parse error: syntax error, unexpected T_SL hanizar77 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 23rd, 2008 09:17 PM
Parse error: syntax error, unexpected T_STRING ginost7 Beginning PHP 1 November 9th, 2007 02:51 AM
PHP Parse error: parse error, unexpected T_STRING geminient PHP How-To 4 August 18th, 2007 02:27 AM
Parse error: parse error, unexpected $end Ayodeji Adegbaju Pro PHP 3 January 12th, 2007 12:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.