-1

I'm trying to use this query:

$cert= 125125161241261241261;
$cert= $cert + 1;
INSERT into table (column) values ($cert);

however, when the insertion is done.

I get something like 12512516124126124+E17 or something like that. I already have put the datatype into varchar(max) and var_dump'ed my variable

SQL Server 200x.

Mostafa Mohsen
  • 766
  • 5
  • 15

2 Answers2

1

Insert quotes '

$cert= 125125161241261241261;
$query = mysql_query("INSERT INTO table (column) VALUES('".$cert."'");
                                                       ^^^       ^^^ 
                                                         INSERT QUOTES.

BEWARE OF SQL INJECTION

USE this way

$cert= 125125161241261241261;
$sql = "INSERT INTO table (column) VALUES(?)";

$stmt = $dbConnection->prepare($sql);
$stmt->bind_param('s', $cert); -- 's' indicate is a string parameter

$stmt->execute();
Community
  • 1
  • 1
Juan Carlos Oropeza
  • 47,252
  • 12
  • 78
  • 118
0

I used a SQL procedure that does the insert and used it in my PHP insertion, Thanks for whoever tried to help.

Mostafa Mohsen
  • 766
  • 5
  • 15