Jump to content

Get data from URL


Larry101

Recommended Posts

@MrSean: Lol oops typo thanks for catching that...

 

I'm not sure how well this will work, but how about trying this?

 

$queryString = $_SERVER['QUERY_STRING'];

echo "Query: " . $queryString;

 

Will that get the result?

Link to comment
Share on other sites

@MrSean: Lol oops typo thanks for catching that...

 

I'm not sure how well this will work, but how about trying this?

 

$queryString = $_SERVER['QUERY_STRING'];

echo "Query: " . $queryString;

 

Will that get the result?

 

Thanks again Insecure... that did work!!

Link to comment
Share on other sites

I see the link was on your own server, but if it wasn't....

 

If the url contains multiple unknown queries or not a link on your server, you can do this.

 

Grabs just the query, and also finds how many queries, and separates the queries and values.

 

<?php
$url = "http://www.youtube.com/watch?v=3fumBcKC6RE&feature=topvideos_music";
$url = trim($url);
//add http:// if is not present
if (substr($url, 0, 5) != "http:") {
$url = "http://$url";
}
$query_parse = parse_url($url, PHP_URL_QUERY);
$query_chunk = ltrim($query_parse, "?");
$query_array = explode("&", $query_chunk);
$query_number = 0;
foreach($query_array as $value_chunk){
$query_number = $query_number +1;
$query_value_array = explode("=", $value_chunk);
$query_value[] = $query_number."|".$query_value_array[0]."|".$query_value_array[1];
}

//the complete query
echo $query_chunk."<br />";

//queries array
foreach($query_value as $query_results){
$results = explode("|", $query_results);
$number = $results[0];
$query = $results[1];
$value = $results[2];

echo "<b>$number: Query: </b>".$query."<b>Value: </b>".$value."<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.