hi im trying to insert data in mysql using array, can someone please look at my code, i cant seem to make it work.
this is my post.php
/* POST.PHP */
$p
Construct the array with a key and a value
$myarray = array("id"=>'',"title"=>$title,"body"=>$body,"pid"=>$rowId);
and Use PDO instead of mysql_* functions (depreciated).
$sql=$dbh->prepare("INSERT INTO `posts`(`id`, `title`, `body`, `post_id`) VALUES (:id,:title,:body,:pid)");
foreach($myarray as $row=>$value){
$sql->bindValue(":".$row,$value);
}
$sql->execute();
More About PDO : http://www.php.net/manual/en/book.pdo.php