2009-01-25 84 views
1

嗯,我認爲我寫的,如果我運行phpMyAdmin的東西下面的正確返回這個MySQL存儲過程:提供的參數無效:爲什麼我的PHP不會返回MySQL存儲過程?

SELECT game_name,urlfriendly(game_name) AS game_name2 FROM games 

但是,如果我嘗試運行下面的代碼我得到的錯誤「警告爲的foreach()在/filepath.php線#」

foreach ($this->database->query("SELECT game_name,urlfriendly(game_name) AS game_name2 FROM games") as $games) 
{ 
    echo $games["game_name"] . " " . $games["game_name2"]; 
} 

但是,如果我跑這一點,一切順利的罰款:

foreach ($this->database->query("SELECT game_name FROM games") as $games) 
{ 
    echo $games["game_name"]; 
} 

含義ŧ他存儲過程不會返回到PHP。

任何想法?

編輯這裏的存儲過程(但我懷疑這是問題,因爲phpMyAdmin是從它就好拉後的值)

DELIMITER //

DROP FUNCTION urlfriendly 
// 
CREATE FUNCTION urlfriendly (unsafe TEXT) RETURNS TEXT 

DETERMINISTIC 

BEGIN 

DECLARE safe TEXT; 

SET safe = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(LOWER(unsafe),' ','-'),'&','and'),'`',''),'~',''),'!',''),'@',''),'#',''),'$',''),'%',''),'^',''),'*',''),'(',''),')',''),'_',''),'+',''),'=',''),'[',''),'{',''),']',''),'}',''),'|',''),'\\',''),"'",""),'"',''),':',''),';',''),'<',''),',',''),'>',''),'.',''),'/',''),'?',''); 

RETURN safe; 

END 
// 

EDIT2這裏是從MySQL返回的錯誤

execute command denied to user 'username'@'localhost' for routine 'databasename.urlfriendly') 

回答

3

你能得到errorInfo

你可以運行:

GRANT EXECUTE ON `database`.* TO 'username'@'localhost' 

從phpMyAdmin的?

+0

沒有顯示任何內容 - 這將與PDO一起工作嗎? – 2009-01-25 02:10:57