Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
A Beginner Set cookies question
Old 04-25-2005, 12:31 PM A Beginner Set cookies question
Experienced Talker

Posts: 41
Trades: 0
I just pasted this simple example to document but got gibberish.

I place the code before <!DOCTYPE HTML PUBLIC tag.

What am I doing wrong ?

<?php
// Print an individual cookie
echo $_COOKIE["TestCookie"];
echo $HTTP_COOKIE_VARS["TestCookie"];

// Another way to debug/test is to view all cookies
print_r($_COOKIE);
?>


Thank you so much!
grace04 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-25-2005, 01:15 PM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
Really, I've never seen a gibberish error before, could you show me what that looks like?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 04-26-2005, 05:38 PM
Experienced Talker

Posts: 41
Trades: 0
Hey,

for the code above i'm getting:

$value) { echo "$name : $value
\n"; } } ?>

in my web browser...
grace04 is offline
Reply With Quote
View Public Profile
 
Old 04-26-2005, 05:41 PM
Experienced Talker

Posts: 41
Trades: 0
Do any one have a simple php/cockies code I can look at or

send me to a good tutorial about the subject ?

Thank you !

-- Grace
grace04 is offline
Reply With Quote
View Public Profile
 
Old 04-26-2005, 05:47 PM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
Does your server support PHP?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 04-26-2005, 05:52 PM
Experienced Talker

Posts: 41
Trades: 0
yes
grace04 is offline
Reply With Quote
View Public Profile
 
Old 04-26-2005, 06:08 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Looks like it is spitting out some other part of your code - check that your <? and ?> tags are matched and that you've matched up quotes around your strings and matched up the starts and ends of comments etc.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 04-26-2005, 06:24 PM
Experienced Talker

Posts: 41
Trades: 0
I changed it to the following:

$Age_Group = $_POST['Age_Group'];
setcookie("Age", $Age_Group);

if ($_COOKIE['Age'] == '21 - 25')

{

echo "Hello, ".$_COOKIE['Age']."I choose the 0-20 age group!";

}

else ($_COOKIE['Age'] == '21 - 25')
{

echo "Hello, ".$_COOKIE['Age']."! So I guess you like them a bit older!";

}



But getting this blurb back -


"; // } // elseif ($APrefGender == 'Women') // { // echo ""; // } // echo " "; $Age_Group = $_POST['Age_Group']; setcookie("Age", $Age_Group); ?>


any ideas ?

Can i use only isset with cookie ?
grace04 is offline
Reply With Quote
View Public Profile
 
Old 04-26-2005, 06:31 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
No, your PHP is spitting out your code, it is not an error in PHP or Cookies. You've done your coding wrong, we need to see ALL of your code, not a snippet, the whole file that is associated with the action. Please
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 04-26-2005, 06:37 PM
Experienced Talker

Posts: 41
Trades: 0
Here you go: Thx !

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

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


<?

$Age_Group = $_POST['Age_Group'];
setcookie("Age", $Age_Group);

?>


<p>I am interesting in some insights about echamist<strong></strong>ry from folks in thier :
<select name="topic">
<option>Select Topic</option>
<option>A</option>
<option>B</option>
<option>C</option>
<option>D</option>
<option>E</option>
<option>41 - 99</option>
</select>
</p>


<?

if ($HTTP_cookie_VARS[Age] == "0 - 20")
{

echo "Hello, ".$_COOKIE['Age']."! So you like them young!";

}

else
{

echo "Hello, ".$_COOKIE['Age']."! So I guess you like them a bit older!";

}

?>

<INPUT name="submit" TYPE='submit' VALUE='Please Click Here To Continue'>

</form>
</body>
</html>
grace04 is offline
Reply With Quote
View Public Profile
 
Old 04-26-2005, 06:51 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Ok, what's on C.php? I'm guessing it is AFTER you submit the form that you get this problem, and that C.php has a problem causing it display some of its code.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 04-26-2005, 06:51 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
hmm, odd. That error message your getting don't seem to match any of your code, u using external files?

The else in the argument should be next to the closing bracket of the if statement too.

Oberon u got anything to say? Need wiser eyes.
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 04-26-2005, 07:00 PM
Experienced Talker

Posts: 41
Trades: 0
the 3 pages are A.php, B.php. C.php
In page A I'm setting the Age group Variable then in page B which you see the code for, I wrote the echo stmt but they are not coming up.

There is no error msg just yet, i am not getting the echo stmt on this page either.
Why ?

My goal in this - Get users inpout on page A.php & B.php and based on that send them to another page

Is there a sample code any of you guys have that I can look at ?

Thank you for your kindness. gs
grace04 is offline
Reply With Quote
View Public Profile
 
Old 04-27-2005, 12:34 AM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
leavethisplace, I agree it's really odd that none of the code that gets echoed is on that file. The only external file I can see is C.php, which is where the form gets submitted to.

grace04, can you show us the code for all three files so we can have a look for where the problem is? Also, please enclose your php code in [php ][/php ] tags (minus the spaces), it makes it an awful lot easier to read, plus the syntax highlighter will probably spot this problem for us
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Reply     « Reply to A Beginner Set cookies question
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.51100 seconds with 12 queries