If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > very easy function in mysql doesn't work

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-28-09, 13:06
chomik chomik is offline
Registered User
 
Join Date: Dec 2008
Posts: 53
very easy function in mysql doesn't work

MySQL 5.0.45

Code:
CREATE FUNCTION fun() RETURNS INT
BEGIN
RETURN 5;
END;

#1064 - Something is wrong in your syntax near '' in line 3

Why ?
Reply With Quote
  #2 (permalink)  
Old 08-28-09, 13:57
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Code:
DELIMITER $$

CREATE FUNCTION fun() RETURNS INT
BEGIN
RETURN 5;
END;

$$
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 08-28-09, 14:30
chomik chomik is offline
Registered User
 
Join Date: Dec 2008
Posts: 53
Code:
DELIMITER $$ 

CREATE FUNCTION fun() RETURNS INT 
BEGIN RETURN 5; 
END; 

$$

I have still error:
http://img526.imageshack.us/my.php?i...2009203229.png
Imageshack - 08282009203042
Reply With Quote
  #4 (permalink)  
Old 08-28-09, 16:17
BettingSherlock BettingSherlock is offline
Registered User
 
Join Date: May 2007
Posts: 78
Possibly you can't do that through phpadmin,
try connecting direct or use a script outside phpadmin.
Reply With Quote
  #5 (permalink)  
Old 08-29-09, 03:46
chomik chomik is offline
Registered User
 
Join Date: Dec 2008
Posts: 53
PEOPLE !! I know !! You must write in phpmyadmin:

Code:
CREATE FUNCTION fun5() RETURNS INT 
BEGIN 
RETURN 5; 
END
without $$ in code !! And then write below in input Separator $$
Screen: http://yfrog.com/5r57844448j







And how can I see the result this function using php. It:
PHP Code:
$query mysql_query("select fun()");
echo 
$query
Shows me: Resource id #3 :/

Last edited by chomik; 08-29-09 at 05:11.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On