Home:ALL Converter>mysqli_stmt_bind_param and mysqli_stmt_execute expect parameter to be mysqli_stmt, boolean

mysqli_stmt_bind_param and mysqli_stmt_execute expect parameter to be mysqli_stmt, boolean

Ask Time:2016-01-18T17:39:15         Author:Iphd

Json Formatter

User clicks button:

<input type="image" src="img/like.png" alt="Like" value="Like">
<input type="hidden" name="IP" value="<?php $_SERVER ["REMOTE_ADDR"] ?>">

Save into database (errors are in comments):

<?php
    $servername = "localhost";
    $username = "username";
    $password = "password";
    if (!empty($_POST)) {
        $connection = mysqli_connect ($servername, $username, $password);
        $statement = mysqli_prepare ($connection, "INSERT INTO Like (User, PageId) VALUES (?, ?)");
        mysqli_stmt_bind_param ($statement, "si", $_POST[IP], $_GET[id]); 
        //mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean
        mysqli_stmt_execute ($statement);
       //mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, boolean
        exit;
    }
?>

Display like amount:

<?php
    $connection = mysqli_connect ($servername, $username, $password);
    $statement = mysqli_prepare ($connection, "SELECT * FROM Like WHERE PageId=$_GET[id];");
?>

Everything looks right to me, but I'm new and have a hard time learning PHP/SQL.

Author:Iphd,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/34851452/mysqli-stmt-bind-param-and-mysqli-stmt-execute-expect-parameter-to-be-mysqli-stm
Can O' Spam :

The error is found by looking at your connection, You don't connect to a database, what you have is:\n\n$connection = mysqli_connect ($servername, $username, $password);\n\n\nWhere what you need is:\n\n$database = 'my_db';\n$connection = mysqli_connect ($servername, $username, $password, $database);\n",
2016-01-18T09:42:26
yy