aristotle15 Posted January 24, 2011 Share Posted January 24, 2011 Hi, I have written a code that take the GET contents of a URL , i.e after the ? sign and outputs it as a csv file. eg - ....../xyz.php?str=<tr><td>c1</td><td>c2</td><td>c3..........c7</tr></td> $input = $_GET['str']; ......... ............ ...... output should be as - c1,c2,c3,c4.... so on well , i have written a code for that and it works wonderfully except that if the url contains '&' and '#'(hidden fields) in the columns , the script malfunctions coz they act as delimiters.How do I take care of that? how to fetch the contents of the URL so that the & and # dont create a problem? Please help.. Link to comment https://forums.phpfreaks.com/topic/225478-get-query/ Share on other sites More sharing options...
dragon_sa Posted January 24, 2011 Share Posted January 24, 2011 you need to use urlencode for the hash and you need to escape the $ symbol with \ like this for example testpage.php <?php if(isset($_GET['test'])) { echo $_GET['test']." is printing my data"; } else { $works=urlencode("yes\$this#works"); echo "<a href='testpage.php?test=$works'>click</a>"; } ?> Link to comment https://forums.phpfreaks.com/topic/225478-get-query/#findComment-1164311 Share on other sites More sharing options...
aristotle15 Posted January 24, 2011 Author Share Posted January 24, 2011 What I want is- if i enter the url - ...../xyz.php?str='abcdefg' in my browser and press enter, 'abcdefg' goes into an array , Its very simple with $_GET['str'] BUT if & or # come in the 'str' , the string is broken before those characters. Is there any way I could escape & and # in the url so that I could use the contents of the url... i.e some way other than $_GET['str'] Link to comment https://forums.phpfreaks.com/topic/225478-get-query/#findComment-1164375 Share on other sites More sharing options...
dragon_sa Posted January 24, 2011 Share Posted January 24, 2011 how are you generating your links, or are you wanting to just type them into the browser address bar? Link to comment https://forums.phpfreaks.com/topic/225478-get-query/#findComment-1164383 Share on other sites More sharing options...
aristotle15 Posted January 25, 2011 Author Share Posted January 25, 2011 I am jusy typing it in the browser address bar... it will be encoded in some button later on.. but what i want is this only... the columns i pass... in str , eg.- ...?str='<tr><td>c1</td><td>c2</td><td>c3</td></tr>' are to be made into csv format..which i ve done but my problem is that if the columns i pass contain # or & , the csv line breaks before that character. How to 'treat' the input before using $_GET[] coz $_GET[] cannot take any string that has # or & in it. Link to comment https://forums.phpfreaks.com/topic/225478-get-query/#findComment-1164872 Share on other sites More sharing options...
codefossa Posted January 25, 2011 Share Posted January 25, 2011 pathinfo substr_replace() remaining string is what's after the str= Link to comment https://forums.phpfreaks.com/topic/225478-get-query/#findComment-1164875 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.