Topic: Pubblico - Composto da 2 Posts di 2 Utenti.
| 18 Luglio, 2011 10:48 | #1 | ||
|---|---|---|---|
|
Ciao a tutti, sono nuovo del forum. Mi sto imbattendo in un problema che non riesco a risolvere. Ho la necessita di creare una funzione in mysql che mi tolga i tag html, l'equivalente di strip_tags di php. Ho trovto questa: 1delimiter || 2 3DROP FUNCTION IF EXISTS strip_tags|| 4CREATE FUNCTION strip_tags( x longtext) RETURNS longtext 5LANGUAGE SQL NOT DETERMINISTIC READS SQL DATA 6BEGIN 7DECLARE sstart INT UNSIGNED; 8DECLARE ends INT UNSIGNED; 9SET sstart = LOCATE('<', x, 1); 10REPEAT 11SET ends = LOCATE('>', x, sstart); 12SET x = CONCAT(SUBSTRING( x, 1 ,sstart -1) ,SUBSTRING(x, ends +1 )) ; 13SET sstart = LOCATE('<', x, 1); 14UNTIL sstart < 1 END REPEAT; 15return x; 16END; 17|| 18delimiter ; Il problema è il seguente: quando la creo in locale, tramite phpmyadmin eseguo la query e il server crea la funzione correttamente. Quando la vado a creare sul server remoto sempre tramite phpmyadmin mi restituisce il seguente errore: Ho provato a togliere l'istruzione delimiter ed eseguire questa query: 1CREATE FUNCTION strip_tags( x longtext) RETURNS longtext 2LANGUAGE SQL NOT DETERMINISTIC READS SQL DATA 3BEGIN 4DECLARE sstart INT UNSIGNED; 5DECLARE ends INT UNSIGNED; 6SET sstart = LOCATE('<', x, 1); 7REPEAT 8SET ends = LOCATE('>', x, sstart); 9SET x = CONCAT(SUBSTRING( x, 1 ,sstart -1) ,SUBSTRING(x, ends +1 )) ; 10SET sstart = LOCATE('<', x, 1); 11UNTIL sstart < 1 END REPEAT; 12return x; 13END; ed ottengo: 1#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 In locale ho PhpMyadmin 3.3.8 e MySQL: 5.1.37, mentre in remoto c'e MySql 5.0.77 e PhpMyadmin 2.8.2.4. Spero di essere stato chiaro e grazie a tutti in anticipo. |
|||
| 20 Luglio, 2011 08:09 | #2 | ||
|---|---|---|---|
|
Ciao e complimenti per il post... dettagliato e pulito. A occhio non vedevo nulla di strano e ho provato su un installazione 5.0.77 senza usare i delimiter Ma nessun problema, immagino sei in hosting ... .. se il problema è phpmyadmin che inserisce qualche caratterino da qualche parte .. fai uno scrippettino php che ti esegue questa query e vedi che succede tienici aggiornati Un tempo ero algweb ora sono g2d |
|||
Condividi su:
Loggati o Registrati per replicare