ขึ้นแบบนี้ครับ
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.....
นี่โค้ดครับ
function generateRandomString($length = 15) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
$photo=$_FILES['favicon']['tmp_name'];
$photo_name=$_FILES['favicon']['name'];
$photo_size=$_FILES['favicon']['size'];
$photo_type=$_FILES['favicon']['type'];
$name_last=explode(".", $photo_name);
$n=count($name_last)-1;
$lastname=strtolower($name_last[$n]);
if($lastname=="gif" or $lastname=="png" or $lastname=="jpg" or $lastname=="jpeg") {
$set_photo=explode(".", $photo_name);
$pfname= "" .generateRandomString(). "_fp";
$plname=$set_photo[1];
$photoname=$pfname ."." .$plname;
copy($photo, "../../uploads/" .$photoname);
unlink($photo);
$sql="REPLACE INTO site_os (SID, title, des, keys, favicon, google_anay ) VALUES ('' , '$_POST[title]', '$_POST[description]', '$_POST[keywords]', '$photoname', '$_POST[google_analytics]' )";
} else {
$sql="REPLACE INTO site_os (SID, title, des, keys, favicon, google_anay ) VALUES ('' , '$_POST[title]', '$_POST[description]', '$_POST[keywords]', '', '')";
}
$conn->set_charset("utf8");
if (mysqli_query($conn, $sql)) {
echo "success!";
header("location:../index.php");
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
ช่วยหน่อยครับ