Hi I have a question about my writing to my database:
I'm new to the mysql_escape_string
because a friend told me.
Since I use mysql_escape_string
it doesn't write to my db anymore.
Here is the code:
////////////////////////////////////////////////////////////////
$iets = $_POST['aantal'] + $_POST['begin'];
for ($i = $_POST['begin'] ; $i < $iets ; $i++){
$rows = $rows.'a'.$i.', ';
}
$rows = mysql_escape_string(trim($rows, ', '));
/////////////////////////////////////////////////////////////////////
$iets = $_POST['aantal'] + $_POST['begin'];
for ($i = $_POST['begin'] ; $i < $iets ; $i++){
$r = 'a'.$i;
$values = $values.'\''.$_POST[$r].'\', ';
}
$values = mysql_escape_string(trim($values, ', '));
$naam = mysql_escape_string($_POST['naam']);
mysql_query("INSERT INTO $naam
(
$rows
)
VALUES
(
$values
)");
mysql_close($con);
printf("%s<br />%s", $values, $rows);
When I have :
aantal = 3
begin = 4
The output of printf
, with a4=abcdef
, a5=ghijkl
, a6=mnopq
is:
\'abcdef\', \'ghijkl\', \'mnopq\'<br />
a1, a2, a3
I don't get it, the backlashes shouldn't have an impact right?