Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6615313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:26:48+00:00 2026-05-25T20:26:48+00:00

I have AJAX running a query every 5 seconds which checks if a user

  • 0

I have AJAX running a query every 5 seconds which checks if a user has requested a session with the coach. and if there is it pops up with a dialog. the script changes the field so that it won’t catch the same session request, but it doesn’t seem to care if the field is blank or not it just runs all the way through the php script. here’s the ajax and php code.

setInterval(function() {
$.ajax({
  type: "GET",
  url: "includes/checksessionrequests.php",
  success: function(msg){
      if(msg == "yes") {
          $(\'$<div title="Request Recieved"></div>\').load(\'requestreceived.php\').dialog({modal: true, closeOnEscape: false, open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); }, height: 300, width: 480, hide: {effect: "fade", duration: 1000}, show: {effect: "fade", duration: 1000}});
      }
    }
});

the query

<?php
session_start();
$user = $_SESSION['username'];
include("dbcon.php");
$result = mysql_query("SELECT * FROM sessionrequests 
    WHERE coach='$user' 
    AND sessionstatus='' 
    ORDER BY id") or die(mysql_error());
$row = mysql_fetch_assoc($result);
$sessionstatus = $row['sessionstatus'];
$sessionid = $row['id'];

if($sessionstatus != "") { 
    die("no"); 
}
elseif($sessionstatus == "") 
{
$result = mysql_query("UPDATE sessionrequests 
    SET sessionstatus='received'
    WHERE id='$id'");
echo "yes";
}
mysql_close($con);
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:26:48+00:00Added an answer on May 25, 2026 at 8:26 pm

    You are not checking if the query is actually successful or if the query returns a match. If either of these scenarios happen, I believe that $sessionstatus will be set to NULL, thus skipping your if and elseif statements. I am still not too familiar with PHP’s weak typing and whether NULL evaluates to “” or not. But, it’s worth a shot. 🙂

    I would try something like this:

    $result = mysql_query("SELECT * FROM sessionrequests......");
    
    if ($result) { // Query executed successfully
    if (mysql_num_rows($result) > 0) { // Matches returned
    $row = mysql_fetch_assoc($result);
    $sessionstatus = $row['sessionstatus'];
    $sessionid = $row['id'];
    
    // Rest of your code
    
    }
    }
    
    mysql_close($con);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a production Server which has ASP.net 2.0 Application running with Ajax 1.0
I have one form which is submitting by ajax. I am running on php.
I am running ASP.NET MVC Beta. I have an AJAX call running through jQuery
I have a small web application with ASP.NET AJAX running well under the Cassini
I occasionally have some long running AJAX requests in my Wicket application. When this
I have an app that sends multiple Ajax requests simultaneously. I was originally running
If I have a synchronous ajax call running, and an asynchronous call is made
I have some (potentially) long-running ajax calls that I would like to abort if
I'm running a small website. I have an ajax shoutbox. I have 3 different
I have an ajax calendar which changes the month when some arrows are clicked.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.