Click here to Skip to main content
12,302,084 members (55,126 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: PHP MySQL
Im creating a stored procedure in phpmyadmin, which get the event category list. The condition im using, im sending a parameter 'e_range' where i get the list on the basis of whatever i set the range on this parameter 3, 4 etc. but im getting an error in while executing this script:

#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 'e_range; else select category_id, category_name, category_thumb from category' at line 4

CREATE PROCEDURE `sp_category_list`(IN e_range int)
BEGIN
if(e_range != 0) then
    select category_id, category_name, category_thumb from category_list order by category_name limit e_range;
else
    select category_id, category_name, category_thumb from category_list order by category_name;
END if;
END$$

Now problem is that, this script working good in my localhost pc. but im getting these error on my webserver CPANEL's phpmyadmin. the MySQL keyword 'LIMIT' is not taking the value through parameter. or maybe not recognizing it. but when i remove this parameter from the select command and set the static number on this, it will work:
select category_id, category_name, category_thumb from category_list order by category_name limit 5;

now what is the procedure, so i will get the list through my given parameter.

Thank you Smile | :)
Posted 21-Dec-12 23:53pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160530.1 | Last Updated 22 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100