Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PHP echo statement questions . . .

  • 14-01-2006 9:09pm
    #1
    Registered Users, Registered Users 2 Posts: 148 ✭✭


    Hi,

    Is it possible to change the text font and color using echo statement ?

    Thanks . . .


Comments

  • Closed Accounts Posts: 7,145 ✭✭✭DonkeyStyle \o/


    Yes... yes it is.


  • Registered Users, Registered Users 2 Posts: 5,618 ✭✭✭Civilian_Target


    With HTML output? Yes, just add the appropriate tags...


  • Registered Users, Registered Users 2 Posts: 148 ✭✭maco


    thanks . . .

    let say my php code is

    echo "this is a test";

    how do i display this with a different font and colors ? it defaulted to black at the moment . . .


  • Registered Users, Registered Users 2 Posts: 19,396 ✭✭✭✭Karoma


    As a script, or is the output to a webpage..?


  • Registered Users, Registered Users 2 Posts: 148 ✭✭maco


    Sorry for not clarifying it ...

    here my php code in html

    $query = "Select email from passpf where email = '$emailkey'";
    $result = mysql_query($query)
    or die ("Couldn't connect to database, please try again");
    $num = mysql_num_rows($result);
    echo $num;

    if ($num == 0)
    {
    echo "Email ID does not exist, please try again . . .";
    }

    I just want to display the error message in different font and text. . .

    thanks


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 673 ✭✭✭Bananna man


    maco wrote:
    Sorry for not clarifying it ...

    here my php code in html

    $query = "Select email from passpf where email = '$emailkey'";
    $result = mysql_query($query)
    or die ("Couldn't connect to database, please try again");
    $num = mysql_num_rows($result);
    echo $num;

    if ($num == 0)
    {
    echo "Email ID does not exist, please try again . . .";
    }

    I just want to display the error message in different font and text. . .

    thanks


    Try this:

    echo "<font color='red'>Email ID does not exist, please try again . . .</font>";


  • Registered Users, Registered Users 2 Posts: 148 ✭✭maco


    Thanks Bananna Man it works now . . . .


  • Subscribers Posts: 9,716 ✭✭✭CuLT


    maco, learn html before you learn php.

    Or at least learn what php is and what it is used for. It'll save you a lot of hassle.


  • Registered Users, Registered Users 2 Posts: 148 ✭✭maco


    Sorry Cult if this is a very basic question for you, I know a bit HTML already and just learning PHP, just the sysntax on how to insert color in PHP, I read PHP manual before asking it just does not mentioned there http://ie.php.net/echo, did try few combination but got syntax error. I did spend some time before asking here.


  • Registered Users, Registered Users 2 Posts: 9,283 ✭✭✭RobertFoster


    It might be beneficial to learn HTML first. PHP is all well and good, but you need to know what you want to output before you actually output it.

    When using HTML within PHP, probably the most common syntactical error that occurs is users not escaping quotation marks. HTML tags usually define values using quote:
    [html]<img src="image.jpg">
    ...
    <a href="link.html">link</a>
    ...
    <div id="main">content</div>[/html]
    ...and so on.

    PHP uses quotation marks to define statements etc. When mixing both HTML and PHP, the quotation marks used in HTML will affect PHP and cause the syntax errors. In order avoid these errors you need to "escape" quotation marks. Bananna man used single quotes ('), but you can also put a backslash infront of each HTML " in your PHP code:
    [php]echo("<img src=\"image.jpg\">");
    ...
    echo("<a href=\"link.html\">link</a>");
    ...
    echo("<div id=\"main\">content</div>");[/php]
    Like CuLT said, it will save you a lot of hassle in the long run.


  • Advertisement
  • Subscribers Posts: 9,716 ✭✭✭CuLT


    maco wrote:
    Sorry Cult if this is a very basic question for you, I know a bit HTML already and just learning PHP, just the sysntax on how to insert color in PHP, I read PHP manual before asking it just does not mentioned there http://ie.php.net/echo, did try few combination but got syntax error. I did spend some time before asking here.
    I'm not looking for an apology or trying to belittle you, php, for the purpose you are using is simply a way of outputting HTML.

    If you keep that in mind, it'll be easier to use.


  • Registered Users, Registered Users 2 Posts: 4,003 ✭✭✭rsynnott


    At this point, I would just like to point out this.


Advertisement