0
if($_GET["content"] ="foo"){
    echo("<h4>foo</h4>");
    exit;
}

When I type in URL "127.0.0.1/_/index.php?content=foo" it seems to output the previous code I wrote

if($_GET["content"] ="picture"){
    echo("Picture:<br>");
    echo("<img src='./ku~1.jpg'></img>");
    exit;
}

What is the problem here?

IMAGE

Marvin
  • 13,325
  • 3
  • 51
  • 57

2 Answers2

2
if($_GET["content"] ="picture"){

assigns $_GET["content"] the value "picture". You want to use

if($_GET["content"] =="picture"){

and

if($_GET["content"] =="foo"){

instead.

Marvin
  • 13,325
  • 3
  • 51
  • 57
1

Have you started your file with

<?php

And you are assigning the value content by only using one =

Do this instead

if($_GET["content"] == "picture"){ 
  echo "Picture:<br>"; 
  echo '<img src="./ku~1.jpg"></img>'; 
  exit; 
}

You were also wrapping your echo with parentheses when they should be contained in quotations.

I forgot the first example... That should be:

if($_GET["content"] == "foo"){ 
    echo "<h4>foo</h4>"; 
    exit; 
}
useyourillusiontoo
  • 1,287
  • 1
  • 10
  • 24
  • Yes. But I don't know what the problem is, I checked for some problems in code and everything is how it should be. –  Oct 29 '16 at 21:52
  • Wow man, thanks a lot. That fixed the problem. I was really frustrating with this problem. Again, thanks :) –  Oct 29 '16 at 21:56