Recently I'm trying to pass text boxes , radio buttons and checkboxes vaues to database. For that for the clear understanding I'll provide simple way of form.
<form method="post">
<input type="text" name="KKK"><br>
<input type="text" name="val[]"><br>
<input type="text" name="val[]"><br>
<input type="text" name="val[]"><br>
<input type="radio" class="form-check-input" value="new" name="val[]">New
<input type="radio" class="form-check-input" value="recondition" name="val[]">Reconditioned
<input type="radio" class="form-check-input" value="used" name="val[]">Used<br>
<select class="form-control" name="val[]">
<option>Convertible</option>
<option>Coupe / Sports</option>
<option>Hatchback</option>
<option>MPV</option><option>Saloon</option>
<option>Station Wagon</option>
<option>SUV / 4x4</option>
</select><br>
<input type="submit" name="sub" value="send !">
</form>
You see except first textbox other input elements' values should be pass through array. I echo those values without problem. So there is no error in form code. What I need is perform mysqli_real_escape_string function on 'val'. For that i used following php code snip..
<?php
require('./exec/connect.php');
if(isset($_POST['sub']))
{
$myarr[]=mysqli_real_escape_string($con,$_POST['val']);
for($i=0; $i<5; $i++){
//echo "The number is " . $_POST['val'][$i] . "<br>";
}
}
?>
In above I got error message saying that : Warning: mysqli_real_escape_string() expects parameter 2 to be string, array given
I really want to inspect code before it insert to database. I comented echo line because furthor I also wanted to help from you guys to insert read array to database as 6 rows.
Database table is structure is ID | values