Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
| Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP 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 16th, 2005, 01:48 PM
Registered User
 
Join Date: Dec 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to majidnakit
Default Undefined variable

Hi, I am new to php, why I got this error when I click in the link in the movie1.php, here is the error :
My favorite movie is
Notice: Undefined variable: favmovie in C:\Program Files\Apache Group\Apache2\htdocs\moviesite.php on line 9

My movie rating for this movie is: 5


movie1.php :
<HTML>
<HEAD>
<TITLE>Find my Favorite Movie!</TITLE>
</HEAD>
<BODY>
<?php
echo "<a href=moviesite.php?favmovie=Stripes>";
echo "Click here to see information about my favorite movie!";
echo "</a>";
?>
</BODY>
</HTML>


moviesite.php :
<HTML>
<HEAD>
<TITLE>My Movie Site - <?php echo $favmovie ?></TITLE>
</HEAD>
<BODY>
<?php
//delete this line: define (“FAVMOVIE”, “The Life of Brian”);
echo "My favorite movie is ";
echo $favmovie;
echo "<br>";
$movierate=5;
echo "My movie rating for this movie is: ";
echo $movierate;
?>
</BODY>
</HTML>

 
Old April 16th, 2005, 07:11 PM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

because a page won't have a clue what $favmovie is unless you DEFINE IT!!!
in your moviesite.php page above all $favmovie variables try entering this like:

$favmovie = $_GET['favmovie'];

----------------
Never bother to learn something not knowing which does not do you any harm, and never neglect to learn something whose negligence will increase your ignorance - Imam Jafar Sadeq
 
Old April 16th, 2005, 11:23 PM
Registered User
 
Join Date: Dec 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to majidnakit
Default

thank you, it works now.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Undefined Variable aspire Beginning PHP 4 July 12th, 2006 07:00 AM
Undefined variable najib Beginning PHP 4 July 1st, 2005 08:12 AM
undefined variable !! cody44 Beginning PHP 3 January 20th, 2005 05:47 PM
Undefined Variable fpolan Beginning PHP 9 July 15th, 2004 06:24 AM
Undefined Variable Some Help! knight Beginning PHP 7 February 19th, 2004 07:07 AM





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