私の人生では、この単純な挿入クエリを機能させることができないようです。
try {
// Connect to database
$dbh = new PDO("mysql:host=$host;dbname=$db", $user, $pass);
// Create an array of all data to be inserted
$data = array(':id' => 'null',
':name' => $name,
':location' => $loc,
':latitude' => $lat,
':longitude' => $lon,
':website' => $web,
':bandcamp' => $bandcamp,
':facebook' => $facebook,
':bio' => $bio,
':image' => $image,
':updated' => 'null');
// Create sql statement
$sql = 'INSERT INTO artists VALUES (:id, :name, :location, :latitude, :longitude, :website, :bandcamp, :facebook, :bio, :image, :updated)';
// Run query
$query = $dbh->prepare($sql);
$query->execute($data);
// Disconnect from database
$dbh = null;
}
catch(PDOException $e) {
echo $e->getMessage();
}
データがテーブルに挿入されず、エラー メッセージも表示されません。ここで何か不足していますか?