Reputation: 23
$fnavn = $_POST['fnavn'];
$enavn = $_POST['enavn'];
$adresse = $_POST['adresse'];
$adressenr = $_POST['adressenummer'];
$postnr = $_POST['postnummer'];
$kontonr = $_POST['kontonummer'];
$cvc = $_POST['cvc'];
$fid = $_POST['frakt'];
$gid = $_SESSION['gid'];
$aid = $_SESSION['aid'];
$sql = "INSERT INTO `bestillinger` (`bestilling_id`, `adresse`, `adressenummer`, `postnummer`, `fornavn`, `etternavn`, `kontonummer`, `cvc`, `time`, `fid`, `gid`, `aid`)
VALUES (NULL, '$adresse', '$adressenr', '$postnr', '$fnavn', '$enavn', '$kontonr', '$cvc', now(), '$fid', '$gid', '$aid')";
this is my code, for some reason no data is inserted into my database - and i just cant figure out why.
both sessions have a valid value. After a form is filled out, my database is supposed to put the info into the database. what is the error?
Upvotes: 0
Views: 20
Reputation: 372
You are escaping single quotes inside a double quoted string, so that will actually print the \ character as part of the SQL, rendering your SQL invalid.
You need to replace the \' with just ', or wrap the whole query using ' instead of "
Upvotes: 1