Computer Science Canada sends 71 emails instead of 6?!! |
Author: | gsquare567 [ Sat Apr 12, 2008 4:06 pm ] | ||
Post subject: | sends 71 emails instead of 6?!! | ||
it is supposed to send 5 emails to the top 5 monthlyscore users and then one to me. the one to me sends a list of 70 though, and there are two of each name. the usernames are all single characters like A or 0 or even blank. there must be a mysql error in my query, but there shouldnt be because i specifically say LIMIT 5!
|
Author: | btiffin [ Sat Apr 12, 2008 5:54 pm ] |
Post subject: | Re: sends 71 emails instead of 6?!! |
Excuse the lack on knowledge, PHP is not my thing. mail takes a string TO, a string SUBJECT and a string MESSAGE and then the optionals. You are passing an array variable as the message. I'm not sure how that will be parsed by the mail() function, but it seems wrong. You may need to reformat $winners_list into a $winners_list(0) linefeed $winners_list(1) linefeed. I'm sure a true PHP'er will have better advice. Plus; I could be completely out to lunch and should probably have stayed quiet. Cheers |
Author: | gsquare567 [ Sat Apr 12, 2008 10:44 pm ] | ||
Post subject: | RE:sends 71 emails instead of 6?!! | ||
sorry, but i think that you did not look carefully enough.
$winners_list is a string. it is not the problem. the problem is $monthly_winners, which is an array created from the MySQL query. for some reason, the loop runs 70 times. |
Author: | Dan [ Sat Apr 12, 2008 10:55 pm ] |
Post subject: | RE:sends 71 emails instead of 6?!! |
What happens if you do the SQL query directly on your data base and not threw php? If you have command line access to the mysql server or phpadmin you could check if it returns the right amount of rows and then find out if it is your SQL or your php code. |
Author: | btiffin [ Sat Apr 12, 2008 11:27 pm ] |
Post subject: | Re: sends 71 emails instead of 6?!! |
Yeah, sorry; This is not my expertise at all. So I'll ask a question now. In double quoted strings what does $$$ return? What does the "Monthly VIPortals $$$ Winners" expand to after string parsing? Excuse the interruption. Should have stayed quiet. Not that I mind looking out to lunch, love learning things. |
Author: | gsquare567 [ Sun Apr 13, 2008 12:07 am ] |
Post subject: | RE:sends 71 emails instead of 6?!! |
i've tried it in my PHPMyAdmin SQL section and it returns the top 5 as wanted. |
Author: | Dan [ Sun Apr 13, 2008 12:13 am ] |
Post subject: | RE:sends 71 emails instead of 6?!! |
I think you might be using the mysql_fetch_array command incorectly. You should take a look at: http://ca3.php.net/mysql_fetch_array It seems to be that mysql_fetch_array returns an array of the coloums not an array of rows so you are looping threw each coloumn rather then each row. If you look at the examples in the link i gave you, you can see the proper method of looping threw the rows rather then the colomums. |