Forum Moderators: coopster

Message Too Old, No Replies

Problems Calling Stored Procedure

Error when calling stored procedure with PHP

         

Hyperbolik

10:21 pm on Oct 19, 2008 (gmt 0)

10+ Year Member



I'm just getting used to using stored procedures with PHP and I seem to be having some syntax issues. Here is my current call:

$result = mysqli_query($dbcnx, "CALL sp_EditCompanyItem('$userName','$remoteIP','$userAgent','$_GET[id]','$fieldname','$content')") or die ("An error occurred!: " . mysqli_error($dbcnx));

The stored procedure looks like this:

BEGIN
SET @strQuery = CONCAT('UPDATE Companies SET ', $field_name, ' = \'', $field_value, '\' WHERE ID = ', $cmp_id, ';');

PREPARE strQuery FROM @strQuery;
EXECUTE strQuery;

INSERT INTO Journal
(
journalDT,
UserID,
IPAddress,
Browser,
Message
)
VALUES
(
NOW(),
$user_id,
$ipAddress,
$browser,
CONCAT('Updated Company ', $field_name, ' to "', $field_value, '" for Company "', $cmp_id, '"')
);

SELECT $cmp_id AS 'companyID';
END

The error I'm getting when attempt to call this procedure is: An error occurred!: 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 '= '' WHERE ID = 1' at line 1

To me this looks like a simple syntax issue but I can't seem to figure out exactly where it is. Any ideas?

omoutop

9:56 am on Oct 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



my bad... thought i saw a typpo