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
    Dec 2010
    Location
    London
    Posts
    338
    Thanks
    63
    Thanked 11 Times in 11 Posts

    Fatal Error: non-object

    Hi, I'm still trying to get to grips with mysqli... little by little.

    I can't see my mistake - I'm getting a fatal error 'Call to a member function bind_param() on a non-object'.

    I've tried debugging with values for $title and $location but my form is passing them ok, and I've tried replace the bind_param section with directly inputted vaues but I still get a fatal error of 'non-object' on the execute().

    I've tried looking online but to no avail. I assume 'non-object' means that '$statement' is seen as NULL?

    Could anyone be so kind as to point out what I'm doing wrong?


    PHP Code:

    $db 
    mysqli_connect("xxxx","xxxx","xxxx","xxxx") or die("Error " mysqli_error($db));

    $title $_POST['title'];
    $location $_POST['location'];

    $statement $db->prepare("INSERT INTO jobBoard VALUES (?,?)");

    $statement->bind_param('ss'$title,$location);

    $statement->execute();
    $statement->close();

    header('location: index.php'); 
    Last edited by paddyfields; 10-30-2013 at 01:59 PM.

  • #2
    Regular Coder
    Join Date
    Dec 2010
    Location
    London
    Posts
    338
    Thanks
    63
    Thanked 11 Times in 11 Posts
    $statement = $db->prepare("INSERT INTO jobBoard (title,description) VALUES (?,?)");

    I was concentrating so hard on getting the new mysqli stuff right, that I made a simple error with the SQL


  •  

    Posting Permissions

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