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 7927151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:10:02+00:00 2026-06-03T19:10:02+00:00

I want to run three php scripts one after another from one file. all

  • 0

I want to run three php scripts one after another from one file. all the functions are already defined in each of the files so that when they are called upon (aka run) they will do things.
I thought the following code would run all 3 but it stops right after the first file is finished running. does anyone know why?

Thanks

<?
error_reporting(E_ALL);ini_set('display_errors', 1);

require_once ("file1.php");
require_once ("file2.php");
require_once ("file3.php");
?>

EDIT WITH LAST FUNCTION RUN BEFORE END OF SCRIPT

function sendPush ($date)
 {

$username='xxxx';
$password='xxxxx';
$database='xxxxx';

$device="";

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

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

}


$query = "SELECT * FROM `DataTokens`";


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

while($row = $result->fetch_assoc())
{

        if (!$row)
        {
            echo "No Token, insert into database";


        }


    $device= $row['Number'];


        // Put your device token here (without spaces):
        $deviceToken = $device;

        // Put your private key's passphrase here:
        $passphrase = 'XXXXXX';

        // Put your alert message here:
        $message = 'This is a test and its working';

        $i=1;
        $number= $i++;


        $ctx = stream_context_create();
        stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
        stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);

        // Open a connection to the APNS server
        $fp = stream_socket_client(
            'ssl://gateway.sandbox.push.apple.com:2195', $err,
            $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);

        if (!$fp)
            exit("Failed to connect: $err $errstr" . PHP_EOL);

        echo 'Connected to APNS' . PHP_EOL;

        // Create the payload body
        $body['aps'] = array(
            'alert' => $message,
            'sound' => 'default',
            'badge' => +1,
            'loc-key' => 'australia1'
            );


        // Encode the payload as JSON
        $payload = json_encode($body);

        // Build the binary notification
        $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;

        // Send it to the server
        $result = fwrite($fp, $msg, strlen($msg));

        if (!$result)
            echo 'Message not delivered' . PHP_EOL;
        else
            echo 'Message successfully delivered' . PHP_EOL;

        // Close the connection to the server
        fclose($fp);
    }

        }

New Code

replaced

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

with

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

echo "we have a problem";

}

else
{

 $num_results = $result->num_rows;

while($row = $result->fetch_assoc())
{

         //blah blah
    }

    }
  • 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-03T19:10:11+00:00Added an answer on June 3, 2026 at 7:10 pm

    Use echo statements at different parts of your code to figure out where control is being lost or where the program is exiting.

    Make sure whenever you have an assignment to a variable from a command that could throw an exception, to catch the exception if it occurs, or do something with it. Or at least verify for non-null ness (!is_null()) before using that object.

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

Sidebar

Related Questions

I have a process defined in a batch file that runs 3 php scripts,
I want to run a sudo command from the PHP and I have read
I have php scripts that I have to run on linux as well as
A little context: I needed to run PHP scripts in a browser, but I
I have XAMPP on my local machine and am able to run PHP scripts
I have some long-running CLI PHP scripts that run regularly via cron. I'd like
For AJAX on my website, I make calls from a Javascript file to something.php?request=bla.
I have some jQuery/JavaScript code that I want to run only when there is
I want to run Mac OS in my Windows operative system, is there any
I want to run SearchResultByOrderNumber(string orderNumber) method in Foreach with multithreading. There are ten

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.