spanner206 Posted December 3, 2013 Share Posted December 3, 2013 hopefully this will be the end of this little project but ive been trying to do this for a while now i need to get 2 different collumns one of which is hidden which will be the ID one has the value of the field e.g. test, im hopefully down to the last error. ( ! ) Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, boolean given in C:\wamp\www\AddLeads\addeadstemplate.php on line 254 Call Stack # Time Memory Function Location 1 0.0000 186408 {main}( ) ..\addeadstemplate.php:0 2 0.0156 194880 mysqli_fetch_row ( ) ..\addeadstemplate.php:254 <tr> <td>Type of Business:</td> <td> <select name="typeofbusiness"> <option value=''> - select type of business -</option> <?php $sql = "SELECT tbl_typesofbusiness.id, tbl_typesofbusiness.Agent FROM tbl_typesofbusiness"; $res = mysqli_query($con, $sql) or (mysqli_error($con)); while (list($id, $tob) = mysqli_fetch_row($res)); { echo "<option value='$id'>$tob</option>\n"; } ?> </select> </td> <td><span class="error">* <?php if (isset($errors['typeofbusiness'])) echo $errors['typeofbusiness']; ?></span></td> </tr> i can get rid of the error bie adding 'or die' on line 253 other than just or but what this does is stop everything under or die stops working cause ive got another 6 or 7 fields under type of business aswell as this no error occurs so im confused to hell, hopefully its not to complicated any help will be greatly appreciated Quote Link to comment Share on other sites More sharing options...
spanner206 Posted December 3, 2013 Author Share Posted December 3, 2013 O aswell no values are showing in the drop down box Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted December 3, 2013 Share Posted December 3, 2013 You forgot the "die" part. Try $res = mysqli_query($con, $sql) or die(mysqli_error($con)); Quote Link to comment Share on other sites More sharing options...
spanner206 Posted December 3, 2013 Author Share Posted December 3, 2013 yh ive tried that and for some reason everything under or die will stop working e.g. ive got about 5 -6 other fields under type of business and they will not appear, in the form. when i do this no error occurs aswell and still nothing is being pulled from the database any ideas??? Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted December 3, 2013 Share Posted December 3, 2013 you need to do a 'view source' of your page in your browser when it dies, because the php/mysql error message is inside of a html <select></select> tag and won't be displayed in the content on the page (another reason to separate your business logic from your presentation logic.) Quote Link to comment Share on other sites More sharing options...
spanner206 Posted December 3, 2013 Author Share Posted December 3, 2013 right ive done that and ive realised ive made the most rookie mistake ever by searching for the wrong table.... 3 DAYS IVE BEEN LOOKING AT THE SAME PROBLEM. anyway last problem the data is still not being pulled from the database into the drop down box any ideas? Quote Link to comment Share on other sites More sharing options...
spanner206 Posted December 3, 2013 Author Share Posted December 3, 2013 btw no errors are showing up Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted December 3, 2013 Share Posted December 3, 2013 what is your current php code and what is the resulting 'view source' of the <select> ... </select> section of the output in your browser? Quote Link to comment Share on other sites More sharing options...
spanner206 Posted December 3, 2013 Author Share Posted December 3, 2013 the view source is <select name="typeofbusiness"> <option value=''> - select type of business -</option> <option value=''></option> </select> so they is quite a bit missing this is my current code <td>Type of Business:</td> <td> <select name="typeofbusiness"> <option value=''> - select type of business -</option> <?php $sql = "SELECT tbl_typeofbusiness.id, tbl_typeofbusiness.Agent FROM tbl_typeofbusiness;"; $res = mysqli_query($con, $sql) or die (mysqli_error($con)); while (list($id, $tob) = mysqli_fetch_row($res)); { echo "<option value='$id'>$tob</option>\n"; } ?> </select> Quote Link to comment Share on other sites More sharing options...
Solution mac_gyver Posted December 3, 2013 Solution Share Posted December 3, 2013 you have an errant semi-colon ; that is terminating the while(){} loop - while (list($id, $tob) = mysqli_fetch_row($res)); { that line should be - while (list($id, $tob) = mysqli_fetch_row($res)){ Quote Link to comment Share on other sites More sharing options...
spanner206 Posted December 4, 2013 Author Share Posted December 4, 2013 god im crap at this thank you so much for pointing that out mac_gyver Quote Link to comment Share on other sites More sharing options...
spanner206 Posted December 4, 2013 Author Share Posted December 4, 2013 o yh and how would i double check if the id is hidden Quote Link to comment Share on other sites More sharing options...
waynew Posted December 4, 2013 Share Posted December 4, 2013 You forgot the "die" part. Try $res = mysqli_query($con, $sql) or die(mysqli_error($con)); You should be recommending trigger_error instead of die. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted December 4, 2013 Share Posted December 4, 2013 since using or die() or or trigger_error() doesn't address the execution path the code takes when there is an error, unless you want your code to die() or use E_USER_ERROR with trigger_error(), using an or die() or or trigger_error() are only best used for troubleshooting purposes and it doesn't really matter which one you use in that case. actual code needs to address the execution path that is taken when there is an error, either through conditional logic or by using exceptions. 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.