pilot Posted March 2, 2008 Share Posted March 2, 2008 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" ) ); Quote Link to comment Share on other sites More sharing options...
chet139 Posted March 2, 2008 Share Posted March 2, 2008 It maybe that its not set at that time, so the page does not know about it. Try an IF (isset..... { } Quote Link to comment Share on other sites More sharing options...
Baabu Posted March 2, 2008 Share Posted March 2, 2008 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> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.