Jump to content

Problem with database search and Curl POST


Recommended Posts

Hi, i'm currently building essentially an API for my URL shortener site so other sites can implement it. But i've hit a stumbling block on the last script of the lot(the others merely collate the data and store it)


In this last script, i need to find all this data, stored in cookies and inout it into the database, as the main site does(i'm confident this bit works, as it's the code from the main site just copied across, and i can see the data in the database). Importantly, i then need o look in another table for the callback URL to send the data back to


$urltoshorten = $_COOKIE["URLtoShorten"];
$alias = $_COOKIE["urlalias"];
$key = $_COOKIE["key"];
//connection details go in here
$alias =mysql_real_escape_string($alias);
$urltoshorten = mysql_real_escape_string($urltoshorten);
$base = "http://s-url.co.uk/i/?id=";
$url = $base . $alias ;
//this is the main bit, where the URL shortening occurs
mysql_query("INSERT INTO table (id, name) VALUES('$alias', '$urltoshorten')")or die( mysql_error());
//this is where the callback url is looked for
$result= mysql_query("SELECT apiaddress FROM apistuff WHERE apinumber='$key'")or die( mysql_error());
$row = mysql_fetch_array($result);
$new = $row[apiaddress]; 
//I then start a CURL session to POST data to the page in question, as found above
$Curl_Session = curl_init($new);
curl_setopt ($Curl_Session, CURLOPT_POST, 1);
curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, "shortenedurl=$url");
curl_exec ($Curl_Session); 
curl_close ($Curl_Session);

annoyingly, no errors get thrown, as far as i can see, i just end at a blank page without being returned to the callback page.


I'm rather stumped on this one, where am i likely to be going wrong/how do i go about correcting it.





Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.