Page is a not externally linkable
janton - 12:00 pm on Jul 4, 2008 (gmt 0)
Ok everything works UNTIL i want to echo $dburl; So my question How do i get the url out of my database? ____________________________________________________________________________________________________________ $_CONFIG["Username"]= 'username'; // Gebruikersnaam $url = 'http://example.get.com'; function follow_redirect($url){ if(function_exists("curl_init")){ $header = "Location: "; //echo '<ol>'; $Verbinding = mysql_connect($_CONFIG["Host"], $_CONFIG["Username"], $_CONFIG["Password"]); $TestData = array(); $dburl = "SELECT url FROM `films` WHERE id = '10'"; echo $dburl; MySql_close($Verbinding); Ok everything works UNTIL i want to echo $dburl; So my question How do i get the url out of my database?
Hi... I'm getting really close! ;) But at the end there is something wrong..
or $dburl = "SELECT url FROM `films` WHERE id = '10'";
$_CONFIG["Password"]= 'pass'; // Wachtwoord
$_CONFIG["Host"]= 'localhost'; // Host
$_CONFIG["Database"]= 'database';
$redirect_url = null;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
}
else{
$url_parts = parse_url($url);
$sock = fsockopen($url_parts['host'], (isset($url_parts['port']) ? (int)$url_parts['port'] : 80));
$request = "HEAD " . $url_parts['path'] . (isset($url_parts['query']) ? '?'.$url_parts['query'] : '') . " HTTP/1.1\r\n";
$request .= 'Host: ' . $url_parts['host'] . "\r\n";
$request .= "Connection: Close\r\n\r\n";
fwrite($sock, $request);
$response = fread($sock, 2048);
fclose($sock);
}
$pos = strpos($response, $header);
if($pos === false){
return false;
}
else{
$pos += strlen($header);
$redirect_url = substr($response, $pos, strpos($response, "\r\n", $pos)-$pos);
return $redirect_url;
}
}
while(($newurl = follow_redirect($url)) !== false){
//echo '<li>', $url, '</li>';
$url = $newurl;
}
//echo '</ol>';
$DbSelect = mysql_select_db($_CONFIG["Database"], $Verbinding);
if ($DbSelect == false)
{
trigger_error("can't find database");
}
$TestData[] = array( '10', $url );
$Query = "
INSERT INTO
`films`
SET
`id` = '%s',
`url` = '%s'
";
foreach ($TestData as $Data)
{
mysql_query(vsprintf($Query, $Data), $Verbinding)
or trigger_error('Can't find query');
}
____________________________________________________________________________________________________________
or $dburl = "SELECT url FROM `films` WHERE id = '10'";