Hi everyone, I have been trying to update a mysql database with the shortend url I get from bit.ly
I have the shortend url displayed on the page, but everytime I try and update mysql with the variable
$bitlylink.. instead of http://bit.ly/123abc the database is updated with
http://the.full.website.url/directory/link.html
How can I update the database with the correct url I get back from bit.ly
$link = "$bitlyslug";
$bitlylink = "$link";
$suiid = "$suiid";
print getSmallLink($link);
function getSmallLink($longurl){
// Bit.ly
$url = "http://api.bit.ly/shorten?version=2.0.1";
$s = curl_init();
curl_setopt($s,CURLOPT_URL, $url);
curl_setopt($s,CURLOPT_HEADER,false);
curl_setopt($s,CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($s);
curl_close( $s );
$obj = json_decode($result, true);
return $obj["results"]["$longurl"]["shortUrl"];
}
?>
<?php
// update shorturl
// add short url to db -
mysql_query ("UPDATE table SET bitly='$bitlylink' WHERE var='$var_val'")
or die(mysql_error());
// end short url update
?>
If someone good show me why I am getting the wrong url added to my databse that would be great...
Thanks