www.webdeveloper.com
Results 1 to 4 of 4

Thread: unexpected T_IF error? Please Help

  1. #1
    Join Date
    Feb 2012
    Posts
    102

    Unhappy unexpected T_IF error? Please Help

    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?

  2. #2
    Join Date
    Jul 2007
    Location
    Wisconsin
    Posts
    468
    looks like this might be the culprit:

    PHP Code:

    /* 

    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.

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    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

    eBookworm.us

  4. #4
    Join Date
    Feb 2012
    Posts
    102
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles