$username Posted October 6, 2007 Share Posted October 6, 2007 Hello Guys, I am having issues with this drop down box look up from MYSQL. Here is the error Notice: Undefined variable: row in c:\web\www\app\addmember.php on line 58 Notice: Undefined variable: row in c:\web\www\app\addmember.php on line 59 these are the lines it errors out on while ($row = mysql_fetch_assoc($result)) { echo \"<option value=\"{$row['UserType']}</option>\"; <?PHP $sql = \"SELECT UserType FROM values \"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { echo \"<option value=\"{$row['UserType']}</option>\"; } } } ?> Thanks, Brett Quote Link to comment https://forums.phpfreaks.com/topic/72125-solved-need-php-code-checked/ Share on other sites More sharing options...
darkfreaks Posted October 6, 2007 Share Posted October 6, 2007 you need to define $row as $row=mysql_num_rows($result); Quote Link to comment https://forums.phpfreaks.com/topic/72125-solved-need-php-code-checked/#findComment-363594 Share on other sites More sharing options...
$username Posted October 6, 2007 Author Share Posted October 6, 2007 Can you be more specific on where I would add $row=mysql_num_rows($result); This would be over written by this line of code while ($row = mysql_fetch_assoc($result)) { Thank you, Brett Quote Link to comment https://forums.phpfreaks.com/topic/72125-solved-need-php-code-checked/#findComment-363598 Share on other sites More sharing options...
darkfreaks Posted October 6, 2007 Share Posted October 6, 2007 that line of code needs to be also defined before the while statement or it will error undefined row Quote Link to comment https://forums.phpfreaks.com/topic/72125-solved-need-php-code-checked/#findComment-363599 Share on other sites More sharing options...
darkfreaks Posted October 6, 2007 Share Posted October 6, 2007 you need <?php $row=mysql_num_rows($result); while ($row = mysql_num_rows($result,MYSQL_ASSOC)){ ?> Quote Link to comment https://forums.phpfreaks.com/topic/72125-solved-need-php-code-checked/#findComment-363602 Share on other sites More sharing options...
darkfreaks Posted October 6, 2007 Share Posted October 6, 2007 <?php $row=mysql_fetch_array($result,MYSQL_ASSOC); while ($row = mysql_fetch_array($result,MYSQL_ASSOC)){ ?> my bad Quote Link to comment https://forums.phpfreaks.com/topic/72125-solved-need-php-code-checked/#findComment-363607 Share on other sites More sharing options...
emehrkay Posted October 6, 2007 Share Posted October 6, 2007 also this is incorrect, unnecessary backslashes and it is incomplete html echo \"<option value=\"{$row['UserType']}</option>\"; I prefer concatenation, like this echo "<option value=\"". $row['UserType'] ."\">". $row['UserType'] ."</option>"; Quote Link to comment https://forums.phpfreaks.com/topic/72125-solved-need-php-code-checked/#findComment-363611 Share on other sites More sharing options...
$username Posted October 7, 2007 Author Share Posted October 7, 2007 I re-did the why I am using PHP and HTML. So it works for now. Thank you, Brett Quote Link to comment https://forums.phpfreaks.com/topic/72125-solved-need-php-code-checked/#findComment-363670 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.