Help,
I've upgraded to MySQL 5 & PHP 5 so that I can use stored procedures.
I've successfully complied and tested (from the mysql command line) a stored procedure add_stuff.sql, which insert a value into a table (t1).
Here is the simple SP in the MySQL DB.
delimiter ~
create procedure add_stuff( IN inC1 text)
BEGIN
INSERT INTO t1 (c1) VALUES (inC1);
END ~
delimiter ;
From the MySQL command line I can issue the command: mysql> [FONT="Courier New"]call add_stuff('mike');[/FONT] and it works great.
So I wrote some PHP to test the call:
<?php # add_stuff.php
$conn = @mysqli_connect('localhost', 'miketest', 'mike', 'test1');
if (mysqli_connect_errno())
{
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$c1 = 'mike';
$result = @mysqli_query ($conn, 'call add_stuff($c1)');
if (mysqli_affected_rows($conn) == 1)
{
printf("Success");
}
else
{
printf("Errormessage Details: %s\n", mysqli_error($conn));
}
mysqli_close($conn);
?>
As you can see, I have not enclosed the variable $c1 in either single or double quotes in this version.
When I run this code I get this error: Errormessage Details: Unknown column '$c1' in 'field list'
So then I changed the call to 'call add_stuff('.$c1.') and I get the error: Errormessage Details: Unknown column 'mike' in 'field list'
I've been working with Oracle stored procedures for years, so I quite comfortable with the structure, but I'm lost when it comes to CALLING the SP from PHP.
What is the correct syntax used to include arguments in a call to a SP? What am I doing wrong? How do I pass an argument within a call statement?
Thanks