ashesbelow Posted March 3, 2007 Share Posted March 3, 2007 Im a n00b to PHP. i think ive pinned down the problem to the while loop condition, yet it is almost word for word of whats in the book im using. This is driving me nuts. Please help. Code: <?php> database connection lines removed /*gets clothing type from nuke_type_cloth table*/ $type_query="SELECT clothing_type FROM nuke_type_cloth ORDER by clothing_type"; $type_result = mysqli_query($cxn,$type_query); /*begin display form*/ echo "<p><form action='submit_new.php' method='POST'></p>\n"; /*display clothing type radio buttons*/ $counter = 0; while ($type_row = mysqli_fetch_assoc($type_result)) { extract($type_row); /*echo "in loop";*/ echo "<input type='radio' name='category' value='$clothing_type'"; if($counter == 0) { echo "checked"; } echo ">$clothing_type"; $counter++; } echo "<input type='radio' name='category' value='new'>"; echo "<input type='text' name='new_cat_name' size='20' maxlength='25'></td>\n"; /*display gender type*/ /*gets genders from nuke_sex_cloth table*/ $gender_query="SELECT gender FROM nuke_sex_cloth"; $gender_result = mysqli_query($cxn,$gender_query); /*display gender type radio buttons*/ $counter=0; while($gender_row = mysqli_fetch_assoc($gender_result)) { extract($gender_row); echo "<input type='radio' name='category' value='$gender_type'"; if($counter == 0) { echo "checked"; } echo ">$gender_type"; $counter++; } echo "<input type='submit' value='Add New Item'>\n"; echo "</form>\n"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/41053-wtf-is-wrong-with-my-while-loop/ Share on other sites More sharing options...
papaface Posted March 3, 2007 Share Posted March 3, 2007 well what error do you get. and use code tags please. Quote Link to comment https://forums.phpfreaks.com/topic/41053-wtf-is-wrong-with-my-while-loop/#findComment-198838 Share on other sites More sharing options...
pocobueno1388 Posted March 3, 2007 Share Posted March 3, 2007 Let me do this for you before I look through it. <?php //database connection lines removed /*gets clothing type from nuke_type_cloth table*/ $type_query="SELECT clothing_type FROM nuke_type_cloth ORDER by clothing_type"; $type_result = mysqli_query($cxn,$type_query); /*begin display form*/ echo "<p><form action='submit_new.php' method='POST'></p>\n"; /*display clothing type radio buttons*/ $counter = 0; while ($type_row = mysqli_fetch_assoc($type_result)) { extract($type_row); /*echo "in loop";*/ echo "<input type='radio' name='category' value='$clothing_type'"; if($counter == 0) { echo "checked"; } echo ">$clothing_type"; $counter++; } echo "<input type='radio' name='category' value='new'>"; echo "<input type='text' name='new_cat_name' size='20' maxlength='25'></td>\n"; /*display gender type*/ /*gets genders from nuke_sex_cloth table*/ $gender_query="SELECT gender FROM nuke_sex_cloth"; $gender_result = mysqli_query($cxn,$gender_query); /*display gender type radio buttons*/ $counter=0; while($gender_row = mysqli_fetch_assoc($gender_result)) { extract($gender_row); echo "<input type='radio' name='category' value='$gender_type'"; if($counter == 0) { echo "checked"; } echo ">$gender_type"; $counter++; } echo "<input type='submit' value='Add New Item'>\n"; echo "</form>\n"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/41053-wtf-is-wrong-with-my-while-loop/#findComment-198840 Share on other sites More sharing options...
pocobueno1388 Posted March 3, 2007 Share Posted March 3, 2007 Which while loop is not working? Quote Link to comment https://forums.phpfreaks.com/topic/41053-wtf-is-wrong-with-my-while-loop/#findComment-198843 Share on other sites More sharing options...
ashesbelow Posted March 4, 2007 Author Share Posted March 4, 2007 well i was trying to debug the first while loop by echoing "in loop" to see if it actually went into the loop but it doesnt. The second while loop is a duplicate of the first so that doesnt work either. Im not getting an error message, it just doesnt display anything to the browser. Quote Link to comment https://forums.phpfreaks.com/topic/41053-wtf-is-wrong-with-my-while-loop/#findComment-198866 Share on other sites More sharing options...
ashesbelow Posted March 4, 2007 Author Share Posted March 4, 2007 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/41053-wtf-is-wrong-with-my-while-loop/#findComment-199130 Share on other sites More sharing options...
Orio Posted March 4, 2007 Share Posted March 4, 2007 You probably have either an error with your query, or an empty/non-existent table. Anyway, change the line that runs the query to: $type_result = mysqli_query($cxn,$type_query) or die(mysqli_error()); If you get no errors, make sure you have records inside the nuke_type_cloth table. Orio. Quote Link to comment https://forums.phpfreaks.com/topic/41053-wtf-is-wrong-with-my-while-loop/#findComment-199132 Share on other sites More sharing options...
ashesbelow Posted March 4, 2007 Author Share Posted March 4, 2007 i tried putting that in and i get a blank page. How can i config php to give me errors instead of a blank page? I have verified the table does exist and i have put information into the table. Quote Link to comment https://forums.phpfreaks.com/topic/41053-wtf-is-wrong-with-my-while-loop/#findComment-199140 Share on other sites More sharing options...
Orio Posted March 4, 2007 Share Posted March 4, 2007 PHP should show most of errors (the more serious ones) unless you set it not to show them. If you want to see all of the errors, in the beginning of the script add this: error_reporting(E_ALL); Can you show the whole script (including the connection to the database)? Just replace the username, password, db-name etc' with "XXXXX". Maybe you have a problem in the beginning. Orio. Quote Link to comment https://forums.phpfreaks.com/topic/41053-wtf-is-wrong-with-my-while-loop/#findComment-199144 Share on other sites More sharing options...
ashesbelow Posted March 4, 2007 Author Share Posted March 4, 2007 Good call. I originally had included a file with the login information for security reasons but when i put the variables into the script itself it worked this time. Now i need to troubleshoot the second loop. Orio would you be interested in helping me get my website running? we can discuss specifics including $$ at my email address. You can find it in my profile. Quote Link to comment https://forums.phpfreaks.com/topic/41053-wtf-is-wrong-with-my-while-loop/#findComment-199145 Share on other sites More sharing options...
Orio Posted March 4, 2007 Share Posted March 4, 2007 Can't find your email. I've PMed you. Orio. Quote Link to comment https://forums.phpfreaks.com/topic/41053-wtf-is-wrong-with-my-while-loop/#findComment-199152 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.