Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
i keep getting the same error everytime(mysql syntax error)
Old 07-22-2009, 10:32 AM i keep getting the same error everytime(mysql syntax error)
Junior Talker

Posts: 3
Name: Lylle Samuels
Trades: 0
I'm new at Mysql, so forgive me if it's something simple. I'm am working in phpMyAdmin.

This is the code:

create function get_distance()
returns double
begin
declare latitude_1 float(10,6);
declare longitude_1 float(10,6);
declare latitude_2 float(10,6);
declare longitude_2 float(10,6);
select post_lat, post_long into latitude_1, longitude_1 from pc2 where post_uid = 10001;
select post_lat, post_long into latitude_2, longitude_2 from pc2 where post_uid = 10002;
return (((acos(sin((latitude_1*pi()/180)) *
sin((latitude_2*pi()/180))+cos((latitude_1*pi()/180)) *
cos((latitude_2*pi()/180)) * cos(((longitude_1-longitude_2)*
pi()/180))))*180/pi())*60*1.1515);

end get_distance;

And this is the error i get:

#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

PLEASE HELP!
SamLyle is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-25-2009, 09:45 AM Re: i keep getting the same error everytime(mysql syntax error)
Super Talker

Posts: 130
Trades: 0
you forgot the DELIMITER. try this:

PHP Code:
DELIMITER |
create function get_distance()
returns double
begin
declare latitude_1 float(10,6);
declare 
longitude_1 float(10,6);
declare 
latitude_2 float(10,6);
declare 
longitude_2 float(10,6);
select post_latpost_long into latitude_1longitude_1 from pc2 where post_uid 10001;
select post_latpost_long into latitude_2longitude_2 from pc2 where post_uid 10002;
return (((
acos(sin((latitude_1*pi()/180)) *
sin((latitude_2*pi()/180))+cos((latitude_1*pi()/180)) *
cos((latitude_2*pi()/180)) * cos(((longitude_1-longitude_2)*
pi()/180))))*180/pi())*60*1.1515);

end |
DELIMITER 
__________________
flann

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
flann is offline
Reply With Quote
View Public Profile
 
Old 08-06-2009, 05:26 AM Re: i keep getting the same error everytime(mysql syntax error)
Junior Talker

Posts: 3
Name: Lylle Samuels
Trades: 0
Thanks a lot flann for your reply. Sorry for replying so late.
But i got another 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 'function get_distance()
returns double
begin
declare latitude_1 float(10,6);
' at line 1
SamLyle is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to i keep getting the same error everytime(mysql syntax error)
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.31895 seconds with 12 queries