Jump to content

[SOLVED] $_GET[] help


dbx

Recommended Posts

I think what the OP is trying to do is extract data from a query string. However (as far as I know), you can only use $_GET when the data is passed directly through the URL, not as a string stored in a variable.

 

What you can do (which requires some work) is to use parse_url(). This function can be used to return the query-string portion of the url.

 

For example,

 

<?php
$myURL = "http://www.mysite.com/index.php?a=1&b=2";
echo parse_url($myURL, PHP_URL_QUERY);
// Returns: a=1&b=2
?>

 

In order to get the info that you want, you're going to have to use different function to break up the resulting string into parts (hint: explode()).

 

http://us2.php.net/manual/en/function.parse-url.php

 

Link to comment
Share on other sites

change.php?SL-0009000_4080755_678.jpg=1&SL-0009000_6013157_16.jpg=2&SL-0009000_4354083_126.jpg=3&area=paf&ref=SL-0009000

 

if($result)
{
while($row = mysql_fetch_array($result)) {

$dbfile=$row["file"];

echo $dbfile."<br />";

$sentfile=$_GET[$dbfile];

echo "Sent file: ".$sentfile."<br />";

}
}

 

Displays:

 

SL-0009000_4080755_678.jpg

Sent file:

SL-0009000_6013157_16.jpg

Sent file:

SL-0009000_4354083_126.jpg

Sent file: 

Link to comment
Share on other sites

So you want it to read

 

SL-0009000_4080755_678.jpg
Sent file: 1
SL-0009000_6013157_16.jpg
Sent file: 2
SL-0009000_4354083_126.jpg
Sent file: 3

 

? If my memory is right, dots are converted to underscores when used as the name in a query string. Why not swap the names and values, so the URL looks like

 

change.php?1=SL-0009000_4080755_678.jpg&2=SL-0009000_6013157_16.jpg&3=SL-0009000_4354083_126.jpg&area=paf&ref=SL-0009000

 

and then use

 

if($result)
{
while($row = mysql_fetch_array($result)) {

$dbfile=$row["file"];

echo $dbfile."<br />";

echo "Sent file: ".array_search($dbfile, $_GET)."<br />";

}
}

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.