i know that there is alot of similar topics posted about similiar problems but none helped me in my case. I am creating an Insert form for table called product. I am passing data with POST method. This is the part that is giving me troubles. Since with POST you pass string values, I need to convert the id_category to INT because the type is set to INT in the database. The problem is that when i convert the string value to INT the value that is returned is 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 * FROM category ORDER BY 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']." ".$row['id_category']."</option>";
}
}
This is the part of the code that accepts the data and assigns it to 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 is on pastebin http://pastebin.com/d067ZpS8