Click here to Skip to main content
15,887,821 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
AnswerRe: A form data with cascading dropdown and photo for upload Pin
Mohibur Rashid24-Jan-12 22:34
professionalMohibur Rashid24-Jan-12 22:34 
GeneralRe: A form data with cascading dropdown and photo for upload Pin
awedaonline25-Jan-12 21:43
awedaonline25-Jan-12 21:43 
QuestionPHP & JavaScript integration Pin
MacRaider423-Jan-12 1:53
MacRaider423-Jan-12 1:53 
AnswerRe: PHP & JavaScript integration Pin
Graham Breach23-Jan-12 2:37
Graham Breach23-Jan-12 2:37 
GeneralRe: PHP & JavaScript integration Pin
MacRaider423-Jan-12 2:49
MacRaider423-Jan-12 2:49 
GeneralRe: PHP & JavaScript integration Pin
Graham Breach23-Jan-12 3:55
Graham Breach23-Jan-12 3:55 
GeneralRe: PHP & JavaScript integration Pin
MacRaider423-Jan-12 4:45
MacRaider423-Jan-12 4:45 
QuestionGetting the URL Minus the Query String Pin
Kevin Li (Li, Ken-un)22-Jan-12 17:49
Kevin Li (Li, Ken-un)22-Jan-12 17:49 
At the moment, I have index.php located at the root. I want to have it parse all my URLs and delegate the workload to the correct code (via URL rewriting). I may be a bit nit-picky, but I'd like to know if there's an elegant solution to neatly separating the request URL and the key-value pairs of the query?

My index.php looks like this:
PHP
<?php
	// Set the content type of the output.
	header('Content-Type: text/plain; charset=utf-8');
	
	// Get and handle the request string.
	echo 'Debug Output';
	echo "\n\n";
	echo 'Request ($_SERVER["REQUEST_URI"]): "'.$_SERVER['REQUEST_URI'].'"';
	echo "\n";
	echo 'Request ($_GET["request"]): "'.$_GET['request'].'"';
	echo "\n";
	echo 'd="'.$_GET['d'].'"';
	echo "\n";
	echo 'e="'.$_GET['e'].'"';
	echo "\n";
?>


If I give it some URLs, they produce the corresponding outputs:

  1. mysite.com/a/b/c?d=1&e=2&request=3
    Debug Output
    
    Request ($_SERVER["REQUEST_URI"]): "/a/b/c?d=1&e=2&request=3"
    Request ($_GET["request"]): "3"
    d="1"
    e="2"
  2. mysite.com/a/b/c?d=3&e=4
    Debug Output
    
    Request ($_SERVER["REQUEST_URI"]): "/a/b/c?d=3&e=4"
    Request ($_GET["request"]): "a/b/c"
    d="3"
    e="4"


$_SERVER["REQUEST_URI"] includes everything after mysite.com including the raw query string, and $_GET["request"] will not return the requested URL minus the query string if there is a key named request.

I could parse the value of $_SERVER["REQUEST_URI"] myself, but I'd like to use built-in functionality before coding around the problem.


My GUID: ca2262a7-0026-4830-a0b3-fe5d66c4eb1d Smile | :)

Now I can Google this value and find all my Code Project posts!

AnswerRe: Getting the URL Minus the Query String Pin
Peter_in_278022-Jan-12 18:24
professionalPeter_in_278022-Jan-12 18:24 
GeneralRe: Getting the URL Minus the Query String Pin
Kevin Li (Li, Ken-un)22-Jan-12 20:46
Kevin Li (Li, Ken-un)22-Jan-12 20:46 
GeneralRe: Getting the URL Minus the Query String Pin
Kevin Li (Li, Ken-un)23-Jan-12 16:09
Kevin Li (Li, Ken-un)23-Jan-12 16:09 
QuestionFinding the starting PHP script Pin
MacIntyre22-Jan-12 8:16
MacIntyre22-Jan-12 8:16 
AnswerRe: Finding the starting PHP script Pin
Luc Pattyn22-Jan-12 8:26
sitebuilderLuc Pattyn22-Jan-12 8:26 
GeneralRe: Finding the starting PHP script Pin
MacIntyre22-Jan-12 9:14
MacIntyre22-Jan-12 9:14 
GeneralRe: Finding the starting PHP script Pin
MacIntyre22-Jan-12 9:24
MacIntyre22-Jan-12 9:24 
AnswerRe: Finding the starting PHP script Pin
Luc Pattyn22-Jan-12 10:13
sitebuilderLuc Pattyn22-Jan-12 10:13 
GeneralRe: Finding the starting PHP script Pin
MacIntyre22-Jan-12 11:13
MacIntyre22-Jan-12 11:13 
Questioninformation Pin
nilkanth rathod19-Jan-12 23:06
nilkanth rathod19-Jan-12 23:06 
AnswerRe:Information Pin
Manfred Rudolf Bihy20-Jan-12 0:09
professionalManfred Rudolf Bihy20-Jan-12 0:09 
AnswerRe: information Pin
Dhruv Dave14-Feb-12 19:19
Dhruv Dave14-Feb-12 19:19 
Questionbplustree Pin
meenakowshalya19-Jan-12 19:26
meenakowshalya19-Jan-12 19:26 
AnswerRe: bplustree Pin
Manfred Rudolf Bihy20-Jan-12 0:00
professionalManfred Rudolf Bihy20-Jan-12 0:00 
QuestionBlender part means Pin
sartar19-Jan-12 18:35
sartar19-Jan-12 18:35 
QuestionDisplay images from MySQL database using PHP help needed please !!! Pin
Josh7harington19-Jan-12 3:47
Josh7harington19-Jan-12 3:47 
AnswerRe: Display images from MySQL database using PHP help needed please !!! Pin
Gerben Jongerius19-Jan-12 23:12
Gerben Jongerius19-Jan-12 23:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.