-1
<?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 to switch to the 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` FROM `url` WHERE `url`='".$se."'");
if (mysql_num_rows($query) != 0)
{
$rr= rand (1,10);
arr($rr);
}else{
mysql_query("INSERT INTO `url`(`url`) VALUES ('".$se."')");
return $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)."",
);
try {
$ret=$fb->api('/1111/photos', 'POST', $params);
echo 'Photo successfully uploaded to Facebook Album';
}
catch(Exception $e) {
echo $e->getMessage();
}
mysql_close($conn);
?>
나는 5 ~ 6 대의 서버에서이 모든 것을 시도했으며 모두 500 error
입니다. 그러나 SQL 연결을 제거하면 작동합니다! 모든 올바른 mysql 정보를 제공했다.서버 500 오류가 항상 발생합니다
왜 500을 보여주는 이유는 무엇입니까?
편집 :
내가
그것은 작동$query = mysql_query("SELECT `url` FROM `url` WHERE `url`='".$se."'"); if (mysql_num_rows($query) != 0) { $rr= rand (1,10); arr($rr); }else{ mysql_query("INSERT INTO `url`(`url`) VALUES ('".$se."')"); return $se; }
을 주석 경우!
3 행에' ''가 누락되었습니다.'$ dbhost ='x;'는'$ dbhost = 'x'; ' – chriz
'이어야합니다. .. 그저 오타 일 뿐이야. ^^^ - 요즘에는 결코 알지 못합니다. –
500 오류 = 문제가 발생했습니다. 서버의 오류 로그에서 500에 대한 자세한 내용을 확인하십시오. chriz가 말했듯이, 누락 된'''가있는 오타가 있는데, 이것은 치명적인 구문 분석 오류로 스크립트를 완전히 죽일 것입니다. –