I've been pulling my hair out on this MySQL query.
Let's say I have this:
$add = "INSERT INTO books (title) VALUES(?)";
if ($stmt = $mysqli->prepare($add)) {
$arr = array($title);
foreach ($arr as $value) {
echo var_dump($value);
}
$stmt->bind_param("s", $title);
With that foreach
-> var_dump
:
string 'Medieval Times (History)' (length=24)
int 1422843281
int 1420844341
string '127.0.0.1' (length=9)
string 'MY_EMAIL@gmail.com' (length=22)
string '' (length=0)
int 1420844805
int 6
int 3
int 1
int 0
int 0
int 1
int 1
int 1
int 1
Well, it stops when it hits this line and I get this error:
Fatal error: Call to a member function bind_param() on a non-object in C:\wamp\www\books\dashboard.php on line 386
With line 386: $stmt->bind_param ...
So, I know I am importing 16 variables yet ... I get this error. Argh.