我有一个类似 ( www.bbcurdu.com) 的网站。现在我的问题是,当我添加一个带有引号或引号的新故事时,它不会保存在数据库中。如果我删除这些逗号或引号,那么它将保存在数据库中。并正确获取和显示结果。
在 phpMyAdmin 中,我在整理列中使用 utf8_unicode_ci(也尝试过 utf8_general_ci).
任何机构请帮我解决这个问题。提前致谢。
include 'config.php';
$uIDStory = $_POST["uIDStory"];
$title = $_POST['titleStory'];
$excerpt = $_POST['excerptStory'];
$story = $_POST['storyStory'];
$catagory = $_POST['catagory'];
$tags = $_POST['tagsStory'];
//$author = $_POST['authorStory'];
$date = $_POST['dateStory'];
$imagecaption =$_POST['imagecaptionStory'];
$imagelinkStory =$_POST['imagelinkStory'];
$imageStory = $_FILES["imageStory"];
$catagory2 = implode(",", $catagory);
/*if(!empty($author)){
$author2 = implode(",", $author);
}*/
$name = preg_replace("/[^A-Z0-9._-]/i", "_", $imageStory["name"]);
$uploaded_img_save = "../../../i/story/uploaded/";
if(isset($imageStory) && empty($imagelinkStory)){
if(file_exists($uploaded_img_save.$name)){
$actual_name = pathinfo($name,PATHINFO_FILENAME);
$original_name = $actual_name;
$extension = pathinfo($name, PATHINFO_EXTENSION);
$i = 1;
while(file_exists($uploaded_img_save .$actual_name.".".$extension)){
$actual_name = (string)$original_name.$i;
$re_name = $actual_name.".".$extension;
$i++;
}
move_uploaded_file($_FILES["imageStory"]["tmp_name"], $uploaded_img_save.$re_name);
$large_img_save = "../../../i/story/825x500/";
list( $imageWidth, $imageHeight ) = getimagesize( $uploaded_img_save.$re_name );
$resampledImage = imagecreatetruecolor( 825, 500 );
$source = imagecreatefromjpeg( $uploaded_img_save.$re_name );
imagecopyresampled($resampledImage, $source, 0,0,0,0,825,500,$imageWidth,$imageHeight);
ob_start();
imagejpeg( $resampledImage, null, 100 );
$imageContent = ob_get_clean();
file_put_contents( $large_img_save.$re_name, $imageContent );
$large_img_save = "../../../i/story/630x382/";
list( $imageWidth, $imageHeight ) = getimagesize( $uploaded_img_save.$re_name );
$resampledImage = imagecreatetruecolor( 630, 382 );
$source = imagecreatefromjpeg( $uploaded_img_save.$re_name );
imagecopyresampled($resampledImage, $source, 0,0,0,0,630,382,$imageWidth,$imageHeight);
ob_start();
imagejpeg( $resampledImage, null, 100 );
$imageContent = ob_get_clean();
file_put_contents( $large_img_save.$re_name, $imageContent );
$large_img_save = "../../../i/story/180x109/";
list( $imageWidth, $imageHeight ) = getimagesize( $uploaded_img_save.$re_name );
$resampledImage = imagecreatetruecolor( 180, 109 );
$source = imagecreatefromjpeg( $uploaded_img_save.$re_name );
imagecopyresampled($resampledImage, $source, 0,0,0,0,180,109,$imageWidth,$imageHeight);
ob_start();
imagejpeg( $resampledImage, null, 100 );
$imageContent = ob_get_clean();
file_put_contents( $large_img_save.$re_name, $imageContent );
$largelink="http://i.example.net/story/825x500/".$re_name;
$mediumlink="http://i.example.net/story/630x382/".$re_name;
$thumblink="http://i.example.net/story/180x109/".$re_name;
$sql="INSERT INTO story (uIDStory,titleStory,excerptStory,storyStory,catagory,tagsStory,dateStory,imagecaptionStory,thumbStory,topimageStory,imageStory) VALUES ('". $uIDStory ."','". $title ."','". $excerpt ."','". $story ."','". $catagory2 ."','". $tags ."','". $date ."','". $imagecaption ."','". $thumblink ."','". $mediumlink ."','". $largelink ."')";
mysqli_query($con,$sql);
header("location: ../story-edit-publish.php?ID=".$uIDStory);
}khác{
move_uploaded_file($_FILES["imageStory"]["tmp_name"], $uploaded_img_save.$name);
$large_img_save = "../../../i/story/825x500/";
list( $imageWidth, $imageHeight ) = getimagesize( $uploaded_img_save.$name );
$resampledImage = imagecreatetruecolor( 825, 500 );
$source = imagecreatefromjpeg( $uploaded_img_save.$name );
imagecopyresampled($resampledImage, $source, 0,0,0,0,825,500,$imageWidth,$imageHeight);
ob_start();
imagejpeg( $resampledImage, null, 100 );
$imageContent = ob_get_clean();
file_put_contents( $large_img_save.$name, $imageContent );
$large_img_save = "../../../i/story/630x382/";
list( $imageWidth, $imageHeight ) = getimagesize( $uploaded_img_save.$name );
$resampledImage = imagecreatetruecolor( 630, 382 );
$source = imagecreatefromjpeg( $uploaded_img_save.$name );
imagecopyresampled($resampledImage, $source, 0,0,0,0,630,382,$imageWidth,$imageHeight);
ob_start();
imagejpeg( $resampledImage, null, 100 );
$imageContent = ob_get_clean();
file_put_contents( $large_img_save.$name, $imageContent );
$large_img_save = "../../../i/story/180x109/";
list( $imageWidth, $imageHeight ) = getimagesize( $uploaded_img_save.$name );
$resampledImage = imagecreatetruecolor( 180, 109 );
$source = imagecreatefromjpeg( $uploaded_img_save.$name );
imagecopyresampled($resampledImage, $source, 0,0,0,0,180,109,$imageWidth,$imageHeight);
ob_start();
imagejpeg( $resampledImage, null, 100 );
$imageContent = ob_get_clean();
file_put_contents( $large_img_save.$name, $imageContent );
$largelink="http://i.example.net/story/825x500/".$name;
$mediumlink="http://i.example.net/story/630x382/".$name;
$thumblink="http://i.example.net/story/180x109/".$name;
$sql="INSERT INTO story (uIDStory,titleStory,excerptStory,storyStory,catagory,tagsStory,dateStory,imagecaptionStory,thumbStory,topimageStory,imageStory) VALUES ('". $uIDStory ."','". $title ."','". $excerpt ."','". $story ."','". $catagory2 ."','". $tags ."','". $date ."','". $imagecaption ."','". $thumblink ."','". $mediumlink ."','". $largelink ."')";
mysqli_query($con,$sql);
header("location: ../story-edit-publish.php?ID=".$uIDStory);
};
}elseif (isset($imagelinkStory)) {
$url = $imagelinkStory;
$info = new SplFileInfo($url);
$file_extension = $info->getExtension();
$img = uniqid().".".$file_extension;
file_put_contents($uploaded_img_save.$img, file_get_contents($info));
list( $imageWidth, $imageHeight ) = getimagesize( $url );
$resampledImage = imagecreatetruecolor( 825, 500 );
$source = imagecreatefromjpeg( $url );
imagecopyresampled($resampledImage, $source, 0,0,0,0,825,500,$imageWidth,$imageHeight);
ob_start();
imagejpeg( $resampledImage, null, 100 );
$imageContent = ob_get_clean();
file_put_contents("../../../i/story/825x500/".$img, $imageContent );
list( $imageWidth, $imageHeight ) = getimagesize( $url );
$resampledImage = imagecreatetruecolor( 630, 382 );
$source = imagecreatefromjpeg( $url );
imagecopyresampled($resampledImage, $source, 0,0,0,0,630,382,$imageWidth,$imageHeight);
ob_start();
imagejpeg( $resampledImage, null, 100 );
$imageContent = ob_get_clean();
file_put_contents("../../../i/story/630x382/".$img, $imageContent );
list( $imageWidth, $imageHeight ) = getimagesize( $url );
$resampledImage = imagecreatetruecolor( 180, 109 );
$source = imagecreatefromjpeg( $url );
imagecopyresampled($resampledImage, $source, 0,0,0,0,180,109,$imageWidth,$imageHeight);
ob_start();
imagejpeg( $resampledImage, null, 100 );
$imageContent = ob_get_clean();
file_put_contents("../../../i/story/180x109/".$img, $imageContent );
$largelink="http://i.example.net/story/825x500/".$img;
$mediumlink="http://i.example.net/story/630x382/".$img;
$thumblink="http://i.example.net/story/180x109/".$img;
$sql="INSERT INTO story (uIDStory,titleStory,excerptStory,storyStory,catagory,tagsStory,dateStory,imagecaptionStory,thumbStory,topimageStory,imageStory) VALUES ('". $uIDStory ."','". $title ."','". $excerpt ."','". $story ."','". $catagory2 ."','". $tags ."','". $date ."','". $imagecaption ."','". $thumblink ."','". $mediumlink ."','". $largelink ."')";
mysqli_query($con,$sql);
header("location: ../story-edit-publish.php?ID=".$uIDStory);
}
Tôi là một lập trình viên xuất sắc, rất giỏi!