Having trouble passing php as img
Posted: Tue Jul 06, 2010 9:12 pm
Code: Select all
<?php
header('Content-type: image/jpeg');
error_reporting(E_ALL);
ini_set('display_errors', True);
$data = file_get_contents("test.txt");
if(is_numeric($data))
{
echo '<img src="'.$data.'.jpg" />';
}
?> The data this script gets is just 1 integer saved in test.txt. I have uploaded various images like 1.jpg and 2.jpg to the directory.
It should be working, but all I get is " '; } ?>"
I gather there is a better way to do this? inside html img tags? something more like this:
<img src="/GetData.php?filename=<?PHP $data; ?>.jpg" />
I just don't understand the syntax of using PHP this way.