I am getting this unexpected T_IF Error on line 70 cant figure it out. Here is the code, the code below starts at line 65:
PHP Code:
if ($uid ==($_POST['mc_gross'] ==9.99)
// Generate the download key
// A script to generate unique download keys for the purpose of protecting downloadable goods
if (empty($_SERVER['REQUEST_URI'])) {
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
}
// Strip off query string so dirname() doesn't get confused
$url = preg_replace('/\?.*$/', '', $_SERVER['REQUEST_URI']);
$folderpath = 'http://'.$_SERVER['HTTP_HOST'].'/'.ltrim(dirname($url), '/').'/';
// Generate the unique download key
$key = uniqid(md5(rand()));
// echo "key: " . $key . "<br />";
// Get the activation time
$time = date('U');
// echo "time: " . $time . "<br />";
// Generate the email with link:
// send user an email with a link to their digital download
$to = "SELECT email FROM orders WHERE transaction_id='$txn_id'";
$subject = "Your digital download is ready";
mail($to, "Thank you for your order. Here is your download key:", folderpath);
//echo "<p><span class=\"box\">" . $folderpath . "download.php?id=" . $key . "</span></p>";
// Write the key and activation time to the database as a new row
$registerid = mysql_query("INSERT INTO downloadkey (uniqueid,timestamp) VALUES(\"$key\",\"$time\")") or die(mysql_error());
$r = mysqli_query ($dbc);
if (mysqli_affected_rows($dbc) != 1) {
trigger_error('The download link could not be generated!');
}
}elseif ($uid ==($_POST['mc_gross'] ==14.99) {
$ereader = array ('realfile1' , 'realfile2' , 'realfile3');
foreach ($ereader);
if(empty($_SERVER['REQUEST_URI'])) {
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
}
// Strip off query string so dirname() doesn't get confused
$url = preg_replace('/\?.*$/', '', $_SERVER['REQUEST_URI']);
$folderpath = 'http://'.$_SERVER['HTTP_HOST'].'/'.ltrim(dirname($url), '/').'/';
// Generate the unique download key
$key = uniqid(md5(rand()));
// echo "key: " . $key . "<br />";
// Get the activation time
$time = date('U');
// echo "time: " . $time . "<br />";
// Generate the link
echo "<p><span class=\"box\">" . $folderpath . "download.php?id=" . $key . "</span></p>";
// Write the key and activation time to the database as a new row
$registerid = mysql_query("INSERT INTO downloadkey (uniqueid,timestamp) VALUES(\"$key\",\"$time\")") or die(mysql_error());
$r = mysqli_query ($dbc);
if (mysqli_affected_rows($dbc) != 1) {
trigger_error('The download link could not be generated!');
}
unset($ereader);
I have a feeling I am not going about this in the right way so if anyone has any advise I would love to have it. My goal is to read the mc_gross value and create one key for a 9.99 value and three different keys for a 14.99 value. Is that possible using the code in this fashion or do I have to go back to the drawing board?
this first IF ... you open the parenthesis, you open a second parenthesis for _POST == 9.99 (which doesn't really make sense in the first place...), close the second parenthesis... then start a new "if"
You need to properly close out the IF syntax, then wrap it's contents with { }
if ($uid ==($_POST['mc_gross'] ==9.99) ){ // should this just be if ($_POST['mc_gross'] ==9.99) { } ? } */
if ($uid ==($_POST['mc_gross'] ==9.99) // Generate the download key // A script to generate unique download keys for the purpose of protecting downloadable goods if (empty($_SERVER['REQUEST_URI'])) { $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; }
Last edited by OctoberWind; 03-03-2012 at 07:02 PM.
I suspect you'll want an opening "{" after that if statement, too?
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Thanks guys Im surprised I missed that parenthasis. Do either of you think that the code I posted will accomplish my goal of creating a single unique download key for the 9.99 and three different download keys for 14.99? For some reason I dont think I am going about this the right way. Any advise the forum community has would be very helpful.
Bookmarks