I have a page that is used to change the date which is stored as session variables, and then return to the previous page. Just to explain it, people view types of events for a specific date on a page, then if they want to view the types of events for a different date, they click the "change date" link and select a new date.
As I'm testing this, I find that about 1/5 of the time, the returned page is blank. I used some echos to narrow it down, and it seems like it's a failed query here:
$query_friends = "SELECT up.email, up.first_name, up.last_name FROM userprofiles up, friendslist f WHERE f.user = $userid AND up.id = f.friend";
echo $query_friends . ".<br>";
$friends = mysql_query($query_friends, $connBarHopper) or die(mysql_error());
echo "After query";
The thing is, this query doesn't even use the changed date. None of the information in the query is changed when I change the date because the only variable is $userid, and that comes from a session variable that is set when the user logs in. Since I echo the query before it is called, I could see that it is exactly the same when the page loads properly and when the page fails to load. In both cases, the userid is the same as well as the rest of the query. When the page loads properly, "After query" is displayed along with the rest of the page, but if it fails to load, the last output is the query, so I know that something is going wrong on that one line where the query is called.
I thought that maybe it has something to do with the "die" part, but taking that out gives me the following error about as frequently as I got a blank page before:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/outby9.com/httpdocs/beta_test/more/my_friends.php on line 35
Does anyone know why the exact same query would work some of the time but not the rest? I really copied each echoed query into a text document to compare them, and the same one fails sometimes while other times it runs perfectly.
The other interesting piece of information that may or may not be related is that the dates that cause the page to fail seem to change randomly. Sometimes a certain date will cause the page to fail 5 or 6 times in a row, then it the page will load fine with the same date for 10 tries. Either way, I'd be surprised if it had anything to do with the date.
Any help is appreciated and if I wasn't clear enough, I'd be happy to provide more information.