I'm really sorry for coming here with my errors but I'm not quite sure where to go from here.
I have a database that can be submitted to via a GET form to use PHP and INSERT INTO MySQL query however most data can be inputted fine but on some data (for example if every column value is test) it deletes ALL the rows in the database? I don't know why it is happening and worst of all how to fix it.
Anyone got any ideas?
DESCRIBE data;
+---------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| name | varchar(100) | YES | | NULL | |
| company | varchar(100) | YES | | NULL | |
| date | varchar(250) | YES | | NULL | |
| country | varchar(50) | YES | | NULL | |
| notes | varchar(250) | YES | | NULL | |
+---------+--------------+------+-----+---------+-------+
is my MySQL table. My PHP is as follows
<?php
//Connecting to sql db.
$connect = mysqli_connect('localhost','root','----','----');
//Sending form data to sql db.
$name = mysqli_real_escape_string($connect, $_GET['name']);
$company = mysqli_real_escape_string($connect, $_GET['company']);
$date = mysqli_real_escape_string($connect, $_GET['date']);
$country = mysqli_real_escape_string($connect, $_GET['country']);
$notes = mysqli_real_escape_string($connect, $_GET['notes']);
mysqli_query($connect, "INSERT INTO data (name, company, algo, country, notes) VALUES ('$name', '$company', '$date', '$country', '$notes')");
?>
If you need anything else to help diagnose the problem please ask
echo "INSERT INTO data (name, company, algo, country, notes) VALUES ('$name', '$company', '$date', '$country', '$notes')";
and run the query directly in Mysql and see the result.
You should not use name
as column name.