$query = "select date_format(entry_date, '%W, %m/%d%Y - %h:%m:%s %p') from guessbook";
//$query = " select entry_date from guessbook ";
$result = mysql_query($query);
print $query."<br>";
print $result ."<br>";
while ($rows = mysql_fetch_assoc($result))
{ print $rows[entry_date]."<br>";
Why there is no out put ? Is there other way to get it work.
if $query = "select entry_date from guessbook"; The print $rows[entry_date] works fine.
How to format entry_date that works??? Thanks for any input./advice.
<?php
$user='kdao';
$pass='khaidao';
$host='localhost';
$db='kdao';
$table='guessbook';
$conn = mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($db,$conn);
$query = "select date_format(entry_date, '%W, %m/%d%Y - %h:%m:%s %p') from guessbook";
//$query = " select entry_date from guessbook ";
$result = mysql_query($query);
print $query."<br>";
print $result ."<br>";
while ($rows = mysql_fetch_assoc($result))
{ print $rows[entry_date]."<br>";
}
mysql_close($conn);
?>
PHP MYSQL print error.
Moderator: General Moderators
Re: PHP MYSQL print error.
I personally use mysql_fetch_array, might want to try that. I would test and let you know exactly but I am not at a computer for that right now, so just throwing this out there to try and get you a timely solution. If this does not work, post again and I will answer tomorrow.kdao wrote: while ($rows = mysql_fetch_assoc($result))
Re: PHP MYSQL print error.
I have tried
while ($rows = mysql_fetch_array($result))
with out result.
I'm thinking of the query problem.
I try this
$query= "select entry_date from guessbook";
$result= mysql_query($query);
...
while ( $rows = mysql_fetch_array($result)
{ print $rows[date_format('entry_date', ' %W, %m/%d/%Y %h:%m:%s %p ');];
}
what I guess is it :
[/bWarning: date_format() expects parameter 1 to be DateTime, string given in /usr/local/apache2/php/junk.php on line 21
2008-07-16 21:11:24
What I want is :
Wednesday, 07/162008 - 09:07:24 PM EST
]
Thanks. kdao.
note : mysql table guessbook, the field entry_date type datetime .
while ($rows = mysql_fetch_array($result))
with out result.
I'm thinking of the query problem.
I try this
$query= "select entry_date from guessbook";
$result= mysql_query($query);
...
while ( $rows = mysql_fetch_array($result)
{ print $rows[date_format('entry_date', ' %W, %m/%d/%Y %h:%m:%s %p ');];
}
what I guess is it :
[/bWarning: date_format() expects parameter 1 to be DateTime, string given in /usr/local/apache2/php/junk.php on line 21
2008-07-16 21:11:24
What I want is :
Wednesday, 07/162008 - 09:07:24 PM EST
]
Thanks. kdao.
note : mysql table guessbook, the field entry_date type datetime .