General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 12th, 2003, 05:21 AM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via AIM to thecharking
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$month12002 ), );
        
        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

Reply With Quote
  #2  
Old September 12th, 2003, 11:34 AM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,240 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 18
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
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!
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #3  
Old September 12th, 2003, 03:03 PM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via AIM to thecharking
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:
 Warningmysql_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!

Reply With Quote
  #4  
Old September 17th, 2003, 12:48 PM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via AIM to thecharking
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$month12002 ), );
        
//$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!

Reply With Quote
  #5  
Old September 17th, 2003, 05:21 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,240 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 18
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
try this:

PHP Code:
global $month date("m");

global 
$day 1

Reply With Quote
  #6  
Old September 17th, 2003, 09:28 PM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via AIM to thecharking
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 usernamemonthdaypending 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!

Reply With Quote
  #7  
Old September 18th, 2003, 08:52 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,240 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 18
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
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?

Reply With Quote
  #8  
Old September 19th, 2003, 12:08 AM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via AIM to thecharking
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!

Reply With Quote
  #9  
Old September 20th, 2003, 04:10 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,240 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 18
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
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.

Reply With Quote
  #10  
Old September 20th, 2003, 07:58 PM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via AIM to thecharking
i have it attached as a zip so you can see it exactly as meant
thanks!
Attached Files
File Type: zip bday.zip (860 Bytes, 379 views)

Reply With Quote
  #11  
Old September 28th, 2003, 04:18 AM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via AIM to thecharking
just wondering if you had thought of anything new...?

Reply With Quote
  #12  
Old September 29th, 2003, 02:49 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,240 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 18
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
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?

Reply With Quote
  #13  
Old September 29th, 2003, 07:35 PM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via AIM to thecharking
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

Reply With Quote
  #14  
Old September 30th, 2003, 06:33 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,240 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 18
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Sure thing! I'll have a look at it ASAP. Just finished a test this morning, so my week should be a little lighter!

Reply With Quote
  #15  
Old October 1st, 2003, 04:16 AM
Relax Relax is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 43 Relax User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 15
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;

?

Reply With Quote
  #16  
Old October 9th, 2003, 12:58 AM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via AIM to thecharking
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...

Reply With Quote
  #17  
Old November 4th, 2003, 05:57 PM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via AIM to thecharking
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

Reply With Quote
  #18  
Old November 5th, 2003, 02:15 AM
Relax Relax is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 43 Relax User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 15
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$month12002 ), ); 
        
//$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();    } 

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > get all birthday script


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap