tayhaithian Posted January 21, 2009 Share Posted January 21, 2009 i have a few selection <select name=bla > <option selected value="Null">---</option> <option value="drink">Drink</option> <option value="desert">Desert</option> after submit the form and trying to achieve 'bla' with several try still fail any idea ? tried with this $_POST['bla'] , $_POST[$bla] , $_POST["bla] ... no result Quote Link to comment https://forums.phpfreaks.com/topic/141802-php-select-option-value-undetectable/ Share on other sites More sharing options...
jjacquay712 Posted January 21, 2009 Share Posted January 21, 2009 is the form using get or post? if thats not your problem, its the html. Quote Link to comment https://forums.phpfreaks.com/topic/141802-php-select-option-value-undetectable/#findComment-742377 Share on other sites More sharing options...
tayhaithian Posted January 21, 2009 Author Share Posted January 21, 2009 using method=post Quote Link to comment https://forums.phpfreaks.com/topic/141802-php-select-option-value-undetectable/#findComment-742379 Share on other sites More sharing options...
jjacquay712 Posted January 21, 2009 Share Posted January 21, 2009 Then its a problem with your html. Go to W3 Schools for a tutorial. Quote Link to comment https://forums.phpfreaks.com/topic/141802-php-select-option-value-undetectable/#findComment-742383 Share on other sites More sharing options...
Mark Baker Posted January 21, 2009 Share Posted January 21, 2009 <select name="bla"> Quote Link to comment https://forums.phpfreaks.com/topic/141802-php-select-option-value-undetectable/#findComment-742389 Share on other sites More sharing options...
tayhaithian Posted January 21, 2009 Author Share Posted January 21, 2009 yea solved but now it couldnt store into ... Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'jpg, asd)' at line 2 partly of the code : $newname="food/".$image_name; $name = $_POST['name']; $type = $_POST['bla']; $price_reg = $_POST['price_reg']; $price_large = $_POST['price_large']; $description = $_POST['description']; mysql_query("INSERT INTO `foodsys`.`foods` (`food_id`, `name`, `type`, `price_reg`, `price_large`, `image`, `description`) VALUES('', $name , $type, $price_reg, $price_large, $newname, $description)")or die(mysql_error()); <html> <?php echo '<form method="post" enctype="multipart/form-data" action="add_record.php">'; echo '<table border=1>'; echo '<tr>'; echo '<td width="130px">Name </td><td width="200px"><input type="text" name="name" size=20 /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Type </td><td><select name="bla" >'; echo '<option selected value="Null">---</option>'; echo '<option value="food">Food</option>'; echo '<option value="drink">Drink</option>'; echo '<option value="desert">Desert</option>'; echo '</select></td>'; echo '</tr>'; echo '<tr>'; echo '<td > Price Regular </td><td ><input type="text" name="price_reg" size=4 /></td>'; echo '</tr><tr>'; echo '<td> Price Large </td><td><input type="text" name="price_large" size=4 /></td>'; echo '</tr>'; echo '<tr>'; echo '<td> Image </td><td><input type="file" name="image" value="Browse" /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Description </td><td><textarea name="description" rows="5" cols="20" ></textarea></td>'; echo '</tr>'; echo '<tr >'; echo '<td colspan="5" align="center"><input type="submit" name="Submit" value="Add New Record"></td>'; echo '</tr>'; echo '</table>'; echo '</form>'; ?> </html> Quote Link to comment https://forums.phpfreaks.com/topic/141802-php-select-option-value-undetectable/#findComment-742399 Share on other sites More sharing options...
Philip Posted January 21, 2009 Share Posted January 21, 2009 Always put single quotes around values: mysql_query("INSERT INTO `foodsys`.`foods` (`food_id`, `name`, `type`, `price_reg`, `price_large`, `image`, `description`) VALUES('', $name , $type, $price_reg, $price_large, $newname, $description)")or die(mysql_error()); To: mysql_query("INSERT INTO `foodsys`.`foods` (`food_id`, `name`, `type`, `price_reg`, `price_large`, `image`, `description`) VALUES ('', '$name' , '$type', '$price_reg', '$price_large', '$newname', '$description')")or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/141802-php-select-option-value-undetectable/#findComment-742408 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.