Link to home
Start Free TrialLog in
Avatar of BrighteyesDesign
BrighteyesDesignFlag for Afghanistan

asked on

Date formatting not working

I have date formatting for my blog working fine on the initial page using...

mysql_select_db($database_GrandRoofing, $GrandRoofing);
$query_Recordset1 = "SELECT id, intro, title, date_format(`eventdate`,'%D %M %Y') as `formattedDate`, copy, images, category FROM news ORDER BY eventdate DESC";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $GrandRoofing) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

Open in new window


However, when I try to use it on a results page I get a 'Query was empty' error'

This code works fine without formatting..

$colname_Recordset1 = "-1";
if (isset($_GET['id'])) {
  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_GrandRoofing, $GrandRoofing);
$query_Recordset1 = sprintf("SELECT id, intro, title, eventdate, copy, images, category FROM news WHERE id = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $GrandRoofing) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

Open in new window


but when I try to format it like the first bit of code the error occurs...

$colname_Recordset1 = "-1";
if (isset($_GET['id'])) {
  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_GrandRoofing, $GrandRoofing);
$query_Recordset1 = sprintf("SELECT id, intro, title, date_format(`eventdate`,'%D %M %Y') as `formattedDate`, copy, images, category FROM news WHERE id = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $GrandRoofing) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

Open in new window



Any ideas why the formatting is causing this error?
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial