Hi guys I know this might be a repeated post, someone has looked at the code and they seem to think that it all look fine, but I'm getting this following message again

Warning: mysqli_query(): Couldn't fetch mysqli in C:\xampp\htdocs\submit-form.php on line 19
The following SQL Failed INSERT INTO 'users' ('firstname', 'lastname', 'username', 'confirmusername', 'password', 'confirmpassword', 'email' ,'confirmemail') VALUES ('richard', 'Hemmings', 'hemmo001', 'hemmo001', 'password', 'password', 'richardgwhemmings@msn.com' , 'richardgwhemmings@msn.com')

I just cant seem to see where I'm going wrong, at first there was a single quote missing from firstname' this I have now addressed, I've been woriking on this now for 2 weeks today!

Config.php

<?php 

$connection = mysqli_connect("localhost","root","","registration");

// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

mysqli_close($connection);
?>

submit-form.php

<?php
$connection = mysqli_connect("localhost", "root", "", "registration") or die("Error!!");
//select your database
//$b=mysql_select_db("database_name",$a);
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$username=$_POST['username'];
$confirmusername=$_POST['confirmusername'];
$password=$_POST['password'];
$confirmpassword=$_POST['confirmpassword'];
$email=$_POST['email'];
$confirmemail=$_POST['confirmemail'];
//Database connection
require_once("config.php");

//mysql query to insert value to database
$query="INSERT INTOTO 'users' ('firstname', 'lastname', 'username', 'confirmusername', 'password', 'confirmpassword', 'email' ,'confirmemail') VALUES ('$firstname', '$lastname', '$username',  '$confirmusername', '$password', '$confirmpassword', '$email' , '$confirmemail')";

$result = mysqli_query($connection,$query);
//if value inserted successyully disply success message
if(!$result) {

    die("The following SQL Failed $query");
}
echo 'Registred successfully..!!</div>';
?>

Any help would be appreicated

Member Avatar for iamthwee

For future reference please don't start a new thread for an old problem. It is best to keep them altogether.

Second what is so hard about reading the documentation?

Remove the quotes around the column names or add backticks.

The word into is spelt incorrectly. You have spelt it INTOTO.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.