php - Server 500 error occurs always -



php - Server 500 error occurs always -

<?php $dbhost = 'xx'; $dbuser = 'xx'; $dbpass = 'xxxx'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('could not connect: ' . mysql_error()); } mysql_select_db('url') or trigger_error("unable switch database: " . mysql_error()); function arr($num){ $ch = curl_init(); $r= rand (1,90); $url="https://www.googleapis.com/customsearch/v1?q=gravity%20falls%20latest%20images&num=10&start=".$r."&safe=off&cx=x:2hdsc4__avm&filter=0&c2coff=disable&alt=json&key=x"; curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, true); $output = curl_exec($ch); curl_close($ch); $a=intval($num); $data = json_decode($output, true); $se= $data['items'][$a]['pagemap']['cse_image'][0]['src']; $query = mysql_query("select `url` `url` `url`='".$se."'"); if (mysql_num_rows($query) != 0) { $rr= rand (1,10); arr($rr); }else{ mysql_query("insert `url`(`url`) values ('".$se."')"); homecoming $se; } } $rr= rand (1,10); echo arr($rr); require_once("src/facebook.php"); $config = array(); $config['appid'] = 'x'; $config['secret'] = 'x'; $config['fileupload'] = true; $fb = new facebook($config); $params = array( "access_token" => "xxx", "message" => "", "url" => "".arr($rr)."", ); seek { $ret=$fb->api('/1111/photos', 'post', $params); echo 'photo uploaded facebook album'; } catch(exception $e) { echo $e->getmessage(); } mysql_close($conn); ?>

i have tried on 5 6 servers , gives me 500 error when remove sql connection works! have supplied right mysql info .

then why showing 500?

edit:

if comment out

$query = mysql_query("select `url` `url` `url`='".$se."'"); if (mysql_num_rows($query) != 0) { $rr= rand (1,10); arr($rr); }else{ mysql_query("insert `url`(`url`) values ('".$se."')"); homecoming $se; }

it works!

take @ url table. way calling arr function recursively there chance of endless recursion if $se url values stored in table. (also if value gets cast empty string)

php html mysql curl

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -