Welcome to Dream.In.Code
Become an Expert!

Join 150,413 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 980 people online right now. Registration is fast and FREE... Join Now!




css in php echo statement

 
Reply to this topicStart new topic

css in php echo statement

deepbluegene
26 Mar, 2008 - 05:07 AM
Post #1

New D.I.C Head
*

Joined: 13 Mar, 2007
Posts: 7


My Contributions
i have a minor coding problem.please have a look at following code.i want to set color of text "home page" through css but unable to do so.when i try to put id on h2 like "<h2 id = "homeLink">" php gives error.i am using firefox 2.0.0.12.

php:
echo "<h2><a href="index.php">Home page</a></h2>";



css:


a:link {
text-decoration: none;
color: #50c;
}

hope i have given enough information.
User is offlineProfile CardPM
+Quote Post

spearfish
RE: Css In Php Echo Statement
26 Mar, 2008 - 05:28 AM
Post #2

Monkey in Training
Group Icon

Joined: 10 Mar, 2008
Posts: 746



Thanked: 2 times
Dream Kudos: 225
My Contributions
You will have to be more specific because I see nothing wrong, as long as the CSS is either in the page itself or linked to with a link REL
User is offlineProfile CardPM
+Quote Post

thehat
RE: Css In Php Echo Statement
26 Mar, 2008 - 05:36 AM
Post #3

D.I.C Head
Group Icon

Joined: 28 Feb, 2008
Posts: 217


Dream Kudos: 100
My Contributions
You've got too many speech marks going on there. The ones in the link href are breaking the echo. Use speech marks to wrap your echo content, and within them either use apostrophes or escape the speech marks:

php

echo "<h2 id=\"homeLink\"><a href='index.php'>Home page</a></h2>";

User is offlineProfile CardPM
+Quote Post

deepbluegene
RE: Css In Php Echo Statement
26 Mar, 2008 - 06:56 AM
Post #4

New D.I.C Head
*

Joined: 13 Mar, 2007
Posts: 7


My Contributions
QUOTE(thehat @ 26 Mar, 2008 - 06:36 AM) *

You've got too many speech marks going on there. The ones in the link href are breaking the echo. Use speech marks to wrap your echo content, and within them either use apostrophes or escape the speech marks:

php

echo "<h2 id=\"homeLink\"><a href='index.php'>Home page</a></h2>";







thanks .it solved the problem.
User is offlineProfile CardPM
+Quote Post

spearfish
RE: Css In Php Echo Statement
26 Mar, 2008 - 09:02 AM
Post #5

Monkey in Training
Group Icon

Joined: 10 Mar, 2008
Posts: 746



Thanked: 2 times
Dream Kudos: 225
My Contributions
stupid.gif

Should've spotted that. I almost automatically use apostraphes while working in PHP echos I didn't even thing of it.
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Css In Php Echo Statement
26 Mar, 2008 - 05:03 PM
Post #6

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 7,166



Thanked: 78 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
QUOTE(thehat @ 26 Mar, 2008 - 06:36 AM) *

You've got too many speech marks going on there. The ones in the link href are breaking the echo. Use speech marks to wrap your echo content, and within them either use apostrophes or escape the speech marks:

php

echo "<h2 id=\"homeLink\"><a href='index.php'>Home page</a></h2>";


Exactly! You need to either escape them out, or use single quotes. The 2nd double quote will end the 1st, & if it isn't followed by the semicolon, php pukes. This is an often, overlooked type-o.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 07:45PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month