Page 1 of 1

Invalid Parameter Number - PDO

Posted: Fri Mar 07, 2014 12:36 pm
by chris98
I'm trying to create a better search query from another topic that searches the article content and title but it returns:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number' in /home/directories/:110 Stack trace: #0 /home/directories/(110): PDOStatement->execute(Array) #1 {main} thrown in /home/directories/ on line 110

Code: Select all

$count = "SELECT COUNT(*) AS id FROM pages WHERE title LIKE :search AND sub_page != 'sub_sub_page' AND site = :site OR text LIKE :search AND site = :site AND sub_page != 'sub_sub_page'";
	$shn_sites->setAttribute(PDO::ATTR_EMULATE_PREPARES, FALSE);
	$ps = $shn_sites->prepare($count);
	$ps->execute(array( 
	':search'=>'%' . $search_results . '%',
	':site'=>$site));
EDIT: Never mind, I used different parameters and it worked. I don't know why though.