note 88711 added to function.urlencode

From: Date: Wed, 04 Feb 2009 13:31:45 +0000
Subject: note 88711 added to function.urlencode
Groups: php.notes 
Request: Send a blank email to php-notes+get-150202@lists.php.net to get a copy of this message
I read a UTF-8 encoded string form a mysql database and wanted to use it as a parameter for a javascript function which opens a popup window (the HTML site also encoded as UTF-8). Somehow I had serious trouble with strings containing special characters like ' and especially german umlaute. When using urlencode(), the umlaute weren't correctly displayed in the popup with IE. I tried many variations with urlencode(), rawurlencode(), addslashes(), ..., but none of them was working in all browsers (Safari, FF, IE). If someone is experiencing the same problem: Here is the code I got it finally working with very well in all browsers... <?php echo '<a href="javascript: popup_textanswer(\''. htmlentities(addslashes($act_question['questiontext']), ENT_QUOTES,'UTF-8'). '\');">question</a>'; ?> the javascript function: <?php // actually javascript function popup_textanswer(questiontext) { var win = window.open('popup.php?id=1&questiontext=' + questiontext, 'popup', 'width=600,height=400'); win.focus(); } ?> ---- Server IP: 192.35.244.50 Probable Submitter: 62.47.46.209 ---- Manual Page -- http://www.php.net/manual/en/function.urlencode.php Edit -- https://master.php.net/note/edit/88711 Del: integrated -- https://master.php.net/note/delete/88711/integrated Del: useless -- https://master.php.net/note/delete/88711/useless Del: bad code -- https://master.php.net/note/delete/88711/bad+code Del: spam -- https://master.php.net/note/delete/88711/spam Del: non-english -- https://master.php.net/note/delete/88711/non-english Del: in docs -- https://master.php.net/note/delete/88711/in+docs Del: other reasons-- https://master.php.net/note/delete/88711 Reject -- https://master.php.net/note/reject/88711 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#150202) next »