I've been trying to get some data to input to my sqli database using php..
Looking at the insert queries when I do it by GUI on PHPMyAdmin the variables need to be wrapped in single quotes..
This is how I am building the query so far:
$fields = array('`appName`' => $_POST[appName],
'`appDescription`' => $_POST[appDescription],
'`UploadDate`' => date("Y-m-d"),
'`appWebsite`' => $_POST[appWebsite]);
printarray($fields);
print "<br>";
print "<br>";
$columns = implode(", ",array_keys($fields));
$escaped_values = array_map('mysql_real_escape_string', array_values($fields));
$values = implode(", ", $escaped_values);
$sql = "INSERT INTO `applist`.`apps` ($columns) VALUES ($values)";
print $sql;
print "<br>";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error";
}
This is giving me the query like so..
INSERT INTO `applist`.`apps` (`appName`, `appDescription`, `UploadDate`, `appWebsite`)
VALUES (SDD, DDD, 2017-06-02, DDDD)
How do I get the values of the array wrapped in single quotes?
Any help appreciated.