我有一個網站(www.bbcurdu.com)。現在我的問題是,當我添加一個引入了引號或引號的新故事不保存在數據庫中時。如果我刪除這些逗號或引號,那麼它將保存在數據庫中。並正確取出並顯示結果。
在phpMyAdmin中,我在排序列中使用了utf8_unicode_ci(也嘗試過utf8_general_ci)。
任何機構請幫我解決這個問題。預先感謝。在烏爾都語中創建問題的引號(引號)
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<?php
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);
}else{
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);
}
<form method="POST" enctype="multipart/form-data" class="form-horizontal form-bordered form-row-stripped" name="Form1" id="form_sample_3">
<input type="hidden" value="<?php print_r(mt_rand()) ?>" name="uIDStory" />
<div class="page-content">
<!-- BEGIN PAGE HEADER-->
<h3 class="page-title">
Add New Story
</h3>
<div class="page-bar">
<ul class="page-breadcrumb">
<li>
<i class="fa fa-dashboard"></i>
<a href="dashboard.php">Dashboard</a>
<i class="fa fa-angle-right"></i>
</li>
<li>
Stories
<i class="fa fa-angle-right"></i>
</li>
<li>
Add New Story
</li>
</ul>
<div class="pull-right">
<button type="submit" class="btn btn-success" style="border-radius:0px !important" onclick="publishStory()"><i class="fa fa-send-o"></i> Publish</button>
<button type="submit" class="btn btn-info" style="border-radius:0px !important" onclick="draftStory()"><i class="fa fa-save"></i> Draft</button>
<!--<button type="submit" class="btn btn-primary" style="border-radius:0px !important" onclick="previewStory()"><i class="fa fa-eye"></i> Preview</button>-->
</div>
</div>
<!-- END PAGE HEADER-->
<!-- BEGIN PAGE CONTENT-->
<div class="row">
<div class="col-md-12">
<div class="alert alert-danger display-hide">
<button class="close" data-close="alert"></button>
You have some form errors. Please check below.
</div>
<?php if (isset($_GET["status"])) {
$status = $_GET["status"];
if($status == "success"){
echo "<div class='alert alert-success'>
<button class='close' data-close='alert'></button>
Story Has been publish successfuly.
</div> "
;}
;} ?>
<div class="portlet-body form">
<div class="portlet ">
<!-- BEGIN FORM-->
<div class="form-body">
<div class="form-group">
<label class="control-label col-md-2">Title <span class="required">*</span></label>
<div class="col-md-8">
<input type="text" class="form-control urdu" name="titleStory"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-2">Excerpt <span class="required">*</span></label>
<div class="col-md-8">
<textarea id="maxlength_textarea" class="form-control urdu" maxlength="180" rows="3" name="excerptStory"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<textarea class="summernote" name="storyStory"></textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-2">Catagory <span class="required">*</span></label>
<div class="col-md-8">
<select class="form-control select2_sample1 select3" name="catagory[]" multiple>
<optgroup label="Home">
<option value="HomeTop">Top</option>
<option value="HomeTopSlide1">Slide-1</option>
<option value="HomeTopSlide2">Slide-2</option>
<option value="HomeTopSlide3">Slide-3</option>
<option value="HomeTopSlide4">Slide-4</option>
<option value="HomeLatest1">Latest-1</option>
<option value="HomeLatest2">Latest-2</option>
<option value="HomeLatest3">Latest-3</option>
<option value="HomePakistan1">Pakistan-1</option>
<option value="HomePakistan2">Pakistan-2</option>
<option value="HomeWorld1">World-1</option>
<option value="HomeWorld2">World-2</option>
<option value="HomeSports1">Sports-1</option>
<option value="HomeSports2">Sports-2</option>
</optgroup>
<optgroup label="Pakistan">
<option value="PakistanTop">Pakistan-Top</option>
<option value="PakistanList">Pakistan</option>
</optgroup>
<optgroup label="World">
<option value="WorldTop">World-Top</option>
<option value="WorldList">World</option>
</optgroup>
<optgroup label="Sports">
<option value="SportsTop">Sports-Top</option>
<option value="SportsList">Sports</option>
</optgroup>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-2">Tags</label>
<div class="col-md-8">
<input type="hidden" class="form-control select2_sample3" name="tagsStory">
</div>
</div>
<!--<div class="form-group">
<label class="control-label col-md-2">Author</label>
<div class="col-md-8 component-mt-select"
data-mt-max-tags="9"
data-mt-request-method="POST"
data-mt-request-url="extraphp/search-response.php">
<input type="text" style="width:100% !important;" class="form-control" data-mt-filter-control/>
</div>
</div>-->
<div class="form-group">
<label class="control-label col-md-2">Date <span class="required">*</span></label>
<div class="col-md-8">
<div class="input-group input-medium date date-picker" data-date-format="dd-mm-yyyy" data-date-start-date="+0d">
<input type="text" class="form-control" readonly value="<?php echo date("d-m-Y")?>" name="dateStory">
<span class="input-group-btn">
<button class="btn btn-default" type="button"><i class="fa fa-calendar"></i></button>
</span>
</div>
</div>
</div>
<div class="form-group ">
<label class="control-label col-md-2">Image <span class="required">*</span></label>
<div class="col-md-8">
<div class="fileinput fileinput-new" data-provides="fileinput">
<div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px;">
</div>
<div>
<span class="btn btn-default btn-file">
<span class="fileinput-new">
Select image </span>
<span class="fileinput-exists">
Change </span>
<input type="file" name="imageStory">
</span>
<a class="fileinput-new btn btn-default" data-toggle="modal" href="#basic">
Link </a>
<a href="#" class="btn btn-danger fileinput-exists" data-dismiss="fileinput">
Remove </a>
</div>
<div class="modal fade" id="basic" tabindex="-1" role="basic" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
</div>
<div class="modal-body">
<div class="form-group" style="border:1px solid #EFEFEF; border-left:0px;">
<div class="col-md-12">
<input type="text" class="form-control" name="imagelinkStory" placeholder="http://"/>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Submit</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-2">Image caption <span class="required">*</span></label>
<div class="col-md-8">
<textarea id="maxlength_textarea2" class="form-control urdu" maxlength="35" rows="3" name="imagecaptionStory"></textarea>
</div>
</div>
</div>
<div class="form-actions">
<div class="row">
<div class="col-md-offset-3 col-md-9">
<button type="submit" class="btn btn-success" onclick="publishStory()"><i class="fa fa-send-o"></i> Publish</button>
<button type="submit" class="btn btn-info" onclick="draftStory()"><i class="fa fa-save"></i> Draft</button>
<!--<button type="submit" class="btn btn-primary" onclick="previewStory()"><i class="fa fa-eye"></i> Preview</a>-->
</div>
</div>
</div>
<!-- END FORM-->
</div>
</div>
</div>
</div>
<!-- END PAGE CONTENT-->
</div>
</div>
</form>
顯示一些示例數據以及你的代碼。 – Hassaan
嘗試使用implode()/ explode? – user5173426
爆裂花花公子沒有用法。 –