Jump to content

undefined variables - cant see why ?


pilot

Recommended Posts

These code lines are excerpts from within the program that give me an error message that a variable is undefined, but the program is working in that the functionality is correct, and the variable has been used in other parts of the program, usually by a function call, without getting an error message.  All of this useage is within the same file that is a group of functions.  I am a bit of a rookie for this, but I don't see why these are undefined.  Can someone see what I am missing or where to look for contributing issues ?  Thanks

 

    Error message says that cat is undefined variable   

echo "  <form method=\"post\" action=\"$PHP_SELF?action=login&cat=$cat\">\n";

 

    Error message says that email is undefined variable.

echo "      <td width=\"160\" height=\"25\"><input type=\"text\" name=\"email\" value=\"$email\" size=\"20\" maxlength=\"50\"></td>\n";

 

  Error message says that location is undefined variable.

$result = mysql_query( "SELECT cat_name, root_id, papa_id FROM category WHERE root_id=$id" ) or error( mysql_error() );

$row = mysql_fetch_array( $result );

if( $row['papa_id'] == 0 ) $location .= $row['cat_name'];

 

    Error message says that totalAds is undefined variable.

$result = mysql_query( "SELECT root_id FROM category WHERE papa_id=$id" ) or error( mysql_error() );

if( mysql_num_rows( $result ) == 0 )

$totalAds += mysql_num_rows( mysql_query( "SELECT cat_id FROM ads WHERE cat_id=$id AND exp_date>$time" ) );

 

 

Link to comment
Share on other sites

Well i would suggest you avoid using html tags in echo statements it is much better to use them simply

just like

echo "      <td width=\"160\" height=\"25\"><input type=\"text\" name=\"email\" value=\"$email\" size=\"20\" maxlength=\"50\"></td>\n";

would be much better if you use it

<td width="160" height="25"><input type="text" name="email" value=<?php echo $email; ?> size="20" maxlength="50"></td>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.