tags:

views:

352

answers:

4

I am firing a update query. Its working for one page and not working on other one. Can anybody take a look. thanks

 <br />
 <b>Fatal error</b>:  Uncaught exception 'Doctrine_Connection_Mysql_Exception' with         message 
'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not  match number of tokens' in 
 C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Connection.php:1084Stack trace:
#0 C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Connection\Statement.php(253): 
  Doctrine_Connection-&gt;rethrowException(Object(PDOException),         
  Object(Doctrine_Connection_Statement))
  #1 C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Connection.php(1049):      

   Doctrine_Connection_Statement-&gt;execute(Array)
    #2 C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Query\Abstract.php(1091):    

   Doctrine_Connection-&gt;exec('UPDATE users SE...', Array)
    #3 C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Query\Abstract.php(1142):   

    Doctrine_Query_Abstract-&gt;_execute(Array)

     #4 C:\xampp\htdocs\fanyer\doctrine\models\Users.php(122): Doctrine_Query_Abstract-
     &gt;execute()

   #5 C:\xampp\htdocs\fanyer\include\update_profile.inc.php(18): Users-
  &gt;update_coach_details('', '', NULL, 'Select', 'dav', 'coach', '3')

 #6 { in <b>C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Connection.php</b> on line   
    <b>1084</b><br />

EDIT: I am not able to identify where is the problem in parameter passing.. please take a look..

  public function update_coach_details($fname,$lname,$city,$state,$school,$rights,$user_id)
{
    return Doctrine_Query::create()
                ->update('Users')    
                ->set('f_name', '?', $fname)
                ->set('l_name', '?', $lname)
                ->set('city', '?', $city)
                ->set('state', '?', $state)
                ->set('school', '?', $school)
                ->set('rights', '?', $rights)
                ->where("id = '$user_id'")
                ->execute();     

}

        $account_type=$_SESSION['rights'];      
    $fname= $_POST['fname'];        
    $lname= $_POST['lname'];
    $state= $_POST['state'];        
    $school= $_POST['school'];
    $sports= $_POST['sports'];      
    $sports_array = explode(',',$sports);
    $user_id=$_SESSION['user_id'];
    $users= new Users();
        $users->update_coach_details($fname,$lname,$city,$state,$school,$account_type,$user_id);
A: 

The gist of it is that you have a prepared statement you are trying to execute, but you are not supplying one of the parameters needed.

But that's about all the information I can give you without seeing the actual query and calling code.

Eric Petroelje
A: 

Its working for one page and not working on other one.

What did you find when you compared those two pages usage of update_coach_details()? Could they have different number of parameters, as suggested by this error:

Invalid parameter number: number of bound variables does not  match number of tokens
Alex Brasetvik
A: 

The tokens are the part of the SQL query that are replaced from values passed to the function that executes the query (which, in this case are passed in an array); the error message says there are more tokens than values that should replace them.

kiamlaluno
+3  A: 

Looks like you are passing undefined variable $city to update_coach_details. Try to add something like $city = '' before function call.

Ivan Nevostruev
thnks i didint noticed that...
piemesons