|
 |
|
Dev Articles Community Forums
> Programming
> General Programming Help
|
get all birthday script
Discuss get all birthday script in the General Programming Help forum on Dev Articles. get all birthday script General Programming Help forum discussing Perl, Python, Scripting and/or any languages that do not fit into any of the categories above.
|
|
 |
|
|
|

Dev Articles Community Forums Sponsor:
|
|

September 12th, 2003, 06:21 AM
|
Contributing User
|
|
Join Date: Apr 2003
Posts: 187
Time spent in forums: < 1 sec
Reputation Power: 16
|
|
get all birthday script
okay so I am writing a page in php to display all users birthdays:
PHP Code:
//get date and month
$month = 01;
$day = 01;
//function for doing things with the current month
function newMonth()
{ //find how many days in month
$timestamp = mktime(0,0,0,$month);
$monthdays = date("t",$timestamp);
//convert month to calander word
$monthName = jdmonthname ( juliantojd( $month, 1, 2002 ), 1 );
echo $monthName;
while($day < $monthdays)
{ //grabs user info
$getBirthdays = mysql_query("SELECT * FROM users WHERE month = '" . $monthName . "' AND day = '" . $day . "' AND pending = 'no'");
//and displays all info for all users in that day and that month, and then adds
//1 to day, loops again, untill all days looped thru, and then add one to month and
//start all over
while($bday = mysql_fetch_row($getBirthdays))
{ echo 'username' . $bday[1]; }
$day = $day + 1; } }
$month = $month + 1;
$day = 01;
//after displaying all days for month
if($month <= 12)
{ newMonth(); } ?>
This is returning NO INFORMATION. What is wrong with this? I have tried everything and have been working on this for about an hour now :S
__________________
hey it's the CHARKING
|

September 12th, 2003, 12:34 PM
|
Frank The Tank!
|
|
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,240
Time spent in forums: < 1 sec
Reputation Power: 18
|
|
charking,
Try changing your query to this:
PHP Code:
$getBirthdays = mysql_query("SELECT * FROM users WHERE month = '" . $monthName . "' AND day = " . $day . " AND pending = 'no'");
You don't want to enclose your numeric values in quotes.
HTH!
|

September 12th, 2003, 04:03 PM
|
Contributing User
|
|
Join Date: Apr 2003
Posts: 187
Time spent in forums: < 1 sec
Reputation Power: 16
|
|
solves one problem
Thanks, I forgot about that or something... I think I had tried that and was having rpoblems so I put them back for some reason...
but here is what happened.
I tried the query as you suggested, and got an error message:
PHP Code:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in c:\phpdev\www\neo-trivia\bday.php on line 36
(which is where the while statement is after the query).
I tried a few things to fix it:
I took WHERE month = '" . $monthName . "' out of the query. This helped somewhat; I still got the error, but also a list of all users, as I was trying to get, in order of their birthdays.
I tried changing monthname:
$monthName = 'september';
this worked sort of, I got the error message, and all users in september (of course).
Oh and this time it succesfully echoe'd out the $monthName. Is their a problem with the julian month str?
I also tried to echo out the $day. It didn't work. Why is this happening? I checked my table and it is set up right, and each user has info where needed too, although that wouldn't be a problem anyway, but it should be fine I think... any other ideas?
thanks!
|

September 17th, 2003, 01:48 PM
|
Contributing User
|
|
Join Date: Apr 2003
Posts: 187
Time spent in forums: < 1 sec
Reputation Power: 16
|
|
fixed some things, still no good
okay so I've fixed the script as much as I can think, but it's still no good.
here is the code as it stands now:
PHP Code:
//get date and month
$month = date("m");
$day = 1;
//function for doing things with the current month
function newMonth()
{
//find how many days in month
$timestamp = mktime(0,0,0,$month);
$monthdays = date("t",$timestamp);
//convert month to calander word
$monthname = jdmonthname ( juliantojd( $month, 1, 2002 ), 1 );
//$monthname = date("F");
echo $monthname;
//echo $day;
//echo $monthdays;
while($day <= $monthdays)
{ //grabs user info
$query = "SELECT username, month, day, pending FROM users WHERE";
$query .= " month='$monthname' AND day='$day' AND pending='no'";
$getBdays = mysql_query($query) or die(mysql_error());
//echo $query; exit;
//and displays all info for all users in that day and that month, and then adds
//1 to day, loops again, untill all days looped thru, and then add one to month and start all over
while($bday = mysql_fetch_row($getBdays))
{ echo $bday[0] . '<br />'; }
$day = $day + 1; } }
$month = $month + 1;
$day = 01;
//after displaying all days for month
if($month <= 12)
{ newMonth(); }
this is returning nothing still. I have echoed out the $query, it returns the expected statement, except the WHERE month = '' and day=''. It seems to not be getting values for these. Why? How can I fix this? Any ideas? Thanks!
|

September 17th, 2003, 06:21 PM
|
Frank The Tank!
|
|
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,240
Time spent in forums: < 1 sec
Reputation Power: 18
|
|
try this:
PHP Code:
global $month = date("m");
global $day = 1;
|

September 17th, 2003, 10:28 PM
|
Contributing User
|
|
Join Date: Apr 2003
Posts: 187
Time spent in forums: < 1 sec
Reputation Power: 16
|
|
okay i tried what you suggested, but found I had to write it as this:
PHP Code:
$month = date("m");
global $month;
$day = 1;
global $day;
I guess that's normal. I also changed other variables to global, but found no luck; it is still just a blank screen. As I said, I echoed out the statement; it gives me this:
PHP Code:
SELECT username, month, day, pending FROM users WHERE month='' AND day='' AND pending='no'
of couse this is with an exit; or it keeps echoing it out, through 31 days. Just repeats the statement, and doesn't have the proper month value. Any more ideas? Thanks for the help so far!
|

