troubleshooting Question

Why would this happen?

Avatar of Bruce Gust
Bruce GustFlag for United States of America asked on
11 Comments4 Solutions412 ViewsLast Modified:
When a user goes out to, there's a little script that looks like this:

$featured_id = $_GET['id'];

if($featured_id <>0){

	$query_sweep = "select * from featured where contestant_id = '$featured_id'";
	$query_jorja = mysqli_query($cxn,$query_sweep)
	or die ("Couldn't execute query.");
	$count_query_sweep= mysqli_num_rows($query_jorja);

	//if this isn't the first time this page has been accessed, then we're going to do a simple computation and update the record

	$new_hit_total = $hits+1;

	$query = "UPDATE featured SET hits='$new_hit_total'
	WHERE contestant_id = '$featured_id'";
	$result = mysqli_query($cxn, $query)
	or die ("Couldn't execute query.");
	//if this is the first time the page has been accessed, then we do an INSERT, then forward the user to the actual page
	$insert = "insert into featured (hits, contestant_id)
	values ('1', '$featured_id')";
	$insertexe = mysqli_query($cxn, $insert);
	 if(!$insertexe) {
	$error = mysqli_errno($cxn).': '.mysqli_error($cxn);


Open in new window

Easy! It's worked for me for literally years. I've got contestants who have over a million visits to their site and it's proven to be very credible.

Recently, however, things are getting weird. I'll have the entire table freak out and while people aren't zeroed out, they'll get 5024 hits or something very close to that. 5025, 5026 - between 5025 and 5030.

I called my Web Hosting company and asked if they had noticed anything about the database on their end that would explain the coughing and the sputtering and they seemed confident that the problem is my code. But I don't see anything wrong with it and I'm thinking if it were the code, it would've been a problem from the very beginning.

Thoughts? Why is my table zeroing out and / or giving me this random number for everyone doing this and how can I fix it?
Join our community to see this answer!
Unlock 4 Answers and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 4 Answers and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros