I am a newbie with PHP but I am ticked off at myself for not knowing something probably simple.
I am working on a web site.
My index.html is in FOLDER A
A picture I want to see is in Folder B
The index is simple it says to call results.php file.
The php file does a search in the database and grabs a name.
Now my problem. I want to take that name and then open the picture. In other words open the picture called "name.gif". Since I have too many "marks, what do I need to do: I have the typical html code.
<img border="0" src="MyFolder\picture.gif">
I tried with an echo but too many quotes!
thanks,
Fegero
feger585@yahoo.com
HTML and PHP
Moderator: General Moderators
- Bill H
- DevNet Resident
- Posts: 1136
- Joined: Sat Jun 01, 2002 10:16 am
- Location: San Diego CA
- Contact:
Code: Select all
echo "<img border="0" src="MyFolder/picture.gif">";The backslash is the "escape" character and tells the php to print the following character rather than parse it.
Darn, Bill H, I wasn't quick enough.
Anyway, here's what I was posting--
I have come up with three possible solutions:
Anyway, here's what I was posting--
I have come up with three possible solutions:
- 1. You can begin the path with a / (slash), and enter the full path, like this "/path/MyFolder/picture.gif"
2. You can use "dots" like this "../MyFolder/picture.gif" (.. is the previous folder).
3. You might need to use a forward slash /, instead of a backslash \ in the path. A backslash \ is for "escape" characters, so "MyFolder\name.gif" inserts a newline character (\n).
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
If you don't want to have to escape all the double quotes in your HTML put the string in single quotes:
Note that PHP doesn't parse things in single quotes so if you had a variable in the above string you'd have to do something like this:
Mac
Code: Select all
echo '<img border="0" src="MyFolder/picture.gif">';Code: Select all
echo '<img border="0" src="MyFolder/'.$picture_name.'.gif">';- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
Or you could even do it like this:
Especially for larger pieces of html, I often prefer this.
Michiel
Code: Select all
?>
<img border="0" src="MyFolder\<?=$name?>.gif">
<?Michiel