cancel
Showing results for 
Search instead for 
Did you mean: 

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

jrjong
Member
1 REPLY 1


@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?

jrjong
Member