Results 1 to 20 of 20

Thread: Style tags

  1. #1

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819

    Style tags

    The book I'm reading is not helpful with this. I understand that html style tags must be surrounded with double quotes. When I do that, my PHP code doesn't work. When I take the double_quotes away, the formatting is wrong. What am I doing wrong? I've tried these three ways:

    $UserName, $Date and $Comments are being pulled from a mySQL database. That part works.

    Replace double-quotes with single quotes. Really screwed up output doing this.
    print("<table border=‘0’ cellpadding=‘0’ cellspacing=‘0’ style=‘border-collapse: collapse’ width=‘100%’ id=‘AutoNumber1’>
    <tr>
    <td width=‘100%’ colspan=‘2’ bgcolor=‘#3366CC’ style=‘border-style: solid; border-width: 1; padding: 4’ bordercolor=‘#000000’ bordercolorlight=‘#000000’ bordercolordark=‘#000000’>&nbsp;</td>
    </tr>
    <tr>
    <td width=‘50%’ style=‘border:1px solid #000000; padding:4; ‘ bgcolor=‘#FF6666’ bordercolorlight=‘#000000’ bordercolordark=‘#000000’>
    <p style=‘text-align: left’><b><font face=‘Arial’>$UserName</font></b></td>
    <td width=‘50%’ style=‘border:1px solid #000000; padding: 4’ bgcolor=‘#FF6666’ bordercolorlight=‘#000000’ bordercolordark=‘#000000’>
    <p style=‘text-align: right’><b><font face=‘Arial’>$Date</font></b></td>
    </tr>
    <tr>
    <td width=‘100%’ colspan=‘2’ bgcolor=‘#FFFFFF’ style=‘border:1px solid #000000; padding:4; ‘ bordercolorlight=‘#000000’ bordercolordark=‘#000000’>
    <font face=‘Arial’ size=‘2’>$Comments</font></td>
    </tr>
    <tr>
    <td width=‘100%’ bgcolor=‘#3366CC’ colspan=‘2’ style=‘border:1px solid #000000; padding:4; ‘ bordercolorlight=‘#000000’ bordercolordark=‘#000000’>&nbsp;</td>
    </tr>
    </table>");
    Retaining the double quotes as follows results in no PHP output at all:
    print("<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" id="AutoNumber1">
    <tr>
    <td width="100%" colspan="2" bgcolor="#3366CC" style="border-style: solid; border-width: 1; padding: 4" bordercolor="#000000" bordercolorlight="#000000" bordercolordark="#000000">&nbsp;</td>
    </tr>
    <tr>
    <td width="50%" style="border:1px solid #000000; padding:4; " bgcolor="#FF6666" bordercolorlight="#000000" bordercolordark="#000000">
    <p style="text-align: left"><b><font face="Arial">$UserName</font></b></td>
    <td width="50%" style="border:1px solid #000000; padding: 4" bgcolor="#FF6666" bordercolorlight="#000000" bordercolordark="#000000">
    <p style="text-align: right"><b><font face="Arial">$Date</font></b></td>
    </tr>
    <tr>
    <td width="100%" colspan="2" bgcolor="#FFFFFF" style="border:1px solid #000000; padding:4; " bordercolorlight="#000000" bordercolordark="#000000">
    <font face="Arial" size="2">$Comments</font></td>
    </tr>
    <tr>
    <td width="100%" bgcolor="#3366CC" colspan="2" style="border:1px solid #000000; padding:4; " bordercolorlight="#000000" bordercolordark="#000000">&nbsp;</td>
    </tr>
    </table>");
    removing the quotes altogether gets me closest, but some things are wrong. For example, the date should be right aligned, but it ends up being left aligned:
    print("<table border=0 cellpadding=0 cellspacing=0 style=border-collapse: collapse width=100% id=AutoNumber1>
    <tr>
    <td width=100% colspan=2 bgcolor=#3366CC style=border-style: solid; border-width: 1; padding: 4 bordercolor=#000000 bordercolorlight=#000000 bordercolordark=#000000>&nbsp;</td>
    </tr>
    <tr>
    <td width=50% style=border:1px solid #000000; padding:4; bgcolor=#FF6666 bordercolorlight=#000000 bordercolordark=#000000>
    <p style=text-align: left><b><font face=Arial>$UserName</font></b></td>
    <td width=50% style=border:1px solid #000000; padding: 4 bgcolor=#FF6666 bordercolorlight=#000000 bordercolordark=#000000>
    <p style=text-align: right><b><font face=Arial>$Date</font></b></td>
    </tr>
    <tr>
    <td width=100% colspan=2 bgcolor=#FFFFFF style=border:1px solid #000000; padding:4; bordercolorlight=#000000 bordercolordark=#000000>
    <font face=Arial size=2>$Comments</font></td>
    </tr>
    <tr>
    <td width=100% bgcolor=#3366CC colspan=2 style=border:1px solid #000000; padding:4; bordercolorlight=#000000 bordercolordark=#000000>&nbsp;</td>
    </tr>
    </table>");

  2. #2
    Addicted Member Martin Wilson's Avatar
    Join Date
    Mar 2002
    Location
    :)
    Posts
    236
    Stick a \ before the double quotes:

    echo "This \"will\" work<br>";
    What is the answer to this question?

  3. #3

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    so I just paste it into Word then replace all " with \". Outstanding. Thank you Mr. Wilson.

  4. #4

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    OK, I'm just not getting this.

    This is how it's supposed to look:

    http://www.paulkjohnson.com/modelbuilding/test.htm

    This is the exact same code converted to PHP with the quotes replaced with \"

    http://www.paulkjohnson.com/modelbuilding/test.php

  5. #5
    scoutt
    Guest
    those were 2 totally different pages. what is the code you are trying to get to work?

  6. #6

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    They're supposed to be the same. I took the html from the "normal" page, put it in word, replaced the double quotes with backslash + double quote

    " = \"

    and that's what happened.

    Before:

    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" id="AutoNumber1">
    <tr>
    <td width="100%" colspan="2" bgcolor="#3366CC" style="border-style: solid; border-width: 1; padding: 4" bordercolor="#000000" bordercolorlight="#000000" bordercolordark="#000000">&nbsp;</td>
    </tr>
    <tr>
    <td width="50%" style="border:1px solid #000000; padding:4; " bgcolor="#FF6666" bordercolorlight="#000000" bordercolordark="#000000">
    <p style="text-align: left"><b><font face="Arial">User name</font></b></td>
    <td width="50%" style="border:1px solid #000000; padding: 4" bgcolor="#FF6666" bordercolorlight="#000000" bordercolordark="#000000">
    <p style="text-align: right"><b><font face="Arial">Date</font></b></td>
    </tr>
    <tr>
    <td width="100%" colspan="2" bgcolor="#FFFFFF" style="border:1px solid #000000; padding:4; " bordercolorlight="#000000" bordercolordark="#000000">
    <font face="Arial" size="2">Comments</font></td>
    </tr>
    <tr>
    <td width="100%" bgcolor="#3366CC" colspan="2" style="border:1px solid #000000; padding:4; " bordercolorlight="#000000" bordercolordark="#000000">&nbsp;</td>
    </tr>
    </table>
    After:
    print("<table border=\”0\” cellpadding=\”0\” cellspacing=\”0\” style=\”border-collapse: collapse\” width=\”100%\” id=\”AutoNumber1\”>
    <tr>
    <td width=\”100%\” colspan=\”2\” bgcolor=\”#3366CC\” style=\”border-style: solid; border-width: 1; padding: 4\” bordercolor=\”#000000\” bordercolorlight=\”#000000\” bordercolordark=\”#000000\”>&nbsp;</td>
    </tr>
    <tr>
    <td width=\”50%\” style=\”border:1px solid #000000; padding:4; \” bgcolor=\”#FF6666\” bordercolorlight=\”#000000\” bordercolordark=\”#000000\”>
    <p style=\”text-align: left\”><b><font face=\”Arial\”>$UserName</font></b></td>
    <td width=\”50%\” style=\”border:1px solid #000000; padding: 4\” bgcolor=\”#FF6666\” bordercolorlight=\”#000000\” bordercolordark=\”#000000\”>
    <p style=\”text-align: right\”><b><font face=\”Arial\”>$Date</font></b></td>
    </tr>
    <tr>
    <td width=\”100%\” colspan=\”2\” bgcolor=\”#FFFFFF\” style=\”border:1px solid #000000; padding:4; \” bordercolorlight=\”#000000\” bordercolordark=\”#000000\”>
    <font face=\”Arial\” size=\”2\”>$Comments</font></td>
    </tr>
    <tr>
    <td width=\”100%\” bgcolor=\”#3366CC\” colspan=\”2\” style=\”border:1px solid #000000; padding:4; \” bordercolorlight=\”#000000\” bordercolordark=\”#000000\”>&nbsp;</td>
    </tr>
    </table>");

  7. #7
    scoutt
    Guest
    it looks ok to me. but if you are going to put all that into one print commend then just take the print out and make it regular html.

  8. #8

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    Because I don't know html, php or mysql.

    Really, I've always used front page. But I'm trying to learn php and mySQL which is making me learn html too. So I'm taking on three things at once.

    The reason I'm putting it in the php is because of the fields from the database. I don't know another way to do it. Basically, I just took the example from the book and converted it as well as I could. I'm really lost here and the tutorials I've come across don't help much.

    The book (php4) just had standard borders with no styles at all. So it didn't help. But it showed me how to connect to the database and such.

    Can you show me how to split it up better please? I'm assuming I can use the print command to just put the fields in the middle of the html, but I've tried that too with resounding failure.

  9. #9
    scoutt
    Guest
    Try this one first. somethnig looked funny about your "
    Code:
    echo"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" width=\"100%\" id=\"AutoNumber1\">
    <tr>
    <td width=\"100%\" colspan=\"2\" bgcolor=\"#3366CC\" style=\"border-style: solid; border-width: 1; padding: 4\" bordercolor=\"#000000\" bordercolorlight=\"#000000\" bordercolordark=\"#000000\"> </td>
    </tr>
    <tr>
    <td width=\"50%\" style=\"border:1px solid #000000; padding:4; \" bgcolor=\"#FF6666\" bordercolorlight=\"#000000\" bordercolordark=\"#000000\">
    <p style=\"text-align: left\"><b><font face=\"Arial\">$UserName</font></b></td>
    <td width=\"50%\" style=\"border:1px solid #000000; padding: 4\" bgcolor=\"#FF6666\" bordercolorlight=\"#000000\" bordercolordark=\"#000000\">
    <p style=\"text-align: right\"><b><font face=\"Arial\">$Date</font></b></td>
    </tr>
    <tr>
    <td width=\"100%\" colspan=\"2\" bgcolor=\"#FFFFFF\" style=\"border:1px solid #000000; padding:4; \" bordercolorlight=\"#000000\" bordercolordark=\"#000000\">
    <font face=\"Arial\" size=\"2\">$Comments</font></td>
    </tr>
    <tr>
    <td width=\"100%\" bgcolor=\"#3366CC\" colspan=\"2\" style=\"border:1px solid #000000; padding:4; \" bordercolorlight=\"#000000\" bordercolordark=\"#000000\"> </td>
    </tr>
    </table>";

  10. #10

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    OK, that is much better. The first blue row in the table is missing now, but the rest is the way it's supposed to be. Can you give me the cliff's notes on what you did? Was it just a change to echo or is there more to it? I'll look at the code and see if I can tell the difference, but since I don't know html, I doubt I'll understand it.

  11. #11

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    Oh yeah... Thanks

  12. #12
    scoutt
    Guest
    well I did change teh print to echo but that didn't make a difference. they will do the same job. all I did was change your ” to "

    what did you use? they don't look like quotes, that is all I did.

    your welcome and have fun.

  13. #13

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    I used Word. Maybe it replaced them with "Smart quotes." OK, that's probably the problem. I'll put it in another editor next time. Much faster than manually going through and changing it.

    Thanks again.

  14. #14

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    Just for S and G's, I changed it back to print and it works fine. It was the quotes. The blue row was collapsing because there is no text in it. I'm sure there's a way to handle that in HTML, but until I figure out what it is, I just put a space character in it and it's doing what it's supposed to now.

    Thanks.

    Stay tuned... more questions will be coming soon.

  15. #15
    scoutt
    Guest
    good job.

    that is correct by the way. if your table cell has nothing in it it will not render correctly. always have at least something in it like &amp;nbsp; is all it needs.

  16. #16

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    ok, this is what I've got.

    The next thing I'm going to be asking about is creating an input form that a user can use to flame my site.

    I'll go ahead and construct the form and do what I can and if I have problems I'll start a new thread. My book talks about it a bit. My main concern is that it mentioned that people can put html code into the fields that will execute, possibly maliciously, when the page the fields from the database get displayed.

    Of course I don't want that to happen, but the first thing I want to do is get the form working at all. Then I'll try to figure out the security. It did say something about how to prevent it, but I didn't really understand what they were talking about.

    here's where it stands now.

    http://www.paulkjohnson.com/modelbuilding/test.php

    Thanks again for all the help.

  17. #17

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    Sorry, scoutt. You're in the guest book now. See what you get for helping? Go back and refresh the page.

  18. #18
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    there are a number of built in functions you can use to remove malicious user input

    check out strip_tags(), htmlspecialchars(), addslashes(), stripslashes()

  19. #19

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    oh yeah... gotta add chrisjk too

    If you guys don't like what I'm doing in your name, just say so and I'll remove it. It's just for learning purposes. If I actually do implement it, I'm going to clear out the database before I do.

    Thanks again for your help.

  20. #20
    scoutt
    Guest


    ya chris doesn't have a reputation

    it doesn't bother me...

Posting Permissions

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



Click Here to Expand Forum to Full Width