简体   繁体   中英

phpmyadmin stored procedure error

I am trying to run SP in phpmyadmin web-hosting server but always getting following error

1064 - 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 '' at line 4

SP I am trying to run is:

CREATE PROCEDURE Authenticate_UserByEmailID(strUsername VARCHAR(45), strPassword VARCHAR(45))
BEGIN
    SELECT * FROM users 
    WHERE users.Username = strUsername AND users.Password = strPassword;
END $$

I tried putting single quotes in SP name, table name columns name and different other combinations with quotes but no result then I came across this link and tried changing delimiter but no result. can you please help on this.

Solution:

Sorry guys my bad. I added delimiter which solved the problem for me.

DELIMITER ;;

CREATE PROCEDURE `Authenticate_UserByEmailID`(strUsername VARCHAR(45), strPassword VARCHAR(45))
BEGIN
    SELECT * FROM DBCompany_samsonusac517644.users 
    WHERE Username = strUsername AND Password = strPassword;
END ;;

you miss the DELIMITER

mysql> delimiter $$
mysql> CREATE PROCEDURE Authenticate_UserByEmailID(strUsername VARCHAR(45), strPassword VARCHAR(45))
    -> BEGIN
    ->     SELECT * FROM users 
    ->     WHERE users.Username = strUsername AND users.Password = strPassword;
    -> END $$
Query OK, 0 rows affected (0.01 sec)

All the answers above are making certain assumptions. There are basic problems in 1and1 and certain other hosting providers are using phpMyAdmin versions which are very old and have an issue that defined delimiter is ; and there is no way to change it from phpMyAdmin. Some of the providers have moved on so they will not face this problem. but if you do then following are the ways -

  1. Create a new PHPMyAdmin on the hosting provider. Attached link gives you idea http://internetbandaid.com/2009/04/05/install-phpmyadmin-on-1and1/
  2. Go thru the complicated route of be able to access the your hosting providers mySQL from your dekstop. It is complicated but the best if you are a serious developer. here is a link to do it http://franklinstrube.com/blog/remote-mysql-administration-for-1and1/

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM