Hi everybody
I’m trying to make a form to submit data to my PHPMyAdmin database.
The php to connect seems to work fine but when I try to submit data from the form it gives me the error “error inserting new record”. Is there anybody out there who can tell me what I’m doing wrong?
Here’s the html for the form:
Quote
Add your company
to the database
Unquote
And here is the php:<?php
include(‘connect-mysql.php’);
$CustId=$_POST[‘CustId’];
$Company=$_POST[‘Company’];
$Country=$_POST[‘Country’];
$PostalCode=$_POST[‘PostalCode’];
$City=$_POST[‘City’];
$StreetAndNr=$_POST[‘StreetAndNr’];
$GenTel=$_POST[‘GenTel’];
$GenMail=$_POST[‘GenMail’];
$Website=$_POST[‘Website’];
$Domain=$_POST[‘Domain’];
$sql=“INSERT INTO Customers (CustId, Company, Country, PostalCode, City, StreetAndNr, GenTel, GenMail, Website, Domain) VALUES (’$CustId’, ‘$Company’, ‘$Country’, ‘$PostalCode’, ‘$City’, ‘$StreetAndNr’, ‘$GenTel’, ‘$GenMail’, ‘$Website’, ‘$Domain’)”;
if (!mysqli_query($dbcon, $sql)) {
die (‘error inserting new record’);
}
$answer = “1 record added to the database”;
?>
Unquote
This is the connect file in php:
Quote<?php
DEFINE (‘DB_USER’, ‘Any userr’);
DEFINE (‘DB_PSWD’, ‘Any password’);
DEFINE (‘DB_HOST’, ‘localhost’);
DEFINE (‘DB_NAME’, ‘Any DB’);
$dbcon = mysqli_connect (DB_HOST, DB_USER, DB_PSWD, DB_NAME);
if (!$dbcon){
die (‘error connecting to database’);
}
//echo ‘you have connected succesfully’;
?>
The names of user, password and db have been replaced by dummy values.
Much appreciated.
Sven