Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

pdo invalid parameter number exception

Codes here !

Moderators: macek, egami, gesf

pdo invalid parameter number exception

Postby adenjones » Tue May 07, 2013 5:32 pm

I am new to php and pdo.

I am trying to execute the following query

Code: Select all
//allow for confusion of first and surnames
      $qryMembers = $dbh->prepare("SELECT * FROM tbl_members
                    WHERE (fld_first_name LIKE concat('%', :FName, '%') AND fld_surname LIKE concat('%', :SName, '%')
                    OR fld_first_name LIKE concat('%', :SName, '%') AND fld_surname LIKE concat('%', :FName, '%'))
                    AND id_member <> :idMember
                           ");
$qryMembers->execute(array(':FName' => $strFName,
            ':SName' => $strSName,
                       ':idMember' => $_SESSION['idMember']
                            ));


And I am receiving the following error
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number' in D:\Websites\INB271Ass2\act\act_search_members.inc:38 Stack trace: #0 D:\Websites\INB271Ass2\act\act_search_members.inc(38): PDOStatement->execute(Array) #1 D:\Websites\INB271Ass2\www\index.php(108): include('D:\Websites\INB...') #2 {main} thrown in D:\Websites\INB271Ass2\act\act_search_members.inc on line 38

The problem seems to be with the :idMember parameter but I have checked that the variable $_SESSION['idMember'] exists and is initialised and it is. Any help would be greatly appreciated!
adenjones
New php-forum User
New php-forum User
 
Posts: 2
Joined: Tue May 07, 2013 5:25 pm

Re: pdo invalid parameter number exception

Postby adenjones » Tue May 07, 2013 6:00 pm

I actually ended up solving it myself

I was trying to use the same parameters twice and it was solved when I just created different parameters for the different parameter calls.
adenjones
New php-forum User
New php-forum User
 
Posts: 2
Joined: Tue May 07, 2013 5:25 pm


Return to mySQL & php coding

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.