你好,我是新來的PDO所以越來越一頭霧水,得到錯誤),其具有mysql_real_escape_string ..mysql_real_escape_string與PDO PHP
任何一個可以幫助,這裏是我的代碼
if(!empty($_POST) && isset($_POST)) {
include ('connection_pdo.php');
$dbh = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
$source_url= mysql_real_escape_string($_POST['source_url']);
$class = mysql_real_escape_string($_POST['class']);
$year = mysql_real_escape_string($_POST['year']);
$date = time();
$ip = $_SERVER['REMOTE_ADDR'];
$insert = $dbh->prepare("
INSERT IGNORE INTO school_students_images
(folder_name, image_url, source_url, class, year , date , ip)
VALUES (:folder_name, :image_url, :source_url, :class, :year, :date, :ip)
");
$a=0;
while ($a<1000){
$a++;
$insert->execute(array(
'folder_name'=> $name->content, //** geting from other source
'image_url' => $link[$a], //** geting from other source
'source_url' => $source_url,
'class' => $class ,
'year' => $year ,
'date' => $date,
'ip' => $ip
));
}
它不工作得到錯誤但如果我使用它與出
$source_url= ($_POST['source_url']);
$class = ($_POST['class']);
$year = ($_POST['year']);
$date = time();
$ip = $_SERVER['REMOTE_ADDR'];
它正在工作......所以我很困惑是安全的POST沒有mysql_real_escape_string到數據庫中? (PDO默認提供任何安全性?)或者我在這裏做一些錯誤... 請幫忙