Tuesday 15 February 2011

stored procedures - Fatal error: Call to a member function execute() on a non-object ... in SQL SERVER SP PHP -


I'm having trouble adding the process stored from my SQL server to my PHP forms ... this tells me an error

Fatal Error: Execute Member Function () on a non-object ...

Please help with new help on SQL Server STORED PROCESS

My PHP code:

  & lt ;? Php $ serverName = "bongbong-pc"; $ Connection = array ("database" = & gt; "profit_investment"); $ Conn = sqlsrv_connect ($ serverName, $ connection); $ Btn = $ _ Post ['Button']; $ Fname = $ _POST ['fname']; $ Lname = $ _ post ['lname']; TRY {if ($ btn == 'LOGIN') {$ stmt = sqlsrv_prepare ($ conn, 'call insert_record (@fname, @lname)'); If (! $ Stmt) {Dead (print_a (true))); } $ Stmt- & gt; Execution (array ('@name' = & gt; $ fname, '@lname' = & gt; $ lname,)); Echo "& lt; script language = javascript & gt; warning ('account saved') "; }} Hold (PDOException $ E) {Print "Error !:" $ E- & gt; Received Message () "
"; Die (); }? & Gt;

Your problem is not in the stored procedure You use the resource as an object this is not right.

And there is no reason to use the prepared statement for only one query.

You need the next code:

  $ stmt = Sqlsrv_query ($ conn, 'EXCUTE insert_record @ fname = ?, @lname =?', Array ($ fname , $ Lname)); If ($ stmt === false) {die (print_as (sqlsrv_errors (), true)); }    

No comments:

Post a Comment