Jump to content

GET query


aristotle15

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.