GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   embedding CSS in PHP, example, please look (https://gfy.com/showthread.php?t=703794)

Kard63 02-06-2007 07:24 PM

embedding CSS in PHP, example, please look
 
print "<IMG STYLE="position:absolute; TOP:35px; LEFT:170px; WIDTH:50px; HEIGHT:50px" SRC="hair$hair.gif">";



Whats wrong with that line? thanks.

Chio 02-06-2007 07:25 PM

Quote:

Originally Posted by Kard63 (Post 11873273)
print "<IMG STYLE="position:absolute; TOP:35px; LEFT:170px; WIDTH:50px; HEIGHT:50px" SRC="hair$hair.gif">";



Whats wrong with that line? thanks.

I'm not a coder at all but maybe you need to escape out some of those characters?

Kard63 02-06-2007 07:27 PM

the line:

print "<img src = hair$hair.gif>";

works. but when I try to add CSS it goes to shit.

DjSap 02-06-2007 07:29 PM

A. You do not fucking do that, all styles go into the CSS file, no hardcoding

print "<IMG class='imgstyle' SRC='hair$hair.gif'>";

naitirps 02-06-2007 07:30 PM

try this:

echo "<IMG STYLE=\"position:absolute; TOP:35px; LEFT:170px; WIDTH:50px; HEIGHT:50px\" SRC=\"hair".$hair.".gif\">";

Kard63 02-06-2007 07:40 PM

Quote:

Originally Posted by naitirps (Post 11873292)
try this:

echo "<IMG STYLE=\"position:absolute; TOP:35px; LEFT:170px; WIDTH:50px; HEIGHT:50px\" SRC=\"hair".$hair.".gif\">";

It worked beautifully. Thank you very much!

If you could explain I would cream my pants, but if you cant I am still insanely grateful. Thanks again.

octane 02-06-2007 07:54 PM

you can't use the same type of quotes (in this case double quotes) inside the string you're trying to print without escaping them.

basically your print statement starts at the first double quote and ends at the next one, which was right after STYLE=, and that caused the error.

woj 02-06-2007 08:44 PM

Quote:

Originally Posted by DjSap (Post 11873291)
A. You do not fucking do that, all styles go into the CSS file, no hardcoding

print "<IMG class='imgstyle' SRC='hair$hair.gif'>";

:thumbsup
or just escape the -> " characters

PHP-CODER-FOR-HIRE 02-06-2007 09:08 PM

Quote:

Originally Posted by DjSap (Post 11873291)
A. You do not fucking do that, all styles go into the CSS file, no hardcoding

print "<IMG class='imgstyle' SRC='hair$hair.gif'>";

If you want to be like that, you shouldn't use single quotes in HTML attributes.

The ultimate correct way is like this:

echo '<img src="whatever.gif" class="super_pic" style="border: 1px solid red;" />';


Print is not required here, nor is escaping quotes.


All times are GMT -7. The time now is 05:04 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123