job job - 5 months ago 47
MySQL Question

Insert data into database?

I am working on a script with a database but it has been a really long time since I learned this stuff and it is keep giving me errors and it is probably easy for you guys =)

I want the input of this

<hr> bestelling <hr>

<form action="bestellingopslaan.php" method="post">

Bestelnummer <input name="bestelnummer" type="text"> <br>
Klantnaam <input name="klantnaam" type="text"> <br>
Artikel<input name="artikel" type="text"> <br>
Prijs <input name="prijs" type="text"> <br>
<input name="verzenden" type="submit" value="Verzenden" />


to this page

bestelling opslaan

$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = '11092068';

//connection to the database
$dbhandle = mysql_connect($dbhost, $dbuser, $dbpass)
Or die("couldn't connect to SQL Server on $dbhost");

//select a database to work with
$selected = mysql_select_db($dbname, $dbhandle)
Or die("couldn't open database $dbname");

//maak de query
$insert_query = "INSERT INTO bestelling ('$_POST[bestelnummer]', '$_POST[klantnummer]', '$_POST[artikel]', '$_POST [prijs]' ) ";

if (mysql_query( $insert_query, $dbname))
echo "de gegevens zijn opgeslagen in de database";
echo "foutje";

Here is a screenshot of my database


So, I hope you guys can help me out.


It would be nice to see your errors, but from looking at your code It looks like you forgottten VALUES in your query.... It should be INSERT INTO table_name (column1, column2 ,etc) VALUES.....