Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To 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 January 7th, 2006, 04:06 PM
Registered User
 
Join Date: Jan 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default changing the value of variables in PHP

Hi there. I am trying to create a simple PHP program using the following code:

<?php
    $myfavmovie = urlencode(Madagascar);

  echo "<a href='moviesite.php?favmovie=$myfavmovie'>";
  echo "Click here to see information about my favorite movie!";
  echo "</a>";
?>

I have a page that this is linked to - which seems to work fine, but when I change the value of "$myfavmovie" to anything else, "Madagascar" continues to show up. Are variables completely static within a page such that I cannot change them once I have assigned a value to it? That doesn't seem to me to be correct...

Here is the code on the subsequent page to which this is linked in case that matters...

<?php

echo "My favorite movie is ";
echo $_REQUEST['favmovie'];

?>

I am much obliged.
 
Old January 8th, 2006, 12:09 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've tried your code and it works fine..

If you change the value of $myfavmovie in the 1st file (save and press refresh on your browser) it does change the value in the second (when you click the link).. I don't undertand where the problem is ??





Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing php variables using the href tag Rayne84 PHP How-To 11 July 12th, 2007 02:47 PM
Changing variables in match templates chicken XSLT 0 September 11th, 2006 10:26 AM
HOW DECLARE VARIABLES IN PHP jhan316 Beginning PHP 1 July 25th, 2006 07:16 PM
Passing Variables from PHP to PHP brian3166 PHP How-To 4 January 31st, 2005 12:44 AM
passing variables from PHP to Perl joconnor Beginning PHP 4 July 21st, 2004 08:13 AM





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