/    Sign up×
Community /Pin to ProfileBookmark

How to stylize a bit of php code?

I want to try to stylize this piece of php code so that when it displays, I can give it a color and font style and size..

[code=php]if (!$resp->is_valid) {
die (“Your CAPTCHA Code wasn’t entered correctly. Go back and try it again.”);
}[/code]

well, if I try to do something simple like apply a DIV around it like this, it breaks the php from functioning correctly by giving [I]Warning: Cannot modify header information – headers already sent[/I]

[code=php]<div style=”color:#FF0000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:14px;”>
if (!$resp->is_valid) {
die (“Your CAPTCHA Code wasn’t entered correctly. Go back and try it again.”);
}
</div>[/code]

and if I try this method, it simply does not display the style..

[code=php]if (!$resp->is_valid) {
die (“<span style=’font-size: 14px;color:#FF0000;’>Your CAPTCHA Code wasn’t entered correctly</span>. Go back and try it again.”);
}[/code]

any other methods to recommend or see an error in my methods?

to post a comment
CSS

7 Comments(s)

Copy linkTweet thisAlerts:
@qjensenSep 14.2010 — If you look at the page source you will see that the style info is there, but the formatting is off.

You don't have to escape single quotes inside double quotes. Remove the slashes to escape the single quotes and it works fine - at least on the simple test I ran.

Quint Jensen

[url="http://www.scaled-solutions.com]Web Developer[/url]

Scaled Solutions
Copy linkTweet thisAlerts:
@DanInMASep 14.2010 — I'm not familair with php as of yet but your not closing the span correctly. You should use </span> not </style> . Perhaps changing it will help.

I did read some info about php strings and it appears you are escaping the single qoutes correctly.
Copy linkTweet thisAlerts:
@etardauthorSep 14.2010 — I'm not familair with php as of yet but your not closing the span correctly. You should use </span> not </style> . Perhaps changing it will help.

I did read some info about php strings and it appears you are escaping the single qoutes correctly.[/QUOTE]


oops.. in that 3rd example I didn't catch the wrong closing tag and see it should be </span>.. however, that did not allow the style to render so I will look into qjensen's remarks next....
Copy linkTweet thisAlerts:
@etardauthorSep 14.2010 — If you look at the page source you will see that the style info is there, but the formatting is off.

You don't have to escape single quotes inside double quotes. Remove the slashes to escape the single quotes and it works fine - at least on the simple test I ran.

Quint Jensen

[url="http://www.scaled-solutions.com]Web Developer[/url]

Scaled Solutions[/QUOTE]


thanks.. you nailed it. it was my slashes so the correct format is...

[code=php]die ("<span style='font-size: 14px;color:#FF0000;'>Your CAPTCHA Code wasn't entered correctly. <a href="javascript:history.go(-1)">Go back</a> and try it again.</span>");[/code]
Copy linkTweet thisAlerts:
@etardauthorSep 14.2010 — BTW.. any idea why other styles would not be adhered to? for example, I added in

[I]margin-top:75px[/I]

to bump the text output down a bit, but that style is being disregarded while the others are rendered.
Copy linkTweet thisAlerts:
@qjensenSep 14.2010 — span is an inline element, not a block element. Change your span to a div and you will get the result you want.
Copy linkTweet thisAlerts:
@etardauthorSep 14.2010 — d'oh.. I feel like such a tard (hence my user name).

thanks again for pointing out the obvious. tip.. don't stay up all night coding - you make dumb errors
×

Success!

Help @etard spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...