Jump to content

php select option value undetectable


tayhaithian

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/141802-php-select-option-value-undetectable/
Share on other sites

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>

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()); 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.