0

I have mp3 website where is when i click to download getting some error like this so i can fix this issue please help me out i m waiting for you guys so please tel me i also remove that space but still issue this if full code when i click on download its redirect to home page this is different question before i did not explain full now here is full with full code as well

PHP Parse error: syntax error, unexpected '$title' (T_VARIABLE) in /home/xxx/public_html/xxxx/xxxx/themes/xxxx/functions/source/download_mp3.php on line 42

<?php
require_once('../../../../../wp-load.php');
if(isset($_REQUEST['filename'])) {
    $filename = $_REQUEST['filename'];
} else {
    echo '<p>No id passed in</p>';
    exit;
}

function checkRemoteFile($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
// don't download content
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if(curl_exec($ch)!==FALSE){
    $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if (($code == 301) || ($code == 302)) {
        return false;
    }else{
        return true;
    }
}else{
    return false;
}
}
$checkMp3 = checkRemoteFile( base64_url_decode( $filename ) );
$title=$_GET['ref'];
$mp3file = base64_url_decode( $filename );
if($checkMp3){
?>
<html>
<head>
<title>Download Mp3</title>
</head>
<body>
<div class="downButtons" style="margin:5px">
<b class="red">Choose a server to download your song!</b>
<br><br><a rel="nofollow" target="_blank" title="Right Click to Download Mp3"class="dr dss" href="/download?mp3=<?php echo $mp3file;?>&title=<?php echo $title;?>"><img style="max-height:60px"src="http://ppp.com/download.jpg"></a>
</body>
</html>
<?php
}
else
{
echo '<div style="font-size:11px;text-align: center;color: black;">file not found, try other download link</div>';    
}
?>

here is line no 42 error code

 <br><br><a rel="nofollow" target="_blank" title="Right Click to Download Mp3"class="dr dss" href="/download?mp3=<?php echo $mp3file;?>&title=<?php echo $title;?>"><img style="max-height:60px"src="http://ppp.com/download.jpg"></a>
newapps1
  • 1
  • 3

1 Answers1

0

This error will only occur if you don't have set the get parameter.

And you should allways check that the get data actually exists and is not empty.

Instead of:

$title=$_GET['ref'];

You should have something like:

if (isset($_GET['ref']) && !empty($_GET['ref'])) {
    $title = $_GET['ref'];
}

EDIT: I see that you echo out the $title also, therefore you could set the title to blank if you haven't received any get data.

Like this:

if (isset($_GET['ref']) && !empty($_GET['ref'])) {
    $title = $_GET['ref'];
} else {
    $title = "";
}

Or you could shorten it like this:

$title = (isset($_GET['ref']) && !empty($_GET['ref']) ? $_GET['ref'] : '');
Andrew Larsen
  • 1,257
  • 10
  • 21
  • not working i try it but still getting same error when click on download button its come redirect to home page – newapps1 Apr 27 '15 at 12:29
  • Huh? You still get this exact error message? PHP Parse error: syntax error, unexpected '$title' (T_VARIABLE) in /home/xxx/public_html/xxxx/xxxx/themes/xxxx/functions/source/download_mp3.php on line 42 – Andrew Larsen Apr 27 '15 at 12:31
  • yes when click on download button its redirect to home page why its not downloading actually i m download it from api on soundcloud – newapps1 Apr 27 '15 at 12:34
  • Yes as in yes the error message is exact the same? I have no clue what $_REQUEST['filename'] contains, so I can't help you with the actual download part. – Andrew Larsen Apr 27 '15 at 12:51
  • may i know your skype id ? to fix this issue plesae – newapps1 Apr 27 '15 at 12:59