[GLLUG] Syntax checking

Brad Fears fearsb@michigan.gov
Thu, 21 Mar 2002 08:30:02 -0500


You shouldn't need to worry about "bad" characters, as you should really pay more attention to those when you're inputting data.  Instead, I would use an echo statement, which will simply output whatever you want in whatever form it's already in.  You can also use the print command (not printf), which will deliver similar results.

<snippet>

        while ($myrow = mysql_fetch_row($result))
        {
        
        echo '<i>'. $myrow[2] .'</i><p>'. $myrow[0] .'<br>
                 <font size="-1">Posted by '. $myrow[1] .'</font></p>';

        }

</snippet>

You can always escape ' or " with an \ also if you wish use them within one another.  In the snippet above, I changed your <font size='-1'> tag to double quotes to avoid a parse error, but I could just as easily have used <font size=\'-1\'>.

--Brad Fears

>>> Mike Szumlinski <szumlins@msu.edu> 03/20/02 07:26PM >>>
Oops..I'm doing it all in php...here is a little snippet of what I'm
currently doing to print a journal of sorts.

<snippet>

        while ($myrow = mysql_fetch_row($result))
        {
        
        printf("<i>$myrow[2]</i><p>\n");
        printf("$myrow[0]<br>\n");
        printf("<font size='-1'>Posted by $myrow[1]</font></p>");

        }

</snippet>

$myrow[0] is a text field for a journal entry, so it definitely has the
potential to have parentheses (as well as quotation marks and anything else
bad to the printf() statement).  Is there a way to auto convert any "bad"
characters to whatever their code equivalent is (ie &nbsp = space) in html
so it doesn't break the page?

-Mike


On 3/20/02 5:12 PM, "Dpk" <dpk@egr.msu.edu> wrote:

> printf in C or perl or something else?  Can you provide a code snippet
> (grabbing and printing) as I am not quite sure the source of your
> problem.

-=--===---===---===---===-=-
|Mike Szumlinski           |
|Michigan State University |
-=--===---===---===---===-=-
"We are what we repeatedly do. Excellence, then, is not an act, but a habit"

                                                                 -Aristotle


_______________________________________________
linux-user mailing list
linux-user@egr.msu.edu
http://www.egr.msu.edu/mailman/listinfo/linux-user