Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi guys,
I want to call stored procedure in mysql from php code - at first glance simple task, but I met huge problems. Maybe some of you could help me.
The code isCode: Select all
$sql = "call my_proc('".$_POST['a']."','".$_POST['b']."','".$_POST['c']."','".$_POST['d']."')";
mysql_query($sql);If i add echo $sql."<br>" - just to see the string generated, it looks ok -
Code: Select all
"call my_proc('value_for_a','value_for_b','value_for_c','value_for_d')"Code: Select all
mysql>call my_proc('value_for_a','value_for_b','value_for_c','value_for_d');The connection to mysql is ok, before trying to call the procedure, I have some insert, updates, select on the database and they work pretty well. But calling procedure fails - actually nothing happens.
I get the feeling, that I am missing some generic point. Do I need any settings or what else?
The procedure my_proc was created as root in test database. The connection to the database is also as root, so it shouldn't be a permission problem. I browsed the forums here and found out some examples, but it is exactly what I do -
Code: Select all
mysql_connect("localhost", "root", "password");
mysql_select_db("test");
$sql = "...";
mysql_query($sql);If $sql is something like "insert into foo values('foo')" - it works.
If $sql is "call myproc..." - it doesn't, no errors returned.
Any ideas?
Thanks in advance,
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]