I've problem in my code, I use these lines for example:
$numb1 = 12;
$numb2 = 6;
$folder = (string)$numb1."/".$numb2;
echo ($folder); // => 12/6
$sql="insert into test (folder) values (".$folder.");
// Here the value of folder is "2" !!!
// Structure of the colume folder : varchar(50) utf8_general_ci
I went insert in this column "folder" the string output "12/6", but every time in database I get the division of $numb1 / $numb2
, in this case I get "2";.
You should really be using mysqli. It's much more secure.
You're missing quotes around your string. SQL needs quotes to identify it as a string. Otherwise it uses as a number.
Where you say
insert into ... values(12/6)
It should be
Insert into ... Values '12/6')
Try:
"INSERT INTO test (folder)
VALUES ('".$folder."')";