0

Hi, I am trying to get my date field in a table to display as a long date (%W, %D %M %Y) format, but when I change the query variable using the FORMAT_DATE function it doesn't work at all, I just get a warning error.

die('Could not connect: ' . mysql_error());
}
mysql_select_db("chris", $con);
//$count = "SELECT eventname COUNT(id) FROM events ");
//$id=--echo"$count";
//$eventname="SELECT name FROM events WHERE id=$id";
$query="SELECT id, date, title, cost FROM dates WHERE date > NOW()ORDER BY id asc";
$result=mysql_query($query);
echo "<table border='0' rules='rows' width='95%' padding='10' spacing='0' align='left'>";

while($row = mysql_fetch_array($result))
{
$id=$row['id'];
echo "<tr>";
echo "<td width=\"150\">" . $row['date'] . "</td>";
echo "<td width=\"450\"><a href=viewdate.php?id=" . $id . ">" . $row['title'] . "</a></td>";
echo "<td> &pound; " . $row['cost'] . "</td></p>";
echo "</tr>";
}
echo "</table>";

mysql_close($con);
?>

But when I change my query variable to the following I get Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\Chrissy\dates.php on line 52

$query="SELECT id, date, title, cost DATE_FORMAT(date, '%W, %D %M %Y') FROM dates WHERE date > NOW()ORDER BY id asc";

I apologise if this is something for the databases forum, but I wasn't sure :(

I would appreciate all help as this is driving me crazy!!

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Dukane
1

I believe mysql_query returns the result set if it can run the query, or returns the boolean value false if it cannot. Since the error you are getting is "boolean", you are probably getting that boolean false. That means, that mysql_query cannot run your query. Now I am grapsing at straws here, as I am no PHP/MySQL expert, but you may have to escape those ' marks in your date format. Check your query by echoing it to the screen before you pass it into mysql_query, and do the same for $result and see if you are getting that boolean false.

Edited by Dukane: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.