Bizarre (to me) result: intermittent garbled output

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ethan

    Bizarre (to me) result: intermittent garbled output

    I've been having some really weird problems with a very simple PHP
    app. I'm wondering if anyone can help me sort this out.

    I have a page that prints out the results of a MySQL query as an HTML
    table using a for loop: nothing too exotic there.

    However, sometimes one column shows the data it's supposed to contain,
    and sometimes it doesn't. (The name of the field is "category". ) I
    checked the actual DB data. The data is there.

    That's not all. I just visited the page and got the result below. PHP
    has inserted "(" characters between the table rows. I can see how
    maybe a syntax error could cause that, but why would it only happen
    sometimes?

    Why does that column of data disappear and then reappear when I visit
    the page later?

    Php code and HTML output are given below.

    Setup information:

    FreeBSD 4.7
    PHP 4.3.8
    Zend Optimizer 2.5.1
    MySQL 4.0.18

    --------------------------------------------------------------------------
    PHP CODE
    --------------------------------------------------------------------------

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>AFWH Website Admin</title>
    <? include("../include/headerItems.htm "); ?>
    </head>

    <body>
    <?
    $con = mysql_connect(" localhost", "MYUSERNAME ", "MYPASSWORD ");
    if (!$con)
    {
    echo "Error connecting to DB";
    }
    mysql_select_db ("articles") ;
    $statement = "SELECT * FROM articles";
    $result = mysql_query($st atement);
    ?>

    <h1 id="pageTitle"> <? echo mysql_num_rows( $result); ?>
    articles</h1>
    <p id="menu"><a href="articleFo rmIn.php">Add article</a> | <a
    href="listArtic les.php">List all</a></p>
    <table id="articleList ing">
    <tr>
    <td>Filename</td>
    <td>Category</td>
    <td>Title</td>
    <td>Date</td>
    <td>Publish</td>
    <td>&nbsp;</td>
    <td>Idx. pg. code</td>
    </tr>
    <?
    $rowClass = "white";
    for ($i = 0 ; $i < mysql_num_rows( $result) ; $i++)
    {
    if ($rowClass == "white")
    {
    $rowClass = "grey";
    } else {
    $rowClass = "white";
    }
    $row = mysql_fetch_arr ay($result);
    ?>

    <tr class="<? echo $rowClass; ?>">
    <td><? echo $row["filename"]; ?>
    </td>

    <td><? echo $row["category"]; ?>
    </td>

    <td><a href='editArtic le.php?id=<? echo $row["ID"]; ?>'>
    <? echo $row["title"]; ?>: <? echo $row["subtitle"]; ?>
    </a></td>

    <td><? echo $row["date"]; ?>
    </td>

    <td>
    Publish >
    <a href="publish.p hp?id=<? echo $row["ID"] ?>&curr=1">Curr ent</a>
    |
    <a href="publish.p hp?id=<? echo $row["ID"] ?>&curr=0">Arch ive</a>
    </td>

    <td>
    <a href="deleteCon firm.php?id=<? echo $row["ID"] ?>">DEL from
    DB</a>
    </td>

    <td><a href='indexPgCo de.php?id=<? echo $row["ID"]; ?>'>Snippet</a>
    </td>
    </tr><?
    }
    ?>
    </table>
    </body>
    </html>


    --------------------------------------------------------------------------
    RESULTING HTML OUTPUT
    --------------------------------------------------------------------------

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>AFWH Website Admin</title>
    <meta http-equiv="Content-type"
    content="text/html; charset=us-ascii" />
    <meta http-equiv="Content-Language"
    content="en-us" />
    <meta name="ROBOTS"
    content="NONE" />
    <style type="text/css">
    /*<![CDATA[*/
    @import url(/admin/css/admin.css);
    /*]]>*/
    </style> </head>

    <body>

    <h1 id="pageTitle"> 12 articles</h1>

    <p id="menu"><a href="articleFo rmIn.php">Add article</a> | <a
    href="listArtic les.php">List all</a></p>
    <table id="articleList ing">
    <tr>
    <td>Filename</td>
    <td>Category</td>
    <td>Title</td>

    <td>Date</td>
    <td>Publish</td>
    <td>&nbsp;</td>
    <td>Idx. pg. code</td>
    </tr>

    ( <tr class="grey">
    <td>/articles/free/newmodelofarous al.htm </td>


    <td> </td>

    <td><a href='editArtic le.php?id=8'>
    A New Model of Arousal: At mid-life, desire may need a
    jump start </a></td>

    <td>April, 2004 </td>

    <td>
    Publish >
    <a href="publish.p hp?id=8&curr=1" >Current</a> |
    <a href="publish.p hp?id=8&curr=0" >Archive</a>

    </td>

    <td>
    <a href="deleteCon firm.php?id=8"> DEL from DB</a>
    </td>

    <td><a href='indexPgCo de.php?id=8'>Sn ippet</a>
    </td>
    </tr>
    ( <tr class="white">

    <td>/articles/free/combattingdepre ssion.htm
    </td>

    <td> </td>

    <td><a href='editArtic le.php?id=9'>
    Combatting Depression with a Better Diet: What omega-3
    fatty acids can do for you </a></td>

    <td>April, 2004 </td>

    <td>
    Publish >
    <a href="publish.p hp?id=9&curr=1" >Current</a> |
    <a href="publish.p hp?id=9&curr=0" >Archive</a>

    </td>

    <td>
    <a href="deleteCon firm.php?id=9"> DEL from DB</a>
    </td>

    <td><a href='indexPgCo de.php?id=9'>Sn ippet</a>
    </td>
    </tr>
    ( <tr class="grey">

    <td>/articles/paid/october_04/troublesleeping .htm
    </td>

    <td>SLEEP </td>

    <td><a href='editArtic le.php?id=27'>
    More Trouble Sleeping than Your Spouse?: Anxiety or
    Depression May Be the Problem </a></td>

    <td>October, 2004 </td>

    <td>
    Publish >
    <a href="publish.p hp?id=27&curr=1 ">Current</a> |
    <a href="publish.p hp?id=27&curr=0 ">Archive</a>

    </td>

    <td>
    <a href="deleteCon firm.php?id=27" >DEL from DB</a>
    </td>

    <td><a href='indexPgCo de.php?id=27'>S nippet</a>
    </td>
    </tr>
    ( <tr class="white">

    <td>/articles/paid/october_04/beyondcholester ol.htm
    </td>

    <td>SELFCARE </td>

    <td><a href='editArtic le.php?id=28'>
    Predicting Heart Disease: Beyond Cholesterol
    </a></td>

    <td>October, 2004 </td>

    <td>
    Publish >
    <a href="publish.p hp?id=28&curr=1 ">Current</a> |
    <a href="publish.p hp?id=28&curr=0 ">Archive</a>

    </td>

    <td>
    <a href="deleteCon firm.php?id=28" >DEL from DB</a>
    </td>

    <td><a href='indexPgCo de.php?id=28'>S nippet</a>
    </td>
    </tr>
    ( <tr class="grey">

    <td>/articles/free/controversyover kegels.htm
    </td>

    <td> </td>

    <td><a href='editArtic le.php?id=11'>
    The Controversy over Kegels: Are women doing them
    correctly? </a></td>

    <td>June, 2004 </td>

    <td>
    Publish >
    <a href="publish.p hp?id=11&curr=1 ">Current</a> |
    <a href="publish.p hp?id=11&curr=0 ">Archive</a>

    </td>

    <td>
    <a href="deleteCon firm.php?id=11" >DEL from DB</a>
    </td>

    <td><a href='indexPgCo de.php?id=11'>S nippet</a>
    </td>
    </tr>
    ( <tr class="white">

    <td>/articles/free/recurringnightm ares.htm
    </td>

    <td> </td>

    <td><a href='editArtic le.php?id=12'>
    Recurring Nightmares and Post-traumatic Stress: Twice as
    many women suffer as men </a></td>

    <td>April, 2004 </td>

    <td>
    Publish >
    <a href="publish.p hp?id=12&curr=1 ">Current</a> |
    <a href="publish.p hp?id=12&curr=0 ">Archive</a>

    </td>

    <td>
    <a href="deleteCon firm.php?id=12" >DEL from DB</a>
    </td>

    <td><a href='indexPgCo de.php?id=12'>S nippet</a>
    </td>
    </tr>
    ( <tr class="grey">

    <td>/articles/paid/october_04/testosterone.ht m
    </td>

    <td>INTERVIEW </td>

    <td><a href='editArtic le.php?id=29'>
    Is Testosterone the Answer to Low Libido?: Researcher
    Susan Davis tells when and how it works </a></td>

    <td> </td>

    <td>
    Publish >
    <a href="publish.p hp?id=29&curr=1 ">Current</a> |
    <a href="publish.p hp?id=29&curr=0 ">Archive</a>

    </td>

    <td>
    <a href="deleteCon firm.php?id=29" >DEL from DB</a>
    </td>

    <td><a href='indexPgCo de.php?id=29'>S nippet</a>
    </td>
    </tr>
    ( <tr class="white">

    <td>/articles/free/sexafterprostat e.htm </td>

    <td> </td>

    <td><a href='editArtic le.php?id=14'>
    Sex after Prostate Surgery: What every couple needs to
    know </a></td>

    <td>April, 2004 </td>

    <td>
    Publish >
    <a href="publish.p hp?id=14&curr=1 ">Current</a> |
    <a href="publish.p hp?id=14&curr=0 ">Archive</a>

    </td>

    <td>
    <a href="deleteCon firm.php?id=14" >DEL from DB</a>
    </td>

    <td><a href='indexPgCo de.php?id=14'>S nippet</a>
    </td>
    </tr>
    ( <tr class="grey">

    <td>/articles/free/copingwithpms.h tm </td>

    <td> </td>

    <td><a href='editArtic le.php?id=15'>
    Coping with PMS: Can low-dose antidepressants help?
    </a></td>

    <td>April, 2004 </td>

    <td>
    Publish >
    <a href="publish.p hp?id=15&curr=1 ">Current</a> |
    <a href="publish.p hp?id=15&curr=0 ">Archive</a>

    </td>

    <td>
    <a href="deleteCon firm.php?id=15" >DEL from DB</a>
    </td>

    <td><a href='indexPgCo de.php?id=15'>S nippet</a>
    </td>
    </tr>
    ( <tr class="white">

    <td>/articles/free/destress.htm </td>

    <td> </td>

    <td><a href='editArtic le.php?id=17'>
    How to De-Stress: A Brief Guide to Relaxation Tools
    </a></td>

    <td>June, 2004 </td>

    <td>
    Publish >
    <a href="publish.p hp?id=17&curr=1 ">Current</a> |
    <a href="publish.p hp?id=17&curr=0 ">Archive</a>

    </td>

    <td>
    <a href="deleteCon firm.php?id=17" >DEL from DB</a>
    </td>

    <td><a href='indexPgCo de.php?id=17'>S nippet</a>
    </td>
    </tr>
    ( <tr class="grey">

    <td>/articles/free/erectiledysfunc tion.htm
    </td>

    <td>ABOUT MEN </td>

    <td><a href='editArtic le.php?id=19'>
    Straight Talk About Erectile Dysfunction: When the Body
    Won\'t Respond </a></td>

    <td>February, 2004 </td>

    <td>
    Publish >
    <a href="publish.p hp?id=19&curr=1 ">Current</a> |
    <a href="publish.p hp?id=19&curr=0 ">Archive</a>

    </td>

    <td>
    <a href="deleteCon firm.php?id=19" >DEL from DB</a>
    </td>

    <td><a href='indexPgCo de.php?id=19'>S nippet</a>
    </td>
    </tr>
    ( <tr class="white">

    <td>/articles/free/fightingfatigue .htm </td>

    <td> </td>

    <td><a href='editArtic le.php?id=21'>
    Fighting Fatigue: How to get a more satisfying sleep
    </a></td>

    <td>February, 2004 </td>

    <td>
    Publish >
    <a href="publish.p hp?id=21&curr=1 ">Current</a> |
    <a href="publish.p hp?id=21&curr=0 ">Archive</a>

    </td>

    <td>
    <a href="deleteCon firm.php?id=21" >DEL from DB</a>
    </td>

    <td><a href='indexPgCo de.php?id=21'>S nippet</a>
    </td>
    </tr> </table>

    </body>
    </html>
Working...