Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5
This is the forum to discuss the Wrox book Beginning PHP4 by Wankyu Choi, Allan Kent, Chris Lea, Ganesh Prasad, Chris Ullman; ISBN: 9780764543647
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 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
  #1 (permalink)  
Old December 15th, 2004, 01:22 AM
Authorized User
 
Join Date: Dec 2004
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with set cookie chapter 8

I've typed out the code but get all kinds of errors:

Notice: Undefined variable: size_sel in C:\Documents and Settings\Stephen\My Documents\Websites\test_sites\beginning_php\chapte r_08\cookie_test.php on line 7

What font type would you like to use? DefaultArialHelveticaCourierSans-Serif


Your cookies say:
Notice: Use of undefined constant type - assumed 'type' in C:\Documents and Settings\Stephen\My Documents\Websites\test_sites\beginning_php\chapte r_08\cookie_test.php on line 40
face='Courier'
Notice: Use of undefined constant size - assumed 'size' in C:\Documents and Settings\Stephen\My Documents\Websites\test_sites\beginning_php\chapte r_08\cookie_test.php on line 45

Notice: Undefined index: size in C:\Documents and Settings\Stephen\My Documents\Websites\test_sites\beginning_php\chapte r_08\cookie_test.php on line 45
> $font[type] = Courier

Notice: Undefined index: size in C:\Documents and Settings\Stephen\My Documents\Websites\test_sites\beginning_php\chapte r_08\cookie_test.php on line 52
$font[size] =

Your variables say:
Notice: Undefined variable: size_sel in C:\Documents and Settings\Stephen\My Documents\Websites\test_sites\beginning_php\chapte r_08\cookie_test.php on line 62
> $type_sel =

Notice: Undefined variable: size_sel in C:\Documents and Settings\Stephen\My Documents\Websites\test_sites\beginning_php\chapte r_08\cookie_test.php on line 69
$size_sel =


Anyone got any ideas why? I'm a bit stuck, I don't know how to fix the errors.

Here's my code:


Code:
<?php
    if ($type_sel)
    {
        setcookie ("font[type]", $type_sel, time() + 3600);
    }

    if ($size_sel)
    {
        setcookie ("font[size]", $size_sel, time() + 3600);
    }

    $type = array ("Arial", "Helvetica", "Courier", "Sans-Serif");
    $size = array ("1", "2", "3", "4", "5", "6", "7");


    echo     "<html>";
    echo     "    <head>";
    echo     "        <title>Cookie Test</title>";
    echo     "    </head>";
    echo     "";    
    echo     "    <body>";
    echo     "        <div align='center'>";
    echo     "            <form method='post'>";
    echo     "                What font type would you like to use?";
    echo     "                <select name='type_sel'>";
    echo     "                    <option selected value=''>Default</option>";

                                foreach ($type as $var)
                                {
                                    echo "<option>$var</option>";
                                }

    echo     "                </select><br><br>";
    echo     "                <input type='submit'>";
    echo     "            </form>";
    echo     "";    
    echo     "            <b>Your cookies say:</b><br>";
    echo     "            ";
    echo     "            \$font[type] = $font[type]<br>";
    echo     "            \$font[size] = $font[size]<br>";
    echo     "            <br>";
    echo     "            <b>Your variables say:</b><br>";
    echo     "            ";
    echo     "            \$type_sel = $type_sel<br>";
    echo     "            \$size_sel = $size_sel<br>";
    echo     "            <br>";
    echo     "        </div>";
    echo     "    </body>";
    echo     "</html>";
?>

  #2 (permalink)  
Old December 15th, 2004, 02:09 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I do not have the book, but perhaps this is a register_globals issue?

Try turning register_globals on in php.ini and see if it works.

-Snib - http://www.snibworks.com
Where will you be in 100 years?
  #3 (permalink)  
Old December 15th, 2004, 02:35 PM
Authorized User
 
Join Date: Dec 2004
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

register_globals is on, what else might be the problem?



Similar Threads
Thread Thread Starter Forum Replies Last Post
set the cookie file name crmpicco Javascript How-To 4 February 17th, 2006 05:04 AM
Set Cookie Chapter 8 ? phirun BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 13 May 27th, 2005 11:19 AM
Use cookie to set main frame npepin Javascript 0 October 18th, 2004 02:01 PM
Set Cookie rowlandk Beginning PHP 5 April 6th, 2004 01:18 PM
getting set cookie value from a script abbylee26 Javascript 1 July 17th, 2003 03:01 AM





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