Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-06-2005, 03:53 PM
WebProWorld Pro
 

Join Date: Aug 2004
Location: Maryland
Posts: 219
webmasterjunkie RepRank 0
Default PHP Date Compare

I am having an issue with my script and was wondering if anyone could help. Here goes:

$current_full_date = $_GET['year'];
$current_full_date .= "-";
$current_full_date .= $_GET['month'];
$current_full_date .= "-";
$current_full_date .= "00";
$db_connection = mysql_connect ($DBHost, $DBUser, $DBPass) OR die (mysql_error());
$db_select = mysql_select_db ($DBName) or die (mysql_error());
$query = "SELECT * FROM subscribers WHERE date_added >= \"$current_full_date\"";
$query_result = mysql_query($query);
while ($row = mysql_fetch_array($query_result)) {
$subscriber_id = $row['id'];
$subscriber_type = $row['type'];
$date1 = $row['date_added'];
$day = substr($date1, 8, 2);
$events[$day][] = $subscriber_id;
$event_info[$subscriber_id]['0'] = "New ";
$event_info[$subscriber_id]['1'] = ucfirst("$subscriber_type");
}
FOR($i = 1; $i <= $days_in_month; $i++) {
IF(isset($events[$i])) {
echo "<div align=\"left\">";
while (list($key, $value) = each ($events[$i])) {
echo "$event_info[$value]['0'] . " " . $event_info[$value]['1']";
}
}
}

This is supposed to show a list of people who signed the guestbook during the current month. I know someone is in the database, but I can't get it to show up. Any help is appreciated.
Reply With Quote
  #2 (permalink)  
Old 04-06-2005, 11:27 PM
mushroom's Avatar
WebProWorld Veteran
 

Join Date: Feb 2004
Location: Queen Charlotte B. C. Canada
Posts: 351
mushroom RepRank 0
Default

Do not use escape, quote inside mysql querys use single quotes around vars instead.
Also "00" is not a valid date use "01"

And if you are only last month try using the date_sub function

"Date_SUB(1999-12-01,INTERVAL 1 MONTH)"
or
"Date_SUB(NOW(),INTERVAL 1 MONTH)"
__________________
Irony: That for most people the most "trusted" web site on the planet is for a company the has been convicted of criminal activity.

Both Security and SuSe start with "S". www.oldslides.com
Reply With Quote
  #3 (permalink)  
Old 04-07-2005, 09:40 AM
WebProWorld Pro
 

Join Date: Aug 2004
Location: Maryland
Posts: 219
webmasterjunkie RepRank 0
Default Date Sub

Thanks Mushroom,

I'll try the date_sub function, and see if that helps. Also, I've never had any problems escaping in the query before, it's what I use in my search algo too.
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , ,



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
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0