dbTalk Databases Forums  

odd display of mysql table contents?

comp.databases.mysql comp.databases.mysql


Discuss odd display of mysql table contents? in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
geoff@invalid.invalid
 
Posts: n/a

Default odd display of mysql table contents? - 05-31-2011 , 11:55 AM






Hello

I have come across an new oddity, to me - perhaps someone can see why?

I am displaying the contents from 2 different tables in a browser
using php files which are identical except for the names of the tables
and the headings.

But - when dislaying the contents of table wm_results_p1, I see the
titles generated below, followed by a line starting

01-01-1970 01:00 followed by the actual names of the mysql table
fields ..

With wm_results_p2 this line is not there.

Why the difference?? I cannot see any explanation looking at the
structure of the 2 tables ..

I expect the 01-01-1970 is the clue?

Cheers

Geoff


<?php

@require(dirname(__FILE__) . '/<path to>/config-wm.php');
mysql_connect($conf['sql']['host'], $conf['sql']['user'],
$conf['sql']['pass']) or die(mysql_error());
mysql_select_db($conf['sql']['db']) or die(mysql_error());
$sql = "SELECT *, UNIX_TIMESTAMP(DT) as DTnew FROM wm_results_p1 ORDER
by DT";
$lab2_ = mysql_query($sql);

echo "<table border='1'><tr>
<td>DateTime</td>
<td>nme</td>

......

while($row = mysql_fetch_array($lab2_)) {
if ($row['DTnew'] !=''){
$dt = $row['DTnew'];
$newdt = date('d-m-Y H:i:s', $dt);
echo '<td>' . $newdt . '</td>';
} else {
echo '<td>' . '&nbsp;' . '</td>';
}
if ($row['login_name'] !=''){
echo '<td>' . $row['login_name'] . '</td>';
} else {
echo '<td>' . '&nbsp;' . '</td>';
}

.....

Reply With Quote
  #2  
Old   
geoff@invalid.invalid
 
Posts: n/a

Default Re: odd display of mysql table contents? - 05-31-2011 , 03:10 PM






On Tue, 31 May 2011 17:55:42 +0100, geoff (AT) invalid (DOT) invalid wrote:

this image shows the kind of results displayed,

http://www.micro-active.com/field-names.gif

Why the line with 01-01-1970 and the names of the columns in the
table?

Cheers

Geoff

Reply With Quote
  #3  
Old   
Erick T. Barkhuis
 
Posts: n/a

Default Re: odd display of mysql table contents? - 06-01-2011 , 01:19 AM



geoff (AT) invalid (DOT) invalid:


Quote:
while($row = mysql_fetch_array($lab2_)) {
if ($row['DTnew'] !=''){
$dt = $row['DTnew'];
$newdt = date('d-m-Y H:i:s', $dt);
echo '<td>' . $newdt . '</td>';
} else {
This will print 1-1-70 when $row['DTnew'] is null.
I assume that's the case.

--
Erick

Reply With Quote
  #4  
Old   
geoff@invalid.invalid
 
Posts: n/a

Default Re: odd display of mysql table contents? - 06-01-2011 , 01:51 AM



On 1 Jun 2011 06:19:48 GMT, "Erick T. Barkhuis"
<erick.use-net (AT) ardane (DOT) c.o.m> wrote:

Quote:
geoff (AT) invalid (DOT) invalid:


while($row = mysql_fetch_array($lab2_)) {
if ($row['DTnew'] !=''){
$dt = $row['DTnew'];
$newdt = date('d-m-Y H:i:s', $dt);
echo '<td>' . $newdt . '</td>';
} else {

This will print 1-1-70 when $row['DTnew'] is null.
I assume that's the case.
Eric

Thanks for your reply. I expect you are right but how this happens is
a mystery to me at the moment!

I am using the following with table results_p1

$sql = "SELECT *, UNIX_TIMESTAMP(DT) as DTnew FROM results_p1 ORDER by
DT";

and

if ($row['DTnew'] !=''){
$dt = $row['DTnew'];
$newdt = date('d-m-Y H:i:s', $dt);
echo '<td>' . $newdt . '</td>';
} else {
echo '<td>' . '&nbsp;' . '</td>';
}

which gives the 01-01-1970 etc

and the folllwing with table results_p2

$sql = "SELECT *, UNIX_TIMESTAMP(DT) as DTnew FROM results_p2 ORDER
by DT";

and

if ($row['DTnew'] !=''){
$dt = $row['DTnew'];
$newdt = date('d-m-Y H:i:s', $dt);
echo '<td>' . $newdt . '</td>';
} else {
echo '<td>' . '&nbsp;' . '</td>';
}

which does not give the 01-01-1970 etc

I cannot see any difference in the structure of the 2 tables and I did
a search for DT being null in table results_p1 and this was not found.

Where should I be looking for the reason for the 01-01-1970 etc?!

Cheers

Geoff

Reply With Quote
  #5  
Old   
geoff@invalid.invalid
 
Posts: n/a

Default Re: odd display of mysql table contents? - 06-01-2011 , 02:10 AM



On 1 Jun 2011 06:19:48 GMT, "Erick T. Barkhuis"
<erick.use-net (AT) ardane (DOT) c.o.m> wrote:

Quote:
geoff (AT) invalid (DOT) invalid:


while($row = mysql_fetch_array($lab2_)) {
if ($row['DTnew'] !=''){
$dt = $row['DTnew'];
$newdt = date('d-m-Y H:i:s', $dt);
echo '<td>' . $newdt . '</td>';
} else {

This will print 1-1-70 when $row['DTnew'] is null.
I assume that's the case.
Eric

I have removed some code and used for

1. results_p1

$sql = "SELECT * FROM results_p1 ORDER by DT";

if ($row['DT'] !=''){
echo '<td>' . $row['DT'] . '</td>';
} else {
echo '<td>' . '&nbsp;' . '</td>';
}

and I now get 0000-00-00 00:00:00 followed by the names of the columns

The other dates are there correctly as for example

2010-05-17 12:14:46

2. for results_p2

$sql = "SELECT * FROM results_p2 ORDER by DT";

if ($row['DT'] !=''){
echo '<td>' . $row['DT'] . '</td>';
} else {
echo '<td>' . '&nbsp;' . '</td>';
}

Here is do not get 0000-00-00 00:00:00 followed by the names of the
columns

??!!

Geoff

Reply With Quote
  #6  
Old   
geoff@invalid.invalid
 
Posts: n/a

Default Re: odd display of mysql table contents? - 06-01-2011 , 02:15 AM



On 1 Jun 2011 06:19:48 GMT, "Erick T. Barkhuis"
<erick.use-net (AT) ardane (DOT) c.o.m> wrote:

Quote:
geoff (AT) invalid (DOT) invalid:


while($row = mysql_fetch_array($lab2_)) {
if ($row['DTnew'] !=''){
$dt = $row['DTnew'];
$newdt = date('d-m-Y H:i:s', $dt);
echo '<td>' . $newdt . '</td>';
} else {

This will print 1-1-70 when $row['DTnew'] is null.
I assume that's the case.
Eric

if I use

if ($row['DT'] !=''){
echo '<td>' . 'help' . '</td>';
} else {
echo '<td>' . '&nbsp;' . '</td>';
}

then all the data columns have "help" in them, the first line also
having the names of the columns, so presumably

$row['DTnew'] is never empty? Is this the same as never null?

Geoff

Reply With Quote
  #7  
Old   
geoff@invalid.invalid
 
Posts: n/a

Default Re: odd display of mysql table contents? - 06-01-2011 , 03:07 AM



On 1 Jun 2011 06:19:48 GMT, "Erick T. Barkhuis"
<erick.use-net (AT) ardane (DOT) c.o.m> wrote:

Quote:
geoff (AT) invalid (DOT) invalid:


while($row = mysql_fetch_array($lab2_)) {
if ($row['DTnew'] !=''){
$dt = $row['DTnew'];
$newdt = date('d-m-Y H:i:s', $dt);
echo '<td>' . $newdt . '</td>';
} else {

This will print 1-1-70 when $row['DTnew'] is null.
I assume that's the case.
Eric

is this another clue?

If I use NOT ISNULL(DT) and ORDER by DT

$sql = "SELECT * FROM results_p1 WHERE NOT ISNULL(DT) ORDER by DT";

I get the 0000-00-00 00:00:00 and the column names

but if I use NOT ISNULL(DT) and ORDER by user_ code

$sql = "SELECT * FROM results_p1 WHERE NOT ISNULL(DT) ORDER by
user_code";

I do not get the

0000-00-00 00:00:00 and the column names

What is it about DT that causes this?

Cheers

Geoff

Reply With Quote
  #8  
Old   
geoff@invalid.invalid
 
Posts: n/a

Default Re: odd display of mysql table contents? - 06-01-2011 , 03:49 AM



On 1 Jun 2011 06:19:48 GMT, "Erick T. Barkhuis"
<erick.use-net (AT) ardane (DOT) c.o.m> wrote:

Quote:
geoff (AT) invalid (DOT) invalid:


while($row = mysql_fetch_array($lab2_)) {
if ($row['DTnew'] !=''){
$dt = $row['DTnew'];
$newdt = date('d-m-Y H:i:s', $dt);
echo '<td>' . $newdt . '</td>';
} else {

This will print 1-1-70 when $row['DTnew'] is null.
I assume that's the case.
Erik,

'apologies for spelling your name wrongly .. have only just realised.

Cheers

Geoff

Reply With Quote
  #9  
Old   
geoff@invalid.invalid
 
Posts: n/a

Default Re: odd display of mysql table contents? - 06-01-2011 , 04:44 AM



On Wed, 01 Jun 2011 09:49:23 +0100, geoff (AT) invalid (DOT) invalid wrote:

Quote:
On 1 Jun 2011 06:19:48 GMT, "Erick T. Barkhuis"
erick.use-net (AT) ardane (DOT) c.o.m> wrote:

geoff (AT) invalid (DOT) invalid:


while($row = mysql_fetch_array($lab2_)) {
if ($row['DTnew'] !=''){
$dt = $row['DTnew'];
$newdt = date('d-m-Y H:i:s', $dt);
echo '<td>' . $newdt . '</td>';
} else {

This will print 1-1-70 when $row['DTnew'] is null.
I assume that's the case.

Erik,

'apologies for spelling your name wrongly .. have only just realised.

Cheers

Geoff
Good grief - I've done it again Erick ....

Geoff

Reply With Quote
  #10  
Old   
Erick T. Barkhuis
 
Posts: n/a

Default Re: odd display of mysql table contents? - 06-01-2011 , 05:28 AM



geoff (AT) invalid (DOT) invalid:

Quote:
On 1 Jun 2011 06:19:48 GMT, "Erick T. Barkhuis"
erick.use-net (AT) ardane (DOT) c.o.m> wrote:

geoff (AT) invalid (DOT) invalid:


while($row = mysql_fetch_array($lab2_)) {
if ($row['DTnew'] !=''){
$dt = $row['DTnew'];
$newdt = date('d-m-Y H:i:s', $dt);
echo '<td>' . $newdt . '</td>';
} else {

This will print 1-1-70 when $row['DTnew'] is null.
I assume that's the case.

Eric

if I use

if ($row['DT'] !=''){
echo '<td>' . 'help' . '</td>';
} else {
echo '<td>' . '&nbsp;' . '</td>';
}

then all the data columns have "help" in them, the first line also
having the names of the columns, so presumably

$row['DTnew'] is never empty? Is this the same as never null?
There's a difference betwee NULL and the empty string. They are not the
same.

Let's start at the beginning. What does the table look like. Could you
please generate the CREATE table statement, and post it here? I am
specifically interested in the definition of that DT field.

--
Erick

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.