paulbsb
asked on
Problem inserting info into a MySQL DB
I'm new to this site, php/MySQL and I'm trying to insert text and links into a db. This is the error I get, and below is the code.
mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of elements in type definition string doesn't match number of bind variables in /home/content/53/7284053/h tml/1-news ite/admin/ input.php on line 15
<?php
if (isset($_POST['insert'])) {
require_once('../includes/ connection .inc.php') ;
// initialize flag
$OK = false;
// create database connection
$conn = dbConnect('write');
// initialize prepared statement
$stmt = $conn->stmt_init();
// create SQL
$sql = 'INSERT INTO paintings (title, image, thumb, created)
VALUES(?, ?, ?, NOW())';
if ($stmt->prepare($sql)) {
// bind parameters and execute statement
$stmt->bind_param('ss', $_POST['title'], $_POST['image'], $_POST['thumb']);
// execute and get number of affected rows
$stmt->execute();
if ($stmt->affected_rows > 0) {
$OK = true;
}
}
// redirect if successful or display error
if ($OK) {
header('Location: http://paulbdotcom.db.7284053.hostedresource.com/paulbdotcom/admin/manage_paintings.php');
exit;
} else {
$error = $stmt->error;
}
}
?>
This is the page I'm trying to make work:
http://www.paulb.com/1-newsite/admin/input.php
Thanks very much,
Paul
mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of elements in type definition string doesn't match number of bind variables in /home/content/53/7284053/h
<?php
if (isset($_POST['insert'])) {
require_once('../includes/
// initialize flag
$OK = false;
// create database connection
$conn = dbConnect('write');
// initialize prepared statement
$stmt = $conn->stmt_init();
// create SQL
$sql = 'INSERT INTO paintings (title, image, thumb, created)
VALUES(?, ?, ?, NOW())';
if ($stmt->prepare($sql)) {
// bind parameters and execute statement
$stmt->bind_param('ss', $_POST['title'], $_POST['image'], $_POST['thumb']);
// execute and get number of affected rows
$stmt->execute();
if ($stmt->affected_rows > 0) {
$OK = true;
}
}
// redirect if successful or display error
if ($OK) {
header('Location: http://paulbdotcom.db.7284053.hostedresource.com/paulbdotcom/admin/manage_paintings.php');
exit;
} else {
$error = $stmt->error;
}
}
?>
This is the page I'm trying to make work:
http://www.paulb.com/1-newsite/admin/input.php
Thanks very much,
Paul
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome.
ASKER