please what is wrong with this

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nutstretch
Forum Contributor
Posts: 104
Joined: Sun Jan 11, 2004 11:46 am
Location: Leicester

please what is wrong with this

Post by nutstretch »

I have now got my string in which i am hoping to call an image.

I have put this code i but am getting an error

I have put the string into a variable but can't work out how to syntax it.
the code below shoes the concatenation


print "<td><img src=\""gifs/".$row['StyleID'].".jpg"\" ></td>";

Pleas what have i done wrong.

the string is called $test
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

print "<td><img src=\""gifs/".$row['StyleID'].".jpg"\" ></td>";


http://www.php.net/manual -> variables -> strings

print "<td><img src='gifs/{$row['StyleID'[}.jpg'></td>";
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Single quotes save having to escape double quotes in html. I always concatenate - syntax highlighting makes it much easier to see vars in strings.

Code: Select all

<?php
print '<td><img src="gifs' . $row['StyleID'] . '.jpg"></td>';
?>
Last edited by McGruff on Tue Aug 09, 2005 7:57 pm, edited 1 time in total.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Code: Select all

print "<td><img src="gifs".$row['StyleID'].".jpg"></td>";
If your using "" then you must escape any " you wish to display with \".

You could of course use '' in which case you would need to do:

Code: Select all

print '<td><img src="gifs'.$row['StyleID'].'.jpg"></td>';
Post Reply