N
N
Nana1232016-01-07 20:45:30
PHP
Nana123, 2016-01-07 20:45:30

Curl restarts itself, what's the problem?

$page =mysql_query("SELECT * FROM `link` WHERE `onoff` > '2' AND `status` = '0'");
$check = mysql_num_rows($page);
$res = mysql_query("SELECT *  FROM `groups` WHERE `idgroup`  IN ( 'me','820886501366475') ");
$res1 =mysql_query("SELECT * FROM (SELECT * FROM `link` WHERE `onoff` > '2' AND `status` = '0' ORDER BY `share` LIMIT 1) a ORDER BY `id`");
$row1 = mysql_fetch_array($res1);
$today = date("F j, Y, g:i a");



if($check < 1)
{
    echo "Записей нет";
}
else
{

while($row = mysql_fetch_array($res))
{


$attachment =  array(
'id' => $id,
'access_token' => $token,
'link' => $row[link]
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://graph.facebook.com/v2.4/feed');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  //to suppress the curl output 
$result = curl_exec($ch);
curl_close ($ch);


mysql_query("INSERT INTO `status` (`id`, `idurl`, `idgroup`, `name`, `stat`, `status`, `user`) VALUES (NULL, '$as', '$row[idgroup]', '$row[name]', '$result[3]', '$result', '$row[user]');");

echo $result[3];
echo "<br />";
echo $da;
mysql_query("UPDATE `link` SET `status` = `status` + 1 WHERE `id` = ".$row1['id'].";");



}
}

    





mysql_close();

The script is executed correctly, the Facebook post is published, but exactly 10 minutes later the script starts again, and publishes again, but the next entry in the cron is
like this
php -q /home/web/domen/public_html/cron/2.php like this I run it I run
the script through the browser there are no problems
if I remove
if($check < 1)
{
    echo "Записей нет";
}
else
{

then everything works fine,
tell me please where is my cant?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question