Wrox Programmer Forums
|
BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143
This is the forum to discuss the Wrox book Beginning PHP 6, Apache, MySQL 6 Web Development by Timothy Boronczyk, Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz; ISBN: 9780470391143
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 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 October 15th, 2009, 08:32 PM
Registered User
 
Join Date: Oct 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Exercise 4, P76 - solution on p. 652

Either we are missing something or.... but we keep getting the T_CONSTANT_ENCAPSED_STRING error with the 5 lines on the top of page 652. We think we have matched the code exactly - but are all getting the same error.

Ideas on what I am missing?

TIA,

jc
 
Old March 25th, 2010, 08:00 PM
Registered User
 
Join Date: Mar 2010
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
Default Exercise 4, P76 - solution on p. 652

Hi Jim, I've just spent two hours going over the same problem you had in October. Over 200 views to your post but not a single reply! Did you manage to sort it? I'll reiterate the problem here.

The following code is exactly as printed and to my newbie eyes looks OK but I too keep getting T_CONSTANT_ENCAPSED_STRING error. (, or ; expected).

Code:
<p <?php
echo ' style="font-family: ' . $_SESSION['font'] . '; ';
echo 'font-size: ' . $_SESSION['size'] . '; ';
echo 'color: ' . $_SESSION['colour'] ';" ';
?> >Hi there, this text is here formatted in the font, size and colour you chose on the login page!</p>
The faulty line is apparently the last echo line. If the final " is ommitted then the rest of the page is formatted in the chosen style so there's obviously no problem with the $_SESSION bits etc. If there's somebody out there who can help please do! I'm dying to move on to Chapter 3. Thanks
 
Old March 25th, 2010, 09:13 PM
Friend of Wrox
 
Join Date: Dec 2008
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
Default

You missed a dot on line 4:
Code:
echo 'color: ' . $_SESSION['colour'] . ';" ';
That was the immediate problem that caused the error message. There also seems to be other issues that is not immediately related to that error message. For example, your very first p tag is not closed properly.
 
Old March 26th, 2010, 05:53 AM
Registered User
 
Join Date: Mar 2010
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
Default Working now.

Thanks Peter. Putting the dot in makes everything work. However, I would like to point out that this is another Wrox error not mine. There is no dot in the code in the book. You say there are errors in my code, maybe but again this code is copied exactly from the book. So far as closing the <p>, the entire php code is placed within the <p>, with the closing of the <p> done immediately after the ?> hence the
Code:
?> >
 
Old March 26th, 2010, 09:48 AM
Friend of Wrox
 
Join Date: Dec 2008
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
Default

You are absolutely right! There is no problem with that p tag.
 
Old March 4th, 2011, 01:06 PM
bcb bcb is offline
Registered User
 
Join Date: Mar 2011
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Answer to this Exercise Please? Chapter 2 Exercise 4 SOLVED

Hi, I have correct the errata so I have the code loading without any php errors, but the text does not actually change color or fonts.

Can someone please detail what pages they place this code on and where or perhaps upload their code examples of a working version of Exercise 4 Chapter 2 ?

I have tried placing the code in different combinations of the Login.php, moviesite.php and movie1.php and the code does show with no errors, but the text is always black and the font is always unchanged, so I guess the session variables are not being transferred to the form? If anyone can help by posting their working code i would appreciate it.

After some wrestling I have gotten it to work for me. It seems there are more Errata than mentioned here in the forum. The form example in appendix A has some pretty big errors. I am the working code here for future reference.

I added this bit under the form action in login.php

<td><label for="font">Select Font:</label></td>
<td><select id="font" name="font">
<option value="Verdana">Verdana</option>
<option value="Arial">Arial</option>
<option value="Times New Roman">Times New Roman</option>
</select>
</td>
</tr><tr>
<td><label for="size">Select Size:</label></td>
<td><select id="size" name="size">
<option value="10px">10px</option>
<option value="12px">12px</option>
<option value="16x">16x</option>
<option value="20x">20x</option>
</select>
</td>
</tr><tr>
<td><label for="color">Select Color:</label></td>
<td><select id="color" name="color">
<option value="black">black</option>
<option value="green">green</option>
<option value="purple">purple</option>
<option value="red">red</option>

This next bit I added after the session start()
in movie1.php

$_SESSION['font']=$_POST['font'];
$_SESSION['size']=$_POST['size'];
$_SESSION['color']=$_POST['color'];

and this bit right after the include statement for header.php in moviesite.php

<p <?php
echo ' style="font-family: ' . $_SESSION['font'] . '; ';
echo 'font-size: ' . $_SESSION['size'] . '; ';
echo 'color: ' . $_SESSION['color'] . ';" ';
?> > Hi there, this text is here formatted in the font, size and colour you chose on the login page!</p>

This was a combination of trial and error and following some threads on this forum. I hope it helps someone down the road.

Last edited by bcb; March 4th, 2011 at 05:26 PM.. Reason: Figured out the answer to my question.





Similar Threads
Thread Thread Starter Forum Replies Last Post
My solution to exercise 6, on ch.2 - help rjm BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 July 28th, 2010 05:50 PM
Exercise 4, P76 - solution on p. 652 Jim.Clauson BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 0 October 15th, 2009 08:30 PM
Solution to exercise 7, Chapter 2 Nick Y BOOK: Ivor Horton's Beginning Visual C++ 2005 0 May 28th, 2006 04:28 AM
exercise solution uddessjava Java Basics 1 December 29th, 2005 04:57 AM
Exercise Solution jgrat BOOK: Beginning Access VBA 3 October 18th, 2004 04:13 PM





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