This always has to happen to me, hehe. Somehow it doesn't seem to work when it should work.
Code is as follows:
require("conn.php");
$sql = "INSERT INTO Producten (Naam, Prijs, Categorie, Beschrijving) VALUES ('$naam', '$prijs', '$categorie', '$beschrijving')";
echo $sql;
echo $conn;
$exc = odbc_exec($conn, $sql);
echo $exc;
if (!$exc)
{
echo "Error in sql ";
}
else
{
odbc_close($conn);
header( 'Location: Producten.php' );
}
odbc_close($conn);
conn.php
<?php
$conn=odbc_connect("DSN_Name","username","password");
if (!$conn)
{
echo "Connection Failed: ";
}
?>
The outturn of this is:
INSERT INTO Producten (Naam, Prijs, Categorie, Beschrijving) VALUES ('Cola', '1', 'Drank', 'Lekker')
Resource id #4
Error in sql
I've been looking for obvious reasons why it wouldn't like like typo's and such but I can't find any π
I did what you asked and pasted the SQL in Access and there it adds a row so no problem there.
Access does change the sql statement into the following:
INSERT INTO Producten ( Naam, Prijs, Categorie, Beschrijving )
SELECT 'Cola', '1', 'Drank', 'Lekker';