0
定义变量时出现未定义变量错误。波纹管是我的代码定义变量时出现未定义变量错误
<?php
$imagepath = $_SESSION['path'];
require_once('class-db.php');
if (!class_exists('INSERT')) {
class INSERT {
public function post($postdata) {
global $db;
$query = "
INSERT INTO posts (title, content, subcontent, date, category, image)
VALUES ('$postdata[title]', '$postdata[content]', '$postdata[subcontent]', '$postdata[date]', '$postdata[category]', '$imagepath')
";
return $db->insert($query);
}
}
}
$insert = new INSERT;
?>
你忘了告诉我们错误消息 –
** **警告你的代码很容易受到SQL注入攻击! –
'VALUES('$ postdata [title]','$ postdata [content]''不会起作用,必须是'VALUES('{$ postdata ['title']}','{$ postdata ['content']}''用于PHP正确解析数组。 – ceejayoz