CanMike Posted February 28, 2007 Share Posted February 28, 2007 Help, I've upgraded to MySQL 5 & PHP 5 so that I can use stored procedures. I've successfully and tested (from the mysql command line) a compile a stored procedure add_stuff.sql delimiter ~ create procedure add_stuff( IN inC1 text) BEGIN INSERT INTO t1 (c1) VALUES (inC1); END ~ delimiter ; 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 am I doing wrong? How do I pass an argument within a call statement? Thanks Link to comment https://forums.phpfreaks.com/topic/40583-call-mysql-stored-procedure-using-php50/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.