#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2016
    Location
    Lakewood, WA
    Posts
    196
    Rep Power
    17

    Error I don't understand...


    I'm getting the following error, and I'm not understanding the error, nor seeing a problem with the code:
    Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in
    The line it refers to is the IF line.

    PHP Code:
    $this->database->prepareSql("SELECT mission_key.Puid, LL_data.Puid AS a, LZ_data.Puid AS b, AR_data.Puid AS c" .
        
    " FROM mission_key LEFT JOIN LL_data ON LL_data.Puid = mission_key.Puid" .
        
    " LEFT JOIN LZ_data ON LZ_data.Puid = mission_key.Puid LEFT JOIN AR_data ON AR_data.Puid = mission_key.Puid");
    $this->database->executeQuery();
    $Puid_rows $this->database->fetchAssoc();

    foreach(
    $Puid_rows as $Puid_row) {
        if ((
    $Puid_row['a'] == null) && ($Puid_row['b'] == null) && ($Puid_row['c'] == null)) {
            
    $this->database->prepareSql("DELETE FROM " $this->config['tables']['mission_key'] . " WHERE Puid = :Puid");
            
    $this->database->bindParamSingle(':Puid',$Puid_row['Puid'],PDO::PARAM_STR);
            
    $this->database->executeQuery();        
        }

    The function removes the Puid from the Mission Key table *IF* it is *NOT* present in *ALL THREE* tables, a, b, and c.

    For some reason, this worked fine before I started to convert everything to PDO...
    Last edited by Arty Zifferelli; August 7th, 2017 at 04:37 PM.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,312
    Rep Power
    630
    The error is likely elsewhere but manifests itself on that line. If you post all the code the formatter may show it.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2016
    Location
    Lakewood, WA
    Posts
    196
    Rep Power
    17
    PHP Code:
    public function delete_Primary_key() {
        try {
            
    $this->database->prepareSql("SELECT mission_key.Puid, LL_data.Puid AS a, LZ_data.Puid AS b, AR_data.Puid AS c" .
                
    " FROM mission_key LEFT JOIN LL_data ON LL_data.Puid = mission_key.Puid" .
                
    " LEFT JOIN LZ_data ON LZ_data.Puid = mission_key.Puid LEFT JOIN AR_data ON AR_data.Puid = mission_key.Puid");
            
    $this->database->executeQuery();
            
    $Puid_rows $this->database->fetchAssoc();            
            
            
    // If all the event tables come up null for a particular Puid, delete it from the Mission Key table.                
            
    foreach($Puid_rows as $Puid_row) {
                if ((
    $Puid_row['a'] == null) && ($Puid_row['b'] == null) && ($Puid_row['c'] == null)) {
                    
    $this->database->prepareSql("DELETE FROM " $this->config['tables']['mission_key'] . " WHERE Puid = :Puid");
                    
    $this->database->bindParamSingle(':Puid',$Puid_row['Puid'],PDO::PARAM_STR);
                    
    $this->database->executeQuery();        
                }
            }
            return 
    true;
        }
        catch (
    PDOException $e) {
            echo 
    "<pre>";
            
    print_r($e);
            echo 
    "</pre>";
            
    //$errorHandler->PDOException($e);
            
    return false;
        }

    As I said above, this popped up as I am converting to PDO...

    There are four tables, all contain a row with a column named "Puid". "mission_key" is a control table. When all three of the other tables (a, b, and c) no longer contain a row that matches a row in the mission_key table, the mission_key table row is deleted.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,312
    Rep Power
    630
    The is a syntax error not a usage (runtime) error. What you posted so far still seems syntactically OK. The error must be further up in your code (above the function definition).
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. Wiser? Not exactly.
    Devshed God 2nd Plane (6000 - 6499 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    6,072
    Rep Power
    4101
    I'm not seeing any obvious problem in what you've posted so far. Either the error is further up as mentioned (look for an unclosed single quote) or it might be the same as this invisible character problem.

    In the later case, re-write the code (don't copy/paste) or use a hex editor/viewer to search for anything unusual.
    Recycle your old CD's



    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud
  10. #6
  11. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,760
    Rep Power
    4536
    Man, you done messed up and angered the PHP God's, Arty! Repent!
    -- Cigars, whiskey and wild, wild women. --

IMN logo majestic logo threadwatch logo seochat tools logo