visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: PHP :: Simple Converstion of HEX to ASCII


By: PHP newbee U.S.A.  Date: 15/05/2003 00:00:00  English  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 English  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 English  Type : Comment
$newstring=urldecode($oldstring);
By: PHP newbee Date: 16/05/2003 05:35:00 English  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 English  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 English  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 English  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 English  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 English  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 English  Type : Comment
Yes urldecode worked well in the end thanks!

Regards,

Do register to be able to answer

EContact
browser fav
page generated in 349.831820 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page