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

    Join Date
    Jul 2006
    Posts
    243
    Rep Power
    16

    Issue with Select on joined tables


    Hi,

    So far I haven't had to get into joining tables, however I am having the "Call to a member function execute() on a non-object" issue on the following and think it may be something to do with the statement itself?

    PHP Code:
       $stmt2 "SELECT t1.rideid, t1.type, t1.make, t1.model, t1.year, t1.bhp, t1.torque, t1.top_speed, t1.acceleration, t1.qtr_mile_time, t1.description, 
             t1.rideid, t1.image1, t2.garage_1 FROM ride1 AS t1
                 LEFT JOIN garage AS t2
                 ON t1.userid = t2.userid
                 WHERE t1.userid = :userid"
    ;
         
         
    $stmt $DB_con->prepare($stmt2); // Prepare the statement
    //THE ISSUE IS HERE:
        
    if($stmt2->execute(array(':userid'=>$userid))) 
    The $userid is defined already and it has a value.

    What is the issue here?

    Thanks!

    Comments on this post

    • Will-O-The-Wisp agrees : Let me know if you'd like this moved to MySQL as suggested below, genista! I'd be happy to do so :)
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,418
    Rep Power
    631
    Obviously the prepare has failed. Not sure why you are not getting a error on the page but check the httpd log. Alternatively use:
    PHP Code:
     $stmt $DB_con->prepare($stmt2);
    if (!
    $stmt) {
    print_r($DB_con->errorInfo();

    P.S. This is probably a syntax error and best posted on the MySQL forum.

    Comments on this post

    • Will-O-The-Wisp agrees
    Last edited by gw1500se; September 15th, 2015 at 06:51 AM.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2006
    Posts
    243
    Rep Power
    16
    Thanks, perfect helped me correct the syntax.

    G

IMN logo majestic logo threadwatch logo seochat tools logo