Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2012
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Why do I get fatal error?

    I use this code in one script with no errors.
    Now I get a fatal. Why?

    Fatal error: Call to a member function query() on a non-object

    PHP Code:

    <?php
    $con
    =mysqli_connect("localhost","","","");
    // Check connection
    if (mysqli_connect_errno()) {
      echo 
    "Failed to connect to MySQL: " mysqli_connect_error();
    }


    $dt="06-10-2014";
    $asid="60-003";

    $key=$dt." ".$asid;

    $sql "SELECT * FROM sixty where sid='$asid'";
    $result $mysqli->query($sql);
    // fatal error happens here
    $row $result->fetch_assoc(); 
    echo 
    $row['title'];

    mysqli_query($con,"INSERT INTO tracker (event,date,songID,hits) VALUES ('$key','$dt','$asid',1)
      ON DUPLICATE KEY UPDATE hits=hits+1;
    "
    );


    mysqli_close($con);
    ?>

  • #2
    Regular Coder
    Join Date
    Jun 2012
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Figured it out. connection mismatch.


  •  

    Posting Permissions

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