I am having a heck of a time trying to figure out what is wrong with my query, and was not able to figure out. I have search the internet and S.O found few similar answers but none seems to work.
pLease see the attacked code and help me figure our what the problem is.
public function add_page($page=array()){
global $db;
//define page properties
$page_name = $page['page_name'];
$page_title= $page['page_title'];
$page_meta_description = $page['page_meta_description'];
$page_meta_keywords = $page['page_meta_keywords'];
$page_meta_other = $page['page_meta_other'];
$page_meta_other_2= $page['page_meta_other_2'];
$page_url = $page['page_url'];
$page_summary = $page['page_summary'];
$page_content = $page['page_content'];
$page_nav_item = $page['page_nav_item'];
$page_nav_name= $page['page_nav_name'];
$q="INSERT INTO `simplecms`.`pages` (`page_id`, `page_name`, `page_title`, `page_meta_description`, `page_meta_keywords`, `page_meta_other`, `page_other_2`, `page_url`, `page_summary`, `page_content`, `page_nav_item`, `page_nav_name`) VALUES ( ?, ?, ?, ?, ?, ? , ? , ?, ?, ?, ?)";
$query = $db->prepare($q);
$query->bindValue(1,$page_name);
$query->bindValue(2,$page_title);
$query->bindValue(3,$page_meta_description);
$query->bindValue(4,$page_meta_keywords );
$query->bindValue(5,$page_meta_other);
$query->bindValue(6,$page_meta_other_2);
$query->bindValue(7,$page_url );
$query->bindValue(8,$page_summary);
$query->bindValue(9,$page_content );
$query->bindValue(10,$page_nav_item);
$query->bindValue(11,$page_nav_name);
$query->execute();
$r=$query->rowCount();
echo $r;
//VALUES (NULL, 'Page Name', 'Page Title', 'Meta page description', 'google, ooogle ogle, userher', 'dymmy text qq', '', 'google.com', 'Small Summary', 'Ths is the big text', 'Yes', 'Google.com');
/*
$query= $db->prepare("INSERT INTO `pages`(`page_name`, `page_title`, `page_meta_description`, `page_meta_keywords`, `page_meta_other`, `page_other_2`, `page_url`, `page_summary`, `page_content`, `page_nav_item`, `page_nav_name`) VALUES (?,?,?,?,?,?,?,?,?,?,?)");
$query->execute(array(
$page_name,
$page_title,
$page_meta_description,
$page_meta_keywords,
$page_meta_other,
$page_meta_other_2,
$page_url,
$page_summary,
$page_content,
$page_nav_item,
$page_nav_name
));
$query->execute();
$row = $query->rowCount();
echo $row;*/
/*
$query = "INSERT INTO `pages`(
`page_name`,
`page_title`,
`page_meta_description`,
`page_meta_keywords`,
`page_meta_other`,
`page_meta_other_2`,
`page_url`,
`page_summary`,
`page_content`,
`page_nav_item`,
`page_nav_name`
) VALUES(
:name,
:title,
:desctription,
:keywords,
:meta1,
:meta2,
:url,
:summary,
:content,
:navitem,
:navname
)";
//VALUE(?,?,?,?,?,?,?,?,?,?,?)";
$q = $db->prepare($query);
$q->execute(array(
':name' =>$page_name,
':title' =>$page_title,
':desctription' =>$page_meta_description,
':keywords' =>$page_meta_keywords,
':meta1' =>$page_meta_other,
':meta2' =>$page_meta_other_2,
':url' =>$page_url,
':summary' =>$page_summary,
':content' =>$page_content,
':navitem' =>$page_nav_item,
':navname' =>$page_nav_name
));
*/
/*$q->bindValue(':name', $page_name, PDO::PARAM_STR);
$q->bindValue(':title', $page_title, PDO::PARAM_STR);
$q->bindValue(':desctription', $page_meta_description, PDO::PARAM_STR);
$q->bindValue(':keywords', $page_meta_keywords, PDO::PARAM_STR);
$q->bindValue(':meta1', $page_meta_other, PDO::PARAM_STR);
$q->bindValue(':meta2', $page_meta_other_2, PDO::PARAM_STR);
$q->bindValue(':url', $page_url, PDO::PARAM_STR);
$q->bindValue(':summary', $page_summary, PDO::PARAM_STR);
$q->bindValue(':content', $page_content, PDO::PARAM_STR);
$q->bindValue(':navitem', $page_nav_item, PDO::PARAM_STR);
$q->bindValue(':navname', $page_nav_name, PDO::PARAM_STR);
$q->execute();*/
/*$r = $q->rowCount();
if($r<1){
echo "Oops no article is added <pre>";
print_r($page);
echo "</pre>";
}else{
echo $r."Google";
}
*/
}
I have tried pretty much any/ all methods i could think off. I have browsed the internet for hours and is not working,
In the same class, i am able to select and fetch all data from the database, but inserting into the database has became a nightmare.
Please help.