Languages :: PHP :: Simple Converstion of HEX to ASCII |
|||
| By: PHP newbee |
Date: 15/05/2003 00:00:00 |
Points: 100 | Status: Answered Quality : Excellent |
|
Hi I am new to this but it should be simple to those who know! A Perl script sends me back info from a form that I submitted with the following query string to index.php: index.php?acctype%3D1%26domain%3Dmaster%26frontpage%3Dno%26ecommerce%3Dno%26newold%3Dold%26fname%3Dgdgf%26lname%3Ddfg%26busname%3Ddfg I need it to be in the following ascii format for my php script to work: index.php?acctype=1&domain=master&frontpage=no&ecommerce=no&newold=old&fname=gdgf&lname=dfg&busname=dfg What code do I need to add to my index.php for it to make that conversion? Thanks in advance! |
|||
| By: carchitect | Date: 15/05/2003 15:47:00 | Type : Comment |
|
| hi no need to convert you can directly use variables in php script. regards |
|||
| By: VGR | Date: 16/05/2003 05:34:00 | Type : Comment |
|
| $newstring=urldecode($oldstring); |
|||
| By: PHP newbee | Date: 16/05/2003 05:35:00 | Type : Comment |
|
| Well there must be something I'm doing wrong as it only seems to work when I type the ASCII version in the address bar. What could be wrong? It's just simple html code that is referenced by index.php. e.g. the variable "fname" doesn't get passed in the HEX version: <input type="hidden" name="fname" value="<? echo("$fname");?>"> regards |
|||
| By: VGR | Date: 16/05/2003 05:40:00 | Type : Answer |
|
| 1) $fname will be passed in URI only if method=GET in the FORM 2) you should use, not the QUERY_STRING, but the $_GET['fname'] super-under-global array [if PHP>=4.2] 3) after trying urldecode(), do you still have a problem ? |
|||
| By: prady_21 | Date: 16/05/2003 05:45:00 | Type : Comment |
|
| function unhtmlentities ($string) { $trans_tbl = get_html_translation_table (HTML_ENTITIES); $trans_tbl = array_flip ($trans_tbl); $ret = strtr ($string, $trans_tbl); return preg_replace('/&#(\d+);/me', "chr('\\1')",$ret); } As long as i think, there should be no problem at all, well anyway if u need it, i got the above from a site i dont even know if it works :) <A HREF="http://www.php.net/manual/en/function.get-html-translation-table.php">http://www.php.net/manual/en/function.get-html-translation-table.php</a> |
|||
| By: PHP newbee | Date: 16/05/2003 18:02:00 | Type : Comment |
|
| Well there must be something I'm doing wrong as it only seems to work when I type the ASCII version in the address bar. What could be wrong? It's just simple html code that is referenced by index.php. e.g. the variable "fname" doesn't get passed in the HEX version: <input type="hidden" name="fname" value="<? echo("$fname");?>"> regards |
|||
| By: VGR | Date: 16/05/2003 18:10:00 | Type : Comment |
|
| prady_21's proposal is a bit too overkill to me, as I think preg_replace() is especially unefficient, as are all regexp functions |
|||
| By: mbeckman | Date: 16/05/2003 18:35:00 | Type : Comment |
|
| PHPnewbee, you may not be explaining your problem in the best way. The INPUT tag you show ... is this on a 2nd page that you are trying to pass variables to, or is it on the primary form? |
|||
| By: PHP newbee | Date: 16/05/2003 19:23:00 | Type : Comment |
|
| Yes urldecode worked well in the end thanks! Regards, |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








