problem with showimage.php?image
Moderator: General Moderators
problem with showimage.php?image
Hello, the code in my test page is :
**********************
<?php
echo "<table border=1>";
echo "<tr>";
echo "<td>";
echo "</td>";
echo "<td>";
echo "<A HREF='showimage.php?image="photo1.jpg"'>"; // line 17
echo "</A></td>";
echo "</tr>";
echo "</table>";
?>
*********************
But whe I try to display this file in a browser, it answers with the following error:
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/public_html/test.php on line 17
Thank you in advance.
**********************
<?php
echo "<table border=1>";
echo "<tr>";
echo "<td>";
echo "</td>";
echo "<td>";
echo "<A HREF='showimage.php?image="photo1.jpg"'>"; // line 17
echo "</A></td>";
echo "</tr>";
echo "</table>";
?>
*********************
But whe I try to display this file in a browser, it answers with the following error:
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/public_html/test.php on line 17
Thank you in advance.
check the colors the syntxhilighter assigns to your codeif you start your string literal with " you must escape all "s within the literal or php thinks it ends there (how should it know it does not?)
In your code block there's nothing really to do for php, it only prints static strings. You can leave and re-enter php-blocks (almost) as you like. Anything outside a php-block will be sent as-is to the client, e.g.
Code: Select all
<?php
echo "<table border=1>";
echo "<tr>";
echo "<td>";
echo "</td>";
echo "<td>";
echo "<A HREF='showimage.php?image="photo1.jpg"'>"; // line 17
echo "</A></td>";
echo "</tr>";
echo "</table>";
?>Code: Select all
<?php
echo "escape all "s within the literal. ' can be used freely in here";
echo 'escape all ''s within the literal. " can be used freely in here';
?>Code: Select all
<html>
<head>
<title>jump in and out php-blocks test</test>
</head>
<body>
<?php if (isset($_POST['text'])) { ?>
<fieldset><legend>you've typed</legend>
<pre><?php print_r($_POST['text']); ?></pre>
</fieldset>
<?php } ?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"
<textarea name="text"></textarea>
<input type="submit" />
</form>
</body>
</html>it doesn't work
Thankyou for your response,
I have tested this:
echo "<A HREF='showimage.php?image=\"photo1.jpg\"'>";
but still it doesn't work. The browser doesn't give to me an error, but it doesn't show the image.
What I'm triying to do is an image galery.
I have tested this:
echo "<A HREF='showimage.php?image=\"photo1.jpg\"'>";
but still it doesn't work. The browser doesn't give to me an error, but it doesn't show the image.
What I'm triying to do is an image galery.
You're using single quotes around the HREF string - is that valid HTML? Plus the get variable need not have quotes at all.
I'd try:
Then in showimage.php you need
To read in the value of image from the URL (assuming register globals is off).
I'd try:
Code: Select all
<?php
echo "<A HREF="showimage.php?image=photo1.jpg">";
?>Code: Select all
<?php
$image = $_GET['image'];
?>- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
To save having to escape double quotes you could have:
Although I'm not sure how the image will display if you have it within anchor tags, it should really be within image tags shouldn't it?
i.e. using heredoc format (another choice you have, although you may wish to break out of PHP and return to it once the HTML is done):
Mac
Code: Select all
echo '<a href="showimage.php?image=photo1.jpg">';i.e. using heredoc format (another choice you have, although you may wish to break out of PHP and return to it once the HTML is done):
Code: Select all
echo <<<END
<table border="1">
<tr>
<td> </td>
<td>
<a href="page_to_link_to.php">
<img src="showimage.php?image=photo1.jpg" alt="" title="" />
</a>
</td>
</tr>
</table>
END;i think that this have been mentioned before, but i'll post it anyway;
i would do something like this:
That works, at least on my localhost

i would do something like this:
Code: Select all
<?php
//Start echo...
echo "<table border="1">
<tr>
<td>
</td>
<td>
<A HREF="showimage.php?image=photo1.jpg"'>
</A></td>
</tr>
</table>
"; //End echo...
?>