LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-13-2011, 07:54 PM   #1
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Rep: Reputation: 53
PHP: $_GET['param'] insists on retaining quotes


I've got an XML File including this tag:
Code:
<url>innerpage.php?source='business.xml'</url>
I load that content via a client/server setup which defines:
Code:
$thissource=$_GET['source'];
When I echo $thissource in my php file I get:
Quote:
'business.xml'
when I want
Quote:
business.xml
I hope the problem is obvious to someone here, because I've seemingly tried everything. Thanks

Last edited by bluegospel; 09-13-2011 at 08:00 PM. Reason: specify PHP in title
 
Old 09-13-2011, 08:21 PM   #2
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
assuming the file name will never have quotes in it you could always try changing
Code:
$thissource=$_GET['source'];
to
Code:
$thissource=ereg_replace("'","",$_GET['source']);
 
Old 09-13-2011, 08:37 PM   #3
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
Quote:
Originally Posted by frieza View Post
assuming the file name will never have quotes in it you could always try changing
Code:
$thissource=$_GET['source'];
to
Code:
$thissource=ereg_replace("'","",$_GET['source']);
Thanks frieza. I thought of something like that, but shouldn't the way I wrote my xml & script return the string without the quotes?
 
Old 09-13-2011, 10:15 PM   #4
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
well the thing is, it looks as if the XML is pointing to a script on a web server if I'm not mistaken, which is passing value 'source' as $_GET source, but $_GET values are taken literally including white space and quotes, so you can either safely omit the quotes from the xml or filter them out.
 
Old 09-14-2011, 07:44 AM   #5
Proud
Senior Member
 
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794

Rep: Reputation: 116Reputation: 116
HTML/GET values aren't quoted (see the URL of this page for e.g. "...showthread.php?p=4471019#post4471019"), expect them to be URLEncoded instead (think %20 = space, etc).
In PHP, $_REQUEST and $_GET values are automatically URL decoded (not $_POST), but again, this doesn't deal with quotes.
Whatever formed "innerpage.php?source='business.xml'" was either in error, or is implying the single quotes are parts of the string being passed.

Last edited by Proud; 09-14-2011 at 07:46 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Yet Another Bash Quotes Within Quotes Issue tboyer Linux - Software 17 11-03-2012 11:17 AM
XMLHtpRequest GET() and $_GET Neethusha Programming 3 03-20-2010 04:42 AM
Problems with quotes and double quotes Andruha Slackware 6 01-02-2010 04:44 PM
Using single quotes vs double quotes in PHP strings vharishankar Programming 6 07-11-2005 11:41 AM
[BASH] How to filter characters away? !{param#word} {param%word}! Dark Carnival Programming 8 03-17-2005 01:49 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration