Normal SQL'den PDO'ya geçiş yapıyorum çünkü herhangi bir zayıf nokta varsa benim bir arkadaşımın sınava girmesine izin verdim ve beni bir PDO'ya yönlendirdi Zayıf noktaların çokluğu. Yani buradaÖnemli hata: 'PDOException' iletisine sahip 'SQLSTATE [42000]
benim tam hatadır:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 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 ' in /home/ubuntu/workspace/post.php on line 54
(!) PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 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 '? (
id
,title
,info_bys
,info_shorts
,info_longs
,
Ve işte benim kodudur: SQL'de kullanmak ya da sadece yazarak duyuyorum I PDO'daki cant'kullanma şey
$stmt = $db->prepare("INSERT INTO :portal
(`id`, `title`, `info_bys`, `info_shorts`, `info_longs`, `email`, `filename`, `filepath`, `filename2`, `filepath2`, `approved`)
VALUES ('', ':title', ':by_information', ':short', ':long_information', ':email', ':filename', ':filetarget', ':filename2', ':filetarget2', 'false'");
$stmt->execute(array(':portal' => $portal, ':title' => $title, ':by_information' => $by_information, ':short' => $short, ':long_information' => $long_information, ':email' => $email, ':filename' => $fileName, ':filetarget' => $fileTarget, ':filename2' => $fileName2, ':filetarget2' => $fileTarget));
echo $affected_rows.' were affected';
var mı yanlış şeyler.
Birisi yardımcı olabilir umarım.
DÜZENLEME:
Yeni kod: koduyla
function buildQuery($get_var)
{
switch($get_var)
{
case 1:
$portal = $_POST['portal'];
break;
}
$stmt = $db->prepare("INSERT INTO :portal
(`id`, `title`, `info_bys`, `info_shorts`, `info_longs`, `email`, `filename`, `filepath`, `filename2`, `filepath2`, `approved`)
VALUES (:title, :by_information, :short, :long_information, :email, :filename, :filetarget, :filename2, :filetarget2, 'false'");
$stmt->execute(array(':portal' => $portal, ':title' => $title, ':by_information' => $by_information, ':short' => $short, ':long_information' => $long_information, ':email' => $email, ':filename' => $fileName, ':filetarget' => $fileTarget, ':filename2' => $fileName2, ':filetarget2' => $fileTarget));
echo $affected_rows.' were affected';
}
Tablo adları ciltlenemez. Bir beyaz listeyi ismiyle karşılaştırabiliyorsunuz, sonra sadece içeri aktarıyorsunuz. – chris85
Ow yea. Ben sadece aptal bir aptalım. Teşekkürler –