Send to a Friend

Newboston's avatar

What's wrong with this simple PHP script?

Asked by Newboston (2points) March 9th, 2011 from iPhone

I’m trying to make a simple page that uses the TinyURL API to generate a short URL, but something is going wrong. No matter what I do, I’m getting the same error every time. I’m suspecting it may be a host-related issue, or maybe even an error on TinyURL’s side? The error is “Unexpected T_VARIABLE at line 6.” I’m hosting with GoDaddy. Is there something I need to configure? I’m not sure what the deal is, but please take a look, here’s the code:

<?php

$long = $_POST[‘long_url’];

function shorten($the_long_url) {
    $short = file_get_contents(‘http://tinyurl.com/api-create.php?url=’.$the_long_url);
    return $short;
}

echo (shorten($long));

?>

Using Fluther

or

Using Email

Separate multiple emails with commas.
We’ll only use these emails for this message.