Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: PHP and MySQL 24-Hour Trainer
|
BOOK: PHP and MySQL 24-Hour Trainer
This is the forum to discuss the Wrox book PHP and MySQL 24-Hour Trainer by Andrea Tarr ; ISBN: 978-1-1180-6688-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: PHP and MySQL 24-Hour Trainer 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 4th, 2012, 11:31 AM
Registered User
 
Join Date: Apr 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question to recover "undefined variable" error

Code:
<html>
<head>
<title>Movie Details</title>
</head>
<body>
 
 <?php
  require('moviesite_connect.php');
  function get_director()
    {
	  global $movie_director;
	  global $director;
	  
	  $query_d=mysql_query("SELECT full_name FROM people WHERE id='$movie_director' ");
	  $row_d=mysql_fetch_array($query_d);
	   extract($row_d);
	   
	   $director=$full_name;
	   
	}
	
	function get_leadactor()
    {
	  global $movie_leadactor;
	  global $leadactor;
	  
	  $query_a=mysql_query("SELECT full_name FROM people WHERE id='$movie_director' ");
	  $row_a=mysql_fetch_array($query_a);
	   extract($row_a);
	   
	   $leadactor=$full_name;
	   
	}
  
  function calculate_difference($takings,$cost)
    {
	  $difference=$takings-$cost;
	   if($difference<0)
	     {
		   $difference= substr($difference,1);
		   $font_color='red';
		   $profit_or_loss='$'.$difference.'m';
		 }
		elseif($difference>0)
		 {
		  $font_color='green';
		  $profit_or_loss='$'.$difference.'m';
		 }
		else
         {
		  $font_color='blue';
		  $profit_or_loss='Broke even';
		 }

          return "<font color='$font_color'>".$profit_or_loss."</font>";
         
		 
		 }
		 
		 $result=mysql_query("SELECT * FROM movie WHERE id='".$_GET['movie_id']."'");
		  
		  while($rows=mysql_fetch_array($result))
		  {
		    
			$movie_name=$rows['movie_name'];
			$movie_director=$rows ['movie_director'];
			$movie_leadactor=$rows ['movie_leadactor'];
			$movie_year=$rows ['movie_year'];
			$movie_running_time=$rows ['movie_running_time'];
            $movie_taking=$rows ['movie_taking'];
			$movie_cost=$rows ['movie_cost'];
            

             get_director('$movie_director');
			 get_leadactor('$movie_leadactor');
			 
			 
			 
			 
            
		  }
		  
		  
          		  
		  
		   
		  
         ?>
		 
		 <tr> <h2><center><?php echo  "$movie_name:details"; ?></center></h2>	</tr>
           
           	   
		 <table width='70%' border='0' cellpadding='2' cellspacing='2' align='center'>
		 <tr>
		 <th>Movie Title</th>
		  <th>Year Of Release</th>
		  <th>Movie Director</th>
		  <th>Movie Lead Actor</th>
		  <th>Movie Running Time</th>
		  <th>Movie Health</th>
		  </tr>
		<?php
           
		   $calculate_difference=calculate_difference($movie_takings,$movie_cost)
		   ?>
		   <tr>
		   <td><?php echo $movie_name;?></td>
		   <td><?php echo $movie_year;?></td>
		   <td><?php echo $director;?></td>
		   <td><?php echo $leadactor;?></td>
		   <td><?php echo $movie_running_time;?></td>
		   <td><?php echo $calculate_difference;?></td>
		    
		   
		  
		   </tr>
		   </table>
		    
		   </body>
		   </html>
.....problem is, after i run this code there showing an error such as "Notice: Undefined variable: movie_takings in G:\wamp\www\RED BOOK PRACTISE\movie_details.php on line 94
Call Stack" not only the $movie_takinng ,the same error is showing including the other variables separately....can i have solution plzzz...





Similar Threads
Thread Thread Starter Forum Replies Last Post
MSXSL gives error message for "for" inside "select" ilyaz XSLT 1 December 9th, 2010 05:02 PM
Difficulties with "web.config" and "ASPNETDB" CFRham BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 2 July 3rd, 2010 10:19 AM
Need code corrections "get sub or function not defined" error" bluesboytoo Excel VBA 1 October 22nd, 2009 11:12 PM
How to theme the "Browse" button of "FileUpload" control? varunbwj BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 October 14th, 2009 01:22 AM
Add a CheckBox DataColumn to my DataGridView, Null format: "" or "True" but Error: F ismailc C# 2005 0 September 25th, 2009 04:56 AM





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