PHP Version 7.1.11 INSERT INTO not working

Problems with the Windows version of XAMPP, questions, comments, and anything related.

PHP Version 7.1.11 INSERT INTO not working

Postby goyahackers » 04. December 2017 18:16

goya.php file

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Register</title>
</head>
<body>
<form action="" method="post">
User Name <input type="text" name="username"><br>
E-mail <input type="text" name="email"><br>
Password <input type="password" name="password"><br>
<input type="submit" value="Register" name="reg">
</form>

<?php

// create connection to DB
$connection = mysqli_connect("127.0.0.1", "root", "", "goya_db");

// checking the connection
if (mysqli_connect_errno()) {
die("DataBase connection1 fail..| ".mysqli_connect_error());
}else{
echo "DataBase Connection is Succesful";
}


if (isset($_POST["reg"])) {

// insert user data into database
$username = $_POST["username"];
$email = $_POST["email"];
$pass = $_POST["password"];

$data_insert_query = "INSERT INTO users (username, email, password) VALUES ('$username', '$email', '$pass')";


$query_execute = mysqli_qurey($connection, $data_insert_query);

if ($query_execute) {
echo "one record is added";
}else{
echo "Inserting query is failed";
}


} // main if end


?>

</body>
</html>
<?php mysqli_close($connection) ?>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :

sqli file

-- phpMyAdmin SQL
-- https://www.phpmyadmin.net/
-- Host: 127.0.0.1
-- Server version: 10.1.28-MariaDB
-- PHP Version: 7.1.11

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";


--
-- Database: `goya_db`
--

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
`Id` int(2) NOT NULL,
`username` varchar(20) NOT NULL,
`email` varchar(50) NOT NULL,
`password` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`Id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `Id` int(2) NOT NULL AUTO_INCREMENT;
COMMIT;


1 ) create a db called "goya_db"

2) import "goya_db.sql" to mysqli server

3) run "goya.php"

:P
goyahackers
 
Posts: 2
Joined: 04. December 2017 17:58
Location: Sri Lanka
XAMPP version: 3.2.2
Operating System: Windows 7 sp1 32 bit

Re: PHP Version 7.1.11 INSERT INTO not working

Postby Nobbie » 05. December 2017 21:59

goyahackers wrote: $query_execute = mysqli_qurey($connection, $data_insert_query);


"mysqli_qurey" is not "mysqli_query".
Nobbie
 
Posts: 9800
Joined: 09. March 2008 13:04

Re: PHP Version 7.1.11 INSERT INTO not working

Postby goyahackers » 08. December 2017 16:29

oh my god thanks a lot buddy..
fixed it..sorry for late to reply..
goyahackers
 
Posts: 2
Joined: 04. December 2017 17:58
Location: Sri Lanka
XAMPP version: 3.2.2
Operating System: Windows 7 sp1 32 bit


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 80 guests