473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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($statement);
?>

<h1 id="pageTitle"><? echo mysql_num_rows($result); ?>
articles</h1>
<p id="menu"><a href="articleFormIn.php">Add article</a> | <a
href="listArticles.php">List all</a></p>
<table id="articleListing">
<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_array($result);
?>

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

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

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

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

<td>
Publish >
<a href="publish.php?id=<? echo $row["ID"] ?>&curr=1">Current</a>
|
<a href="publish.php?id=<? echo $row["ID"] ?>&curr=0">Archive</a>
</td>

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

<td><a href='indexPgCode.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="articleFormIn.php">Add article</a> | <a
href="listArticles.php">List all</a></p>
<table id="articleListing">
<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/newmodelofarousal.htm </td>
<td> </td>

<td><a href='editArticle.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.php?id=8&curr=1">Current</a> |
<a href="publish.php?id=8&curr=0">Archive</a>

</td>

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

<td><a href='indexPgCode.php?id=8'>Snippet</a>
</td>
</tr>
( <tr class="white">

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

<td> </td>

<td><a href='editArticle.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.php?id=9&curr=1">Current</a> |
<a href="publish.php?id=9&curr=0">Archive</a>

</td>

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

<td><a href='indexPgCode.php?id=9'>Snippet</a>
</td>
</tr>
( <tr class="grey">

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

<td>SLEEP </td>

<td><a href='editArticle.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.php?id=27&curr=1">Current</a> |
<a href="publish.php?id=27&curr=0">Archive</a>

</td>

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

<td><a href='indexPgCode.php?id=27'>Snippet</a>
</td>
</tr>
( <tr class="white">

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

<td>SELFCARE </td>

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

<td>October, 2004 </td>

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

</td>

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

<td><a href='indexPgCode.php?id=28'>Snippet</a>
</td>
</tr>
( <tr class="grey">

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

<td> </td>

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

<td>June, 2004 </td>

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

</td>

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

<td><a href='indexPgCode.php?id=11'>Snippet</a>
</td>
</tr>
( <tr class="white">

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

<td> </td>

<td><a href='editArticle.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.php?id=12&curr=1">Current</a> |
<a href="publish.php?id=12&curr=0">Archive</a>

</td>

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

<td><a href='indexPgCode.php?id=12'>Snippet</a>
</td>
</tr>
( <tr class="grey">

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

<td>INTERVIEW </td>

<td><a href='editArticle.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.php?id=29&curr=1">Current</a> |
<a href="publish.php?id=29&curr=0">Archive</a>

</td>

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

<td><a href='indexPgCode.php?id=29'>Snippet</a>
</td>
</tr>
( <tr class="white">

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

<td> </td>

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

<td>April, 2004 </td>

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

</td>

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

<td><a href='indexPgCode.php?id=14'>Snippet</a>
</td>
</tr>
( <tr class="grey">

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

<td> </td>

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

<td>April, 2004 </td>

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

</td>

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

<td><a href='indexPgCode.php?id=15'>Snippet</a>
</td>
</tr>
( <tr class="white">

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

<td> </td>

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

<td>June, 2004 </td>

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

</td>

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

<td><a href='indexPgCode.php?id=17'>Snippet</a>
</td>
</tr>
( <tr class="grey">

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

<td>ABOUT MEN </td>

<td><a href='editArticle.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.php?id=19&curr=1">Current</a> |
<a href="publish.php?id=19&curr=0">Archive</a>

</td>

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

<td><a href='indexPgCode.php?id=19'>Snippet</a>
</td>
</tr>
( <tr class="white">

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

<td> </td>

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

<td>February, 2004 </td>

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

</td>

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

<td><a href='indexPgCode.php?id=21'>Snippet</a>
</td>
</tr> </table>

</body>
</html>
Jul 17 '05 #1
0 1537

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tony Marston | last post by:
I have just moved my website to a new hosting provider as the previous one went belly-up. Everything is now fine except for one thing - my counter script which generates a PNG image is sending out...
1
by: supercow | last post by:
Hello, Can anyone give me some pointers for solving my php serving problem? I'm relatively new to this. The problem is: all php output appears client side as garbled text (in firefox, and IE...
4
by: Alan Little | last post by:
This is very bizarre. Could someone else have a look at this? Maybe you can see something I'm overlooking. Go here: http://www.newsletters.forbes.com/enews/admin/deliver.php4 U: bugtest P:...
4
by: Tom Chadwin | last post by:
Hello all Using PHP 4.1.2, I am seeing intermittent visible escaping backslashes in my HTML output. Try refreshing the following page a few times to see what I mean: ...
1
by: steve | last post by:
Hi, My Windows machine running PHP Version 4.3.4, Apache, mysql, Zend IDE has developed a strange problem whereas the html code coming out of php sometimes gets garbled in unpredicatable ways,...
14
by: Michael Carr | last post by:
I have an intermittent problem that occurs on a very small number of browsers that access my website. The strange thing is this: my site works perfectly for 99.9% of browsers. The behavior...
3
by: jethro_uk | last post by:
Hi all, I'm having a hard time with the Day() function. Basically, it appears to be picking and choosing which part of a date string it uses to return the result ... heres some code : ...
9
by: pengypenguin | last post by:
I've made this little example script for a project I'm working on, and the text that gets output seems to be chewed up in IE for Windows. Every other (major) browser has no problem rendering the...
2
by: peridian | last post by:
I've gotten a really weird result crop up on my site, and I can't find any information on the web that it has been seen elsewhere. Given how weird this is, I guess it's probably a symptom of either...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.