php - Converting string to INT returns 0 -


i know there alot of similar topics posted similiar problems none helped me in case. creating insert form table called product. passing data post method. part giving me troubles. since post pass string values, need convert id_category int because type set int in database. problem when convert string value int value returned 0.

<form method="post" action="insert_product.php" enctype="multipart/form-data">     <table>         <tr>             <td>kategorija:</td> <td><select name="category" tabindex="1">     <option value="">odaberi kategoriju</option>  <?php     $sql="select * category order category_name";     $result=mysqli_query($connection,$sql) or die(mysql_error());     if(mysqli_num_rows($result)>0){         while($row=mysqli_fetch_assoc($result)){             echo "<option value='{".$row['id_category']."}'>".$row['category_name']."&nbsp;&nbsp;".$row['id_category']."</option>";         }     } 

this part of code accepts data , assigns varibles.

if(isset($_post['submit'])) {  $category=mysqli_real_escape_string($connection, $_post['category'];  $categoryint=intval($category);  $manufacturer=mysqli_real_escape_string($connection,$_post['manufacturer']);  $name=mysqli_real_escape_string($connection,$_post['name']);  $power=mysqli_real_escape_string($connection,$_post['power']);  $catalogue_number=mysqli_real_escape_string($connection,$_post['catalogue_number']);  $price=mysqli_real_escape_string($connection,$_post['price']);  $description=mysqli_real_escape_string($connection,$_post['description']);  $post_image=mysqli_real_escape_string($connection,$_files['image']['name']);  $image_tmp=mysqli_real_escape_string($connection,$_files['image']['tmp_name']); 

the table on pastebin http://pastebin.com/d067zps8

so, select boxes values come this:

"{2}" 

remove { , } in line starting this

echo "<option value='{".$row['id_category']."}'> 

so more like

echo "<option value='".$row['id_category']."'> 

that should work


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -