Welcome Guest, Not a member yet? Register   Sign In
get error when call store procedure update
#1

[eluser]teddy[/eluser]
I have simple store update

Code:
DELIMITER $$

CREATE  PROCEDURE update_post($post_id int(11),$title varchar(100))
BEGIN

set @query=concat('update tbl_posts set title=', $title);

set @where=concat(' where id=',$post_id);

set @query=concat(@query,@where);

   prepare stmt from @query;  
   execute stmt ;
   deallocate prepare stmt;

END
and I call it $this->db->query("call update_post('$post_id','$title')") but it working when $title is only have a word and without any blank space, someone help me pls, if have any blank space I will get it error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '222 1111 where id=204' at line 1

Thank for reading my topic
#2

[eluser]teddy[/eluser]
someone help me change this:
set @query=concat('update tbl_posts set title=', $title);
to set @query=concat('update tbl_posts set title=''', $title, '''');

but I want to know how to right use call store procedure and where is my problem, thank




Theme © iAndrew 2016 - Forum software by © MyBB