B
B
Bur Ov2016-01-21 21:51:15
PHP
Bur Ov, 2016-01-21 21:51:15

How to insert a response from one script into another?

There is a script:

<?php
include_once 'MultiCurl.class.php'
$poolSize = 10; 
$requests = array(
    array('url' => 'https://www.google.com/search?q=0'),
    array('url' => 'https://www.google.com/search?q=1'),
    array('url' => 'https://www.google.com/search?q=2'),
    array('url' => 'https://www.google.com/search?q=3'),
    array('url' => 'https://www.google.com/search?q=4'),
    array('url' => 'https://www.google.com/search?q=5'),
    array('url' => 'https://www.google.com/search?q=6'),
    array('url' => 'https://www.google.com/search?q=7'),
    array('url' => 'https://www.google.com/search?q=8'),
    array('url' => 'https://www.google.com/search?q=9'),
    array('url' => 'https://www.google.com/search?q=10'),
);
$startTime = round(microtime(true) * 1000);
$example1 = new MultiCurl($poolSize);
$results = $example1->processRequests($requests);
$endTime = round(microtime(true) * 1000);
echo (count($results) . ' requests were done in ' . ($endTime - $startTime) . ' ms <br/>');
echo 'results: <br/>';
foreach ($results as $key => $value) {
    echo $value['url'] . ': ' . $value['status'] . ', content length ' . strlen($value['response']) . ')<br/>';
}
unset($poolSize, $example1, $requests, $results);
?>

To display links in this form from the database, I do this:
<?php
    $connect = mysql_pconnect("localhost", "sssss","ssssss"); 
      $select = mysql_select_db("ssssss", $connect);
      $sql = mysql_query("SELECT * FROM `ssssss`");
    echo '$requests = array(';
      while ($return = mysql_fetch_array($sql)) {
      echo "array('url' => 'https://www.google.com/search?access_token=".$return["token"]."'),";

}		  echo ');';
?>

Then I copy all the text from the browser, it's about 2k links, paste it into the topmost script and run it...
How to make the first script automatically display all the lines from the database in the right form and immediately execute them. I tried to simply specify the include_once 'test.php' file in the place of the array of links, in which the data is displayed in the desired form to the browser, but then when the script is launched, it simply displays everything on the screen, and does not process the links ...
------- ------
Phew, I know what I wrote is not clear and confusing, but I think someone will understand me and tell me what to do)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2016-01-21
@burov0798

$requests = [];
while ($return = mysql_fetch_array($sql)) {
   $requests[] = array('url' => 'https://www.google.com/search?access_token=".$return["token"]."');
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question