Jump to content

question about create stored procedures

- - - - -

  • Please log in to reply
2 replies to this topic

#1
dadli

dadli

    Newbie

  • Members
  • PipPip
  • 12 posts
hello
i need create stored procedures (in mysql), but This is what happens: if i trying create procedure using php file, output is error:


Quote

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 `procpros`(OUT ppp VARCHAR(70)) NOT DETERMIN' at line 1
this is my php file:

include 'dbconnect.php';

mysqli_query($db,

"DELIMITER //

CREATE PROCEDURE `procpros`(OUT ppp VARCHAR(70))

   NOT DETERMINISTIC

   SQL SECURITY INVOKER

   COMMENT ''

BEGIN

SELECT shemos_dro INTO ppp FROM online WHERE ipadres = 55 LIMIT 1;

END;//

DELIMITER ;

")or die(mysqli_error($db));


but if, i trying create procedure using phpmyadmin (if I run this sql query in phpmyadmin) all its good, procedure is creating successfully, tell me please why this happened? create procedure using the php file can not ? Thanks

#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#
The problem is that mysqli_query only allows one command to the server at a time, you make three. Two delimiter and one create procedure
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#3
dadli

dadli

    Newbie

  • Members
  • PipPip
  • 12 posts
Orjan, thanks very much :)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users