Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New Coder
    Join Date
    Feb 2010
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Post PHP Bold in text Problem

    Any ideas why bold doesnt work?

    PHP Code:
    <?php 
    $message
    ="<p><strong>Dear ";
    $title $_GET['title'];
    $fname $_GET['fname'];
    $lname $_GET['lname'];
    $email $_GET['email'];
    $message .=$title;
    $message .=" ";
    $message .=$fname;
    $message .=" ";
    $message .=$lname;
    $message .="</strong>,<br>";
    $message .="an Authorization code has been send to your email address at <b>";
    $message .=$email;
    $message .="</b></p>";
    echo(
    $message);
    ?>
    Thanks for any help in advance
    Last edited by Shinon; 02-18-2010 at 11:24 PM.

  • #2
    New Coder
    Join Date
    Feb 2010
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Example Output result at time:

    Dear Mr. giannis kostis,
    an Authorization code has been send to your email address at shinon@lavabit.com

  • #3
    Regular Coder mOrloff's Avatar
    Join Date
    Nov 2008
    Location
    The Great Pacific NW, USA
    Posts
    422
    Thanks
    8
    Thanked 6 Times in 6 Posts
    Since I'm not the most seasoned coder, I can't tell you specifically why it doesn't work, but I can tell you another (and I think better) way to get the desired results:
    CSS
    For example
    Code:
    <style type=\"text/css\">
    	.b{font-weight:bold;
    	}
    	.strong{font-weight:bold; font-style:italic;
    	}
    </style>
    PHP Code:
    $title $_GET['title'];
    $fname $_GET['fname'];
    $lname $_GET['lname'];
    $email $_GET['email'];

    $message='<p><span class="strong">Dear ';
    $message .=$title;
    $message .=' ';
    $message .=$fname;
    $message .=' ';
    $message .=$lname;
    $message .='</span>,<br>';
    $message .='an Authorization code has been send to your email address at <span class="b">';
    $message .=$email;
    $message .='</span></p>';

    echo(
    $message); 
    That seems like it should work.
    ~ Mo

  • Users who have thanked mOrloff for this post:

    Shinon (02-18-2010)

  • #4
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    Try changing to this to see if it works.

    PHP Code:
    <?php
    $title 
    $_GET['title'];
    $fname $_GET['fname'];
    $lname $_GET['lname'];
    $email $_GET['email'];
    $message="<p><strong>Dear $title $fname $lname </strong>,<br>an Authorization code has been send to your email address at <b>$email</b></p>";
    echo(
    $message);
    ?>
    Or else try this

    PHP Code:
    <?php
    $title 
    $_GET['title'];
    $fname $_GET['fname'];
    $lname $_GET['lname'];
    $email $_GET['email'];
    $message="<p><strong>Dear $title $fname $lname </strong>,<br>an Authorization code has been send to your email address at <b>$email</b></p>";
    echo 
    "$message";
    ?>
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Works for me with no changes (aside from missing error checking).
    You sending it as plain text to the browser?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #6
    New Coder
    Join Date
    Feb 2010
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Smile

    Thanks a lot ^^

    The span and CSS work pefrect

    Only one small coding problem in your code, which is:
    PHP Code:
    $message='<p><span class="strong">Dear '
    should be
    PHP Code:
    $message="<p><span class=\"strong\">Dear "
    U forgot the 2 slashes \

    Thanks a lot.
    Doing an Evoting Webpage, so I think u will hearing from me soon again
    Last edited by Shinon; 02-18-2010 at 11:29 PM.

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Quote Originally Posted by Shinon View Post
    Thanks a lot ^^

    The span and CSS work pefrect

    Only one small coding problem in your code, which is:
    PHP Code:
    $message='<p><span class="strong">Dear '
    should be
    PHP Code:
    $message="<p><span class=\"strong\">Dear "
    U forgot the 2 slashes \

    Thanks a lot.
    Doing an Evoting Webpage, so I think u will hearing from me soon again
    Since there is no variable expansion occurring in that particular block of code, single quoted text with double quotes is perfectly fine.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #8
    New Coder
    Join Date
    Aug 2003
    Location
    Derby, UK
    Posts
    97
    Thanks
    0
    Thanked 14 Times in 14 Posts
    Quote Originally Posted by mOrloff View Post
    but I can tell you another (and I think better)way to get the desired results:
    CSS
    For example
    Code:
    <style type=\"text/css\">
    	.b{font-weight:bold;
    	}
    	.strong{font-weight:bold; font-style:italic;
    	}
    </style>
    Sorry to disagree as I know you were trying to be helpful, but actually it is better practice generally to use semantic markup like <strong> and <em> and then apply styles to those, rather than define your own class styles to replicate their visual behavior.

    Using semantic tags means the content has meaning without the CSS so for example text browsers (including search engine spiders) can readily identify that this text has special significance. Futhermore there are default behaviours in different browsers for standard tags which you are arbitrarily overriding with your own visual only style.

    Another example: I am no expert but I imagine browsers for the visually impaired use an audio emphasis for <strong> and <em> but they are unlikely to do the same for your class stlyled bits.

    My general rule of thumb: the HTML should convey as much meaning as possible if you remove the CSS completely.

    Just my 2p

  • #9
    New Coder
    Join Date
    Aug 2003
    Location
    Derby, UK
    Posts
    97
    Thanks
    0
    Thanked 14 Times in 14 Posts
    As to the original problem, what client were you viewing it in and did you look at the source code? The code should work fine, it may be that b and strong tags have their behavior modified somewhere? If you have a URL I will happily take a look. Or you could stick with the span class solution, just seems a little unnecessary to me.

    Regards,

    Dai

  • #10
    Regular Coder mOrloff's Avatar
    Join Date
    Nov 2008
    Location
    The Great Pacific NW, USA
    Posts
    422
    Thanks
    8
    Thanked 6 Times in 6 Posts
    Quote Originally Posted by DaiWelsh View Post
    Sorry to disagree ..., but actually it is better practice generally to use semantic markup like <strong> and <em> and then apply styles to those, rather than define your own class styles to replicate their visual behavior ...
    I like that.
    When I went through a bunch of tut's, most of them suggested stripping everything down with a reset css, then just starting fresh, but none of them suggested retaining the HTML semantics. (To the contrary, the two which I ended up following most closely drilled the point to keep all stylizing out of HTML, and do it all via CSS.)
    Your point is logical, and I like it.
    Thanks for the feedback.

    Quote Originally Posted by DaiWelsh View Post
    ... I imagine browsers for the visually impaired use an audio emphasis for <strong> and <em> ...
    Yeah, I think you're right. (Seeing as how my father-in-law is blind, you'd think I would have remembered that :-)

    ~ Mo

  • #11
    New Coder
    Join Date
    Aug 2003
    Location
    Derby, UK
    Posts
    97
    Thanks
    0
    Thanked 14 Times in 14 Posts
    Quote Originally Posted by mOrloff View Post
    I like that.
    When I went through a bunch of tut's, most of them suggested stripping everything down with a reset css, then just starting fresh
    by a reset CSS you mean taking off default padding etc.? I do that, but I don't take off bold etc. just the things that tend to be inconsistent between browsers like padding.

    Quote Originally Posted by mOrloff View Post
    but none of them suggested retaining the HTML semantics.
    Interesting,, any links? I am surprised they didn't mention semantic HTML, but then there are many ways to skin a cat.

    Quote Originally Posted by mOrloff View Post
    (To the contrary, the two which I ended up following most closely drilled the point to keep all stylizing out of HTML, and do it all via CSS.)
    I would agree with that statement as written, I would keep all stylizing out of HTML, which is why I would not suggest <b> and <i>. However <strong> and <em> are not style tags they are semantic (meaning) tags, they state that the text within is to be emphasised (never quite considered how the two differ, strong and emphasis seem synonymous to me, but...). You can (and should) choose to apply visual styles to those tags in your screen css style sheet because on screen we often convey emphasis with bold and/or italics, though color is another option. However the HTML itself doesn't hold any style information just the fact that those bits of text has particular significance..

    The key is to view the HTML and the CSS (of which there may be several an/or none in different scenarios) as totally seperate documents. The HTML should make sense if it has no CSS associated with it whatsoever and ideally would be reasonably readable in a browser without any CSS. This document is for non-CSS browsers to use as is, particularly search engines,but also screen readers etc.

    The CSS for screen applies any visual styling that is relevant for screen display, the print CSS for print and presumably other CSS for other media, though I have never gone beyond those two.

    I generally make the HTML as simple as possible, so <h1>-<h5> for headings (though rarely use more than 3), <p> for text paragraphs <hr> for seperators, <div> to delineate significant sections of the content. Then where necessary (with the emphasis on minimising) add <div> and <span> as hooks for styles in your stylesheet.

    CSS2 is good enough to achieve most designs with this approach (if you can't it is usually a sign the designer is thinking in print), CSS3 promises to make it even more practical.

    Just my 2p and belongs more in a different forum, but fwiw...

  • #12
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Quote Originally Posted by mOrloff View Post
    When I went through a bunch of tut's, most of them suggested stripping everything down with a reset css, then just starting fresh, but none of them suggested retaining the HTML semantics. (To the contrary, the two which I ended up following most closely drilled the point to keep all stylizing out of HTML, and do it all via CSS.)
    Style and semantic meaning are generally two completely different things. I know what you mean with the info on the net though. There is more conflicting information than you can shake a stick at. I pretty much think balls to it now and just do it as I think best. I try to make the source as descriptive as possible, (which impacts page size slightly due to classes when they're not strictly necessary), try to use the best tags for the purpose whilst avoiding the ones which only have style meaning and then just do the general layout and styling with the CSS.

    There really is so much contradictory information though, (and validators contradict themselves with their recommendations a good percentage the time too), that you're better off, (in my opinion), just trying to go with the method of making the bare source meaningful and then use the CSS to make the rendered output look nice, if that makes sense. Page size, semantics etc all seem to be pretty much working against each other though. It seems to be a compromise all ways round.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •