I have the below mysql statement:
INSERT INTO rates_try (`Weight`, `length`, `height`, `Min`, `100`, `200`, `300`) VALUES (1000,0.1,2.3,1,2,3,4);
Which gives the error:
No Row created. Check 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 'insertquery' at line 1INSERT INTO rates_try (
Weight
,length
,height
,Min
,100
,200
,300
) VALUES (1500,2.31,3.5,1,0,0,0);
The table structure is:
rates_try ( `Weight` int(11),
`length` double,
`height` double,
`Min` double,
`100` double,
`200` double,
`300` double )
I am not sure what is wrong with the syntax and I know it most likely have something to do with the columns being numbers, if this is the issue causing it I will have to add something to the names so they are not just numbers, but I wanted to check that this was not the case first.
THe php code that creates the statement
$insertquery = "INSERT INTO rates_{$tablename} (`Weight`, `length`, `height`, `Min`";
foreach ($titles as $title){
if (empty($title) ){
}else{
$insertquery .= ", `" . $title . "`";
$counter++;
}
}
$insertquery .= ") VALUES (".$row['weight'].",".$row['cbm_min'].",".$row['cbm_max'].",".$value;
$a = 0;
while ($a < $counter){
$newvalue = $array[$a][$i];
if (empty($newvalue)){
$newvalue = 0;
}
$insertquery .= ",". $newvalue;
$a++;
}
$insertquery .= ");";
echo $insertquery. "<br/>";
$queryResult = mysqli_query($con, insertquery);