Well I have this MySQL stored procedure that I wrote and if I run the following in phpMyAdmin things return properly:
SELECT game_name,urlfriendly(game_name) AS game_name2 FROM games
However if I try to run the following code I get the error "Warning: Invalid argument supplied for foreach() in /filepath.php on line #"
foreach ($this->database->query("SELECT game_name,urlfriendly(game_name) AS game_name2 FROM games") as $games)
{
echo $games["game_name"] . " " . $games["game_name2"];
}
However if I run this it all goes fine:
foreach ($this->database->query("SELECT game_name FROM games") as $games)
{
echo $games["game_name"];
}
Meaning the stored proc won't return to PHP.
Any ideas?
EDIT Here's the stored proc (but I doubt it is the issue as phpMyAdmin is pulling values back from it just fine)
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 Here is the error returned from MySQL
execute command denied to user 'username'@'localhost' for routine 'databasename.urlfriendly' )