0

Alright, so I'm going to be completely honest here. I've spent three days trying to find what was going wrong, used online sources to check for errors, ANYTHING, that I could use to help me fix this problem. The original PHP code I used is below, but I've changed it a bit, and I'll show those as well:

<?php
   $image = $_GET["image"]; //e.g. "image.png"
   echo '<img src="' . $image . '"/>'; //prints everything after ">" (unwanted)
   echo '<a href="' . $image . '">Right-click to download</a>';
?>

After seeing that caused the problem, I tried swapping the quotes:

<?php
   $image = $_GET["image"]; //e.g. "image.png"
   echo "<img src='" . $image . "'/>"; //still cuts off
   echo "<a href='" . $image  . "'>Right-click to download</a>";
?>

Then after THAT, I tried taking the original code and made echo use a variable:

<?php
   $image = $_GET["image"]; //e.g. "image.png"
   $imgech = '<img src="' . $image . '"/>';
   $aech = '<a href="' . $image . '">Right-click to download</a>';
   echo $imgech;
   echo $aech;
?>

Then I tried swapping the quotes again (You can see above, I don't want to make this too long). I tried using brackets:

<?php
   $image = $_GET["image"];
   echo "<img src='{$image}'/>";
   echo "<a href='{$image}'>Right-click to download</a>";
?>

...I however didn't try swapping the quotes this time. I've tried more combinations, but I don't want to make this too long, so I'll skip over those. Using online tools, I've found no errors in the code, the file ends in .php, and the HTML is normal:

<html lang="en">
 <head>
  <meta charset="utf-8"/>
  <title>View image</title>
  <link rel="stylesheet" href="default.css"/>
 </head>
 <body>
  <!-- PHP code goes here -->
 </body>
</html>

So I have no idea what's wrong! Other questions I've found are mostly just HTML or file problems, and references show me I'm doing things right. Could someone please help me?

ColinTNMP
  • 11
  • 1
  • 1
    It's not the quotes. The page is not being parsed by PHP. PHP is not installed correctly with your webserver. – AbraCadaver Mar 11 '16 at 16:23
  • view HTML source and tell us what you see. – Funk Forty Niner Mar 11 '16 at 16:23
  • *"and the HTML is normal"* `` ok Colin. You need to interact with us here. If you're running this as `.html` in your browser `file:///file.html(.php)` as opposed to `http://localhost/file.php` and expecting PHP to be parsed and without a webserver/PHP installed, is the reason why. So... your question stands to be closed shortly based on what you've given us. – Funk Forty Niner Mar 11 '16 at 16:33

0 Answers0