SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Creating a stored procedure using PHP

    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:
    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.

  2. #2
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, 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

  3. #3
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

    Code:
    $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
    ");


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •