-8

I simply need a GET Variable that doesn't have any " marks. ' marks are okay, but " aren't. What do I need to do to fix that? And no, changing the " marks to ' do not work. I must do this because the GET is a URL link, so the URL link must be within two " quotes. If a " mark is within those lines, it will cause the link to stop short.

' . $_GET["test"] . '

My Code

<?php
$user = str_replace($_GET["user"], "\"", "'");
$user = "" . $user . "";
?>

<iframe src="https://domain.tld/?user=' . $user . '&password=' . $_GET['password'] . '&version=99" height="30" width="500"></iframe>
  • 3
    There is nothing here that needs fixing. Can you be more specific? – Jon Feb 24 '13 at 02:07
  • Yes, it can't have the " mark... – user2092939 Feb 24 '13 at 02:08
  • 1
    You already wrote that. Try another way. *What* is it can't have *quotes*? *Why*? – Jon Feb 24 '13 at 02:09
  • Because it is in a URL link, so the URL link must be within two " quotes. If a " mark is within those lines, it will cause the link to stop short. – user2092939 Feb 24 '13 at 02:09
  • Although I've answered your question, you've not worded it very descriptively. Please consider adding more detail in the future. – Christian Stewart Feb 24 '13 at 02:10
  • 1
    Then look here: http://stackoverflow.com/questions/129677/whats-the-best-method-for-sanitizing-user-input-with-php. – Jon Feb 24 '13 at 02:10
  • @ChristianStewart: You have answered his question, but your answer is still not 100% correct. Exactly because there was not enough information to determine the correct answer. – Jon Feb 24 '13 at 02:11
  • Quite right, I have still answered the question "How do I remove " marks from a GET variable" – Christian Stewart Feb 24 '13 at 02:11
  • You reposted the question under a different username and said that we did not answer it... This is NOT acceptable behavior under SO rules and etiquette.. Needless to say I have expanded my answer to be a full solution. – Christian Stewart Feb 24 '13 at 02:42

1 Answers1

4

You can simply fetch the $_GET[''] variable and use a find and replace to replace all the "

Example:

$myVar = str_replace($_GET["myVar"], "\"", "'");
$myStringWithVar = "" . $myVar . "";

Full example:

<iframe src="https://domain.tld/?user=<?php echo
str_replace($_GET["myVar"], "\"", "'");  ?>&password=' .
$_GET['password'] . '&version=99" height="30" width="500"></iframe>

Please do not ask the same question again later on under a different username (as you have done)

Christian Stewart
  • 15,217
  • 20
  • 82
  • 139