Reply
Highlighted
Member
Posts: 2
Registered: ‎05-29-2020

Cant't make Sql insert work

I have an Sql database with about 20 fields in the record. I want to create new records by only adding the values of two of these fields. So I have the following code:

CODE: SELECT ALL

$sql = "INSERT INTO Customer SET Email = '$Email', Accesscode = '$Code' ";
$result = mysqli_query($conn, $sql);		   
      if (!$sql) echo "Error 1002: Connection failed. Try later.";
	  else echo "Success";				
      mysqli_close($Conn); 

I have also tried with this:

CODE: SELECT ALL 

$sql = "INSERT INTO Customer (Email,  Accesscode) VALUES ('$Email', '$Accesscode') ";

Both of this gives the echo "Success" message, but no record enters into the table. I have also checked that the $Email and $Accesscode variables are not empty.

Thanks in advance

Sincerely

Highlighted
Member
Posts: 2
Registered: ‎05-29-2020

Re: Cant't make Sql insert work


@jrjong wrote:

I have an Sql database with about 20 fields in the record. I want to create new records by only adding the values of two of these fields. So I have the following code:

CODE: SELECT ALL

$sql = "INSERT INTO Customer SET Email = '$Email', Accesscode = '$Code' ";
$result = mysqli_query($conn, $sql);		   
      if (!$sql) echo "Error 1002: Connection failed. Try later.";
	  else echo "Success";				
      mysqli_close($Conn); 

I have also tried with this:

CODE: SELECT ALL 

$sql = "INSERT INTO Customer (Email,  Accesscode) VALUES ('$Email', '$Accesscode') roadrunner email";

Both of this gives the echo "Success" message, but no record enters into the table. I have also checked that the $Email and $Accesscode variables are not empty.

Thanks in advance

Sincerely


Anyone?