Jump to content

Undefined variable:


zenix

Recommended Posts

Hi, I am learning this and doing alright (well...until now), I have hit a wall that seems to define logic. If someone could help me out I would REALLY appreciate it. The code is below, the error I get is "Undefined variable $movie_details. The first instance of the variable works well, but the second one comes up undefined. The table I am attempting to display does show, but so does the error in the upper left of the screen.Thanks a lot in advance!

 

Sorry my coding isn't very efficient, I will improve in time right now I am just trying to learn.

 

while($row = mysql_fetch_array($result))

{

$movie_name = $row['movie_name'];

$movie_director = $row['movie_director'];

$movie_leadactor = $row['movie_leadactor'];

 

$movie_details .=<<<EOD

<tr>

<td>$movie_name</td>

<td>$movie_director</td>

<td>$movie_leadactor</td>

</tr>

EOD;

}

 

$movie_details .=<<<EOD

<tr>

<td> </td>

</tr>

<tr>

<td>Total :$num_movies Movies</td>

</tr>

EOD;

Link to comment
https://forums.phpfreaks.com/topic/130759-undefined-variable/
Share on other sites

Yes I know, but there is a while loop before it.  So if there's nothing in the loop then menu_details will never be initialized and if he tried to use that variable in another section he would still receive that same error. 

 

I come from a java background, so I'm used to initializing and assigning types to everything  8)  Even though, I still don't follow some of these practices in PHP...

Link to comment
https://forums.phpfreaks.com/topic/130759-undefined-variable/#findComment-678723
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.