Scotty13 Posted September 21, 2012 Report Share Posted September 21, 2012 Error: Notice: Undefined variable: res.php on lines 362, 408, 412 (Marked bold below) Notice: Undefined variable: passengerUserName in /home/************/res.php on line 362 Notice: Undefined variable: passengerFirstName in /home/************/res.php on line 362 Notice: Undefined variable: puname in /home/************/res.php on line 408 Notice: Undefined variable: pfname in /home/************/res.php on line 408 Notice: Undefined variable: pcity in /home/************/res.php on line 412 Notice: Undefined variable: pstate_province in /home/************/res.php on line 412 Notice: Undefined variable: pcountry in /home/************/res.php on line 412 $sqlName = mysql_query("SELECT username, firstname FROM myMembers WHERE id='$value' LIMIT 1") or die ("Sorry we had a mysql error!"); while ($row = mysql_fetch_array($sqlName)) { $passengerUserName = substr($row["username"],0,12); $passengerFirstName = substr($row["firstname"],0,12);} 362 if (!$passengerUserName) {$passengerUserName = $passengerFirstName;} // If username is blank use the firstname programming changes in v1.32 call for this if ($i % 6 == 4){ $passengerList .= '<tr><td><div style="width:106px; height:75px; overflow:hidden;" title="' . $passengerUserName . '"> <a href="res.php?id=' . $value . '">' . $passengerUserName . '</a><br />' . $psgr_pic . ' </div></td>'; } else { $passengerList .= '<td><div style="width:106px; height:75px; overflow:hidden;" title="' . $passengerUserName . '"> <a href="res.php?id=' . $value . '">' . $passengerUserName . '</a><br />' . $psgr_pic . ' </div></td>'; } } $passengerList .= '</tr></table> <div align="right"><a href="#" onclick="return false" onmousedown="javascript:toggleViewAllPassengers(\'view_all_passengers\');">View Manifest</a></div> </div>'; // END ASSEMBLE FRIEND LIST TO VIEW UP TO 6 ON PROFILE // ASSEMBLE FRIEND LIST AND LINKS TO VIEW ALL(50 for now until we paginate the array) $i = 0; $passengerArray50 = array_slice($passengerArray, 0, 50); $passengerPopBoxList = '<table id="passengerPopBoxTable" width="100%" align="left" cellpadding="6" cellspacing="0">'; foreach ($passengerArray50 as $key => $value) { $i++; // increment $i by one each loop pass $check_pic = 'tktedmembers/' . $value . '/image01.jpg'; if (file_exists($check_pic)) { $psgr_pic = '<a href="res.php?id=' . $value . '"><img src="' . $check_pic . '" width="54px" border="1"/></a>'; } else { $psgr_pic = '<a href="res.php?id=' . $value . '"><img src="tktedmembers/0/image01.jpg" width="54px" border="1"/></a> '; } $sqlName = mysql_query("SELECT username, firstname, country, state_province, city FROM myMembers WHERE id='$value' LIMIT 1") or die ("Sorry we had a mysql error!"); while ($row = mysql_fetch_array($sqlName)) { $puname = $row["username"]; $pfname = $row["firstname"]; $pcountry = $row["country"]; $pstate_province = $row["state_province"]; $pcity = $row["city"]; } 408 if (!$puname) {$puname = $pfname;} // If username is blank use the firstname programming changes in v1.32 call for this if ($i % 2) { $passengerPopBoxList .= '<tr bgcolor="#F4F4F4"><td width="14%" valign="top"> <div style="width:106px; height:65px; overflow:hidden;" title="' . $puname . '">' . $psgr_pic . '</div></td> 412 <td width="86%" valign="top"><a href="res.php?id=' . $value . '">' . $puname . '</a><br /><font size="-2"><em>' . $pcity . '<br />' . $pstate_province . '<br />' . $pcountry . '</em></font></td> </tr>'; Thanks, Scott Quote Link to comment Share on other sites More sharing options...
falkencreative Posted September 21, 2012 Report Share Posted September 21, 2012 Personally, I would try changing those lines to use isset() rather than simply checking if the variable is false. So, for example: Original: if (!$passengerUserName) Updated: if (!isset($passengerUserName)) Try that and let me know if that fixes it? Quote Link to comment Share on other sites More sharing options...
Scotty13 Posted September 21, 2012 Author Report Share Posted September 21, 2012 I added (!isset($passengerUserName)) on line 362 and it removed the first error(Notice: Undefined variable: passengerFirstName in /home/**************/res.php on line 362) other errors still remain. Thanks for your help, new to all this. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted September 21, 2012 Report Share Posted September 21, 2012 Correct -- so you need to make that same change for any other "undefined variable" errors, using "!isset()" rather than just "!" like my example above showed. Quote Link to comment Share on other sites More sharing options...
Scotty13 Posted September 22, 2012 Author Report Share Posted September 22, 2012 Like this? if(!isset($passengerUserName)){(!isset($passengerUserName)) = (!isset($passengerFirstName));} If so, dosnt work! Quote Link to comment Share on other sites More sharing options...
falkencreative Posted September 22, 2012 Report Share Posted September 22, 2012 No, you only need to change the if() portion, and only on the lines where you are running into undefined variable errors. Follow my example: Original: if (!$variable_name) Updated: if (!isset($variable_name)) Quote Link to comment Share on other sites More sharing options...
Scotty13 Posted September 22, 2012 Author Report Share Posted September 22, 2012 No, you only need to change the if() portion, and only on the lines where you are running into undefined variable errors. Follow my example: Original: if (!$variable_name) Updated: if (!isset($variable_name)) This is like Algebra, its there but I just dont see it. This is what I have... if(!isset($passengerUserName)) {(!isset($passengerUserName)) = (!isset($passengerFirstName;))} Quote Link to comment Share on other sites More sharing options...
falkencreative Posted September 22, 2012 Report Share Posted September 22, 2012 Your code if(!isset($passengerUserName)) {(!isset($passengerUserName)) = (!isset($passengerFirstName;))} needs to go back to if(!isset($passengerUserName)) { $passengerUserName = $passengerFirstName; } Take line 408, for example: if (!$puname) {$puname = $pfname;} you need to modify the if() portion to use isset() like so: if (!isset($puname)) {$puname = $pfname;} You don't need to change anything within the { ... } section. Anywhere you get the "undefined variable" error, you're probably having the same situation -- you are trying to access a variable that doesn't exist. Using isset() allows you to check if the variable is set and avoid those errors. 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.
Note: Your post will require moderator approval before it will be visible.