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

    Join Date
    Feb 2003
    Posts
    322
    Rep Power
    0

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


    what am i missing im pulling my hair out here


    PHP Code:
    $topicid$_POST["topic"];

    $result $mysqli->query("SELECT * FROM `maintopic` WHERE topicid ='$topicid'"); 

    while (
    $row mysqli_fetch_array($result)) {  

        
    // Gather all $row values into local variables 

        
    $uid $row["topicid"];  

       echo(
    "$uid"); 
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,923
    Rep Power
    1045
    Hi,

    I don't wanna be mean, but after 10 years of doing PHP, I'd expect you to know the var_dump() function and the basics of debugging -- and how to escape variables for queries.

    OK, so PHP is telling you that query() is called on a "non-object". This obviously means there's something wrong with $mysqli. If it's no object, what is it? Where does it come from?

    Apart from that, I suggest reading The 6 worst sins of security to avoid gigantic security holes like injecting $topicid directly into the query.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    322
    Rep Power
    0
    Originally Posted by Jacques1
    Hi,

    I don't wanna be mean, but after 10 years of doing PHP, I'd expect you to know the var_dump() function and the basics of debugging -- and how to escape variables for queries.

    OK, so PHP is telling you that query() is called on a "non-object". This obviously means there's something wrong with $mysqli. If it's no object, what is it? Where does it come from?

    Apart from that, I suggest reading The 6 worst sins of security to avoid gigantic security holes like injecting $topicid directly into the query.
    haha I wish I was programming php for ten years...
  6. #4
  7. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,301
    Rep Power
    7170
    [In reference to removed posts] If you don't believe someone deserves help it's completely your prerogative to not help them, but please just ignore the thread in that case. It's not necessary to insult the person, derail the thread, and prevent others from effectively helping them.

    [@shawnhbk] Have you explored the items that Jacques1 mentioned already?
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo