Enormity Posted December 15, 2010 Share Posted December 15, 2010 I am trying to make a setup file for a website I'm developing, and am having the database tables and stored procedures created automatically. However, I'm having issue getting the stored procedures to be created. Here is my code: $db->Q(" DELIMITER $$ CREATE PROCEDURE `Database`.`Procedure_Name`(in sp_uid mediumint(20) unsigned, in sp_user varchar(15), in sp_pass varchar(20), in sp_email varchar(30)) BEGIN Insert Into Table Values (sp_uid, sp_user, md5(sp_pass), sp_email, '1', '1', '0'); Select true; END$$ "); Assume that the "$db->Q()" works just fine, as I'm having issues no where else with it. This automatically connects to the database and runs a query with whatever is inside the "()". The tables are being created just fine, but no stored procedures are being created. I've tried everything I can think of, and googled my question many different ways without finding an answer or work-through. Does anyone know what I am doing wrong? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/221740-creating-a-stored-procedure-using-php/ Share on other sites More sharing options...
Adam Posted December 15, 2010 Share Posted December 15, 2010 That must be a custom DB package, does it have error handling at all? If not you should still be able to catch the error with mysql_error(), assuming it's MySQL and not MySQLi (which you'd just use the equivalent for). Find out the error message.. Quote Link to comment https://forums.phpfreaks.com/topic/221740-creating-a-stored-procedure-using-php/#findComment-1147621 Share on other sites More sharing options...
Enormity Posted December 15, 2010 Author Share Posted December 15, 2010 Yes, but the error is of no help. 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 'DELIMITER $$ CREATE PROCEDURE `U_C_D`.`Admin_Login_Create`(in sp_uid mediumin' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/221740-creating-a-stored-procedure-using-php/#findComment-1147773 Share on other sites More sharing options...
Enormity Posted December 15, 2010 Author Share Posted December 15, 2010 Well, I ended up fixing it... I just took out the delimiter... I don't know why that would work, or why I didn't try that before. The query looks like this now. $db->Q(" CREATE PROCEDURE `Database`.`Procedure_Name`(in sp_uid mediumint(20) unsigned, in sp_user varchar(15), in sp_pass varchar(20), in sp_email varchar(30)) BEGIN Insert Into Table Values (sp_uid, sp_user, md5(sp_pass), sp_email, '1', '1', '0'); Select true; END "); Quote Link to comment https://forums.phpfreaks.com/topic/221740-creating-a-stored-procedure-using-php/#findComment-1147776 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.