Can somebody help me with this litle thing.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Skywalker
Forum Contributor
Posts: 117
Joined: Thu Aug 29, 2002 3:33 am
Location: The Netherlands

Can somebody help me with this litle thing.

Post by Skywalker »

Why doesn't it Insert it in to the database? It doesn't give any errors?
The first Column is acuto_increment that's why the 0.



<?php
$Host = "localhost";
$Gebruiker = "blabla";
$Wachtwoord = "blabla";
$DBNaam = "blabla";
$TabelNaam = "blabla";

$Naam = $_POST['Naam'];
$AchterNaam = $_POST['AchterNaam'];
$Telfoon = $_POST['Telefoon'];
$EMail = $_POST['EMail'];
$Tijd = $_POST['Tijd'];
$Datum = $_POST['Datum'];
$Aantal = $_POST['Aantal'];

$Verbinding = mysql_connect ($Host,$Gebruiker,$Wachtwoord);
$Opdracht = "INSERT into $TableNaam values ('0','$Naam','$AchterNaam','$Telfoon','$EMail','$Tijd','$Datum','$Aantal')";

if (mysql_db_query ($DBNaam,$Opdracht,$Verbinding)) {
$Tekst ="Uw Reserveering is geplaats, Dank u.";
} else {
$Tekst ="Uw Reserveering is niet geplaats. Probeer het nog eens.";
}

mysql_close($Verbinding);

Code: Select all

<?php

?>
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

if a column is auto_increment you shouldn't be passing it a value. in this case you should pass it a NULL value like so:
$Opdracht = "INSERT into $TableNaam values (NULL,'$Naam','$AchterNaam','$Telfoon','$EMail','$Tijd','$Datum','$Aantal')";

the mysql_db_query() function has bee depreciated. here is the preferred way to do it:

Code: Select all

&lt;?php
$Verbinding = mysql_connect ($Host,$Gebruiker,$Wachtwoord);
mysql_select_db($DBNaam);
$Opdracht = "INSERT into $TableNaam values ('0','$Naam','$AchterNaam','$Telfoon','$EMail','$Tijd','$Datum','$Aantal')";

if (mysql_query ($Opdracht)) { 
?&gt;
Post Reply