September 18th, 2003, 09:52 PM
|
Frank The Tank!
|
|
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,240
Time spent in forums: < 1 sec
Reputation Power: 18
|
|
Hmmm...
That's really weird. I don't understand why it's not picking up the values... Have you tried echoing out the values just before creating your SQL statement -- to make sure the values are still there?
|

September 19th, 2003, 01:08 AM
|
Contributing User
|
|
Join Date: Apr 2003
Posts: 187
Time spent in forums: < 1 sec
Reputation Power: 16
|
|
i echoed out the values as you suggested, and they aren't being given. I have no clue on how to get them... maybe this can be done without a function? because then I know that it would work...
thanks for responding, I've been trying to figure this out for so long!
|

September 20th, 2003, 05:10 PM
|
Frank The Tank!
|
|
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,240
Time spent in forums: < 1 sec
Reputation Power: 18
|
|
Np.. I know how frustrating it can be to now have something work and not know why it's messing up.
That's really weird... Send me the entire code, and I'll try and have a look at this weekend. I'll try it on my system here.
|

September 20th, 2003, 08:58 PM
|
Contributing User
|
|
Join Date: Apr 2003
Posts: 187
Time spent in forums: < 1 sec
Reputation Power: 16
|
|
i have it attached as a zip so you can see it exactly as meant
thanks!
|

September 28th, 2003, 05:18 AM
|
Contributing User
|
|
Join Date: Apr 2003
Posts: 187
Time spent in forums: < 1 sec
Reputation Power: 16
|
|
just wondering if you had thought of anything new...?
|

September 29th, 2003, 03:49 PM
|
Frank The Tank!
|
|
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,240
Time spent in forums: < 1 sec
Reputation Power: 18
|
|
To be honest, I haven't had a chance to look at it... I've been working on assignments for the last couple of weeks... I'll definitely look at it this week.
Sorry to keep you waiting... Have you had any progress at all?
|

September 29th, 2003, 08:35 PM
|
Contributing User
|
|
Join Date: Apr 2003
Posts: 187
Time spent in forums: < 1 sec
Reputation Power: 16
|
|
no problem take your time, I appreciate any help at any time. But I haven't had any progress with it sicne (I haven't checked on it in a bit either, I sort of gave up. thanks
|

September 30th, 2003, 07:33 PM
|
Frank The Tank!
|
|
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,240
Time spent in forums: < 1 sec
Reputation Power: 18
|
|
Sure thing! I'll have a look at it ASAP. Just finished a test this morning, so my week should be a little lighter!
|

October 1st, 2003, 05:16 AM
|
Contributing User
|
|
Join Date: Sep 2003
Posts: 43
Time spent in forums: < 1 sec
Reputation Power: 16
|
|
does it matter if u first give a var a variable and then make em global? lol
ur doing:
$val = 1;
global $val;
shouldnt it be:
global $val;
$val = 1;
?
|

October 9th, 2003, 01:58 AM
|
Contributing User
|
|
Join Date: Apr 2003
Posts: 187
Time spent in forums: < 1 sec
Reputation Power: 16
|
|
i tried what you suggested, no luck. I also tried using $GLOBALS['var'] for a few thigns, and that helped to get the query working.... but it then made some sort of endless loop cause the page wouldn't load. I had a little exit; in there after echoing out the query... after taking that out... it looped...
|

November 4th, 2003, 06:57 PM
|
Contributing User
|
|
Join Date: Apr 2003
Posts: 187
Time spent in forums: < 1 sec
Reputation Power: 16
|
|
oh i was jsut wondering if any one had thought about this? i know I haven't haha I would appreciate any help in this, I still havent figured it out :P
|

November 5th, 2003, 03:15 AM
|
Contributing User
|
|
Join Date: Sep 2003
Posts: 43
Time spent in forums: < 1 sec
Reputation Power: 16
|
|
this really doesnt work?
i could be wrong coz i havent been doing real php for quite a while . no time for pers. hobbies and work works with asp/vbscript lol
PHP Code:
//get date and month
global $month, $day;
$month = date("m");
$day = 1;
//function for doing things with the current month
function newMonth()
{
global $month, $day;
//find how many days in month
$timestamp = mktime(0,0,0,$month);
$monthdays = date("t",$timestamp);
//convert month to calander word
$monthname = jdmonthname ( juliantojd( $month, 1, 2002 ), 1 );
//$monthname = date("F");
echo $monthname;
//echo $day;
//echo $monthdays;
while($day <= $monthdays)
{ //grabs user info
$query = "SELECT username, month, day, pending FROM users WHERE";
$query .= " month='$monthname' AND day='$day' AND pending='no'";
$getBdays = mysql_query($query) or die(mysql_error());
//echo $query; exit;
//and displays all info for all users in that day and that month, and then adds
//1 to day, loops again, untill all days looped thru, and then add one to month and start all over
while($bday = mysql_fetch_row($getBdays))
{ echo $bday[0] . '<br />'; }
$day = $day + 1; } }
$month = $month + 1;
$day = 01;
//after displaying all days for month
if($month <= 12)
{ newMonth(); }
|
Developer Shed Advertisers and Affiliates
Thread Tools |
Search this Thread |
|
|
Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|