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

  • SEARCH
  • Home
  • 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 7874189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:44:25+00:00 2026-06-03T02:44:25+00:00

I have a php script that is triggered from my app. This script uses

  • 0

I have a php script that is triggered from my app. This script uses the GET method to retrieve information from the url and put it into a database. I have got it to work so far except for the fact when I try to do multiple requests.

For example, I did a test where every time I would take the name of the database from the GET, put it into the appropriate database, retrieve the last entry, and then it would add 7 each time and echo it to the screen/put it back into the database as the newest number. I tried this within my browser hitting refresh every time and the first time it worked. Second time I hit refresh, it gave me the same results as the first time. I kept trying but same result so I closed the browser and tried it again. It worked as it should.

So the problem I think has to do with the script not receiving the connection the second, third, fourth… time around. It seems to only work the first time. I thought this was an issue with the data being cached but I turned off cache within the php script.

Can someone please tell me why it only works on the first attempt?

Thanks

EDITED WITH CODE

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 
header("Cache-Control: no-store, no-cache, must-revalidate"); 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

checkToken();

function checkToken ()
{



$username='XXXXX';
$password='XXXXX';
$database='Push';


$passed= $_GET['token'];


$pieces = explode(" ", $passed); /*Contains two pieces of information.  
                                       First is for the correct table and 
                                       and the second is the actually data 
                                       that will be put into the tables*/
$search= $pieces[1];

$table= $pieces[0];

echo $table." ".$search;

 $db= new mysqli('localhost', $username, $password, $database);

if (mysqli_connect_errno())
{
    echo 'Error: Could not connect';
    exit;

}

$query = "SELECT * FROM `Tokens` WHERE `Number` LIKE '%$search%' ";


       echo "after";

$result = $db->query($query);
if ($result) {
    $num_results = $result->num_rows;

    $row = $result->fetch_assoc();


    echo $row;

    if (!$row)
    {
        echo "No Token, insert into database";
        insertToken($table,$pieces[1]);

        return;

    }

   /*problem may be around here...? does not always go into (!row)
     after the first time when it is supposed too*/

echo $row['Numbers'];


} else {
   // echo "Query failed: {$db->error}\n";

    echo "No";

}

}




function insertToken ($daTable, $daToken)
{

$username='XXXX';
$password='XXXX';
$database='Push';

 $token=$daToken;

 $con= mysql_connect("localhost",$username,$password);

  mysql_select_db($database,$con);

  $res = mysql_query(
"INSERT INTO $daTable
VALUES ('', '$token')");
if (!$res) {
die('Invalid query: ' . mysql_error());
 } else  {
echo "complete";
 }

mysql_close($link);

  }
  • 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-06-03T02:44:26+00:00Added an answer on June 3, 2026 at 2:44 am

    maybe a cache problem? try to make sure the code gets executed at all, like echoing the time

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a server with a PHP script that pulls data from a source
I have a global.php file that I call from the top of every script.
i have a link that needs to be triggered from a success post: <?php
I have php script that creates a temporary watermark image for users that are
I have a PHP script that runs as a CGI program and the HTTP
I have a PHP script that needs to determine if it's been executed via
I have a PHP script that initialises an image gallery. It loops through all
I have a PHP script that can encode a PNG image to a Base64
I have a PHP script that sends critical e-mails. I know how to check
I have a PHP script that processes file uploads. The script tries to organise

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.