0

I am trying to insert some data into a MySQL database using MySQLi, I have connected to the database but the page is just blank and the MySQL database is empty. Any ideas?

<?php

$mysqli = new mysqli('localhost', '***', '***', '***');

/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}

session_start();

$stmt = $mysqli->prepare("INSERT INTO membersinfo VALUES (?, ?, ?, ?, ?, ?, ?,     ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param('ssssssssssssssssssssssssssssssss', $_SESSION['fullname'],     $_SESSION['sex'], $_SESSION['dob'], $_SESSION['nameofparent'],     $_SESSION['address1'], $_SESSION['address2'], $_SESSION['city'], $_SESSION['postcode'], $_SESSION['homephone'], $_SESSION['mobilephone'] ,$_SESSION['workphone'], $_SESSION['email'], $_SESSION['email2'], $_SESSION['contactname'], $_SESSION['relation'], $_SESSION['phonenumber'], $_SESSION['med'], $_SESSION['disability'], $_SESSION['typeofdis'], $_SESSION['natureofdis'], $_SESSION['sport'], $_SESSION['wheresport'], $_SESSION['friends'], $_SESSION['sign1'], $_SESSION['con1'], $_SESSION['date1'], $_SESSION['sign2'], $_SESSION['con2'], $_SESSION['date2'],$_POST['sign3'], $_POST['con3'], $_POST['date3']);

/* execute prepared statement */
$stmt->execute();

printf("%d Row inserted.\n", $stmt->affected_rows);

/* close statement and connection */
$stmt->close();

/* close connection */
$mysqli->close();
?>

1 Answers1

0

You have 32 ? And 33 values. Therefore you are getting the following mysql error or similar,

MySQL error: Column count doesn't match value count

If you want to see the error please include this in your code

error_reporting(E_ALL);
ini_set('display_errors', 1);
Leandro Papasidero
  • 3,728
  • 1
  • 18
  • 33