pum
Gebruiker
- Lid geworden
- 18 dec 2009
- Berichten
- 193
ik ben nog niet zo lang bezig met php dus kunnen meer foutjes in zitten of dingen die beter kunnen maar dat probeer ik later wel te verhelpen, voor nu krijg ik telens een sql syntax error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'by, done, todo, problem, time) VALUES ('dth', 'th', 'thtr', hrt', '10')' at line 1
dit is mijn code:
<?php
include ('connect.php');
if(isset($_POST['send'])){
// als er is geklikt eerst checkken of alles is ingevuld
if(check_fields($_POST['by'], $_POST['done'], $_POST['todo'], $_POST['problem'], $_POST['time'])){
insert_data($_POST['by'], $_POST['done'], $_POST['todo'], $_POST['problem'], $_POST['time']);
}
else{
echo "velden zijn niet juist ingevoerd ";
}
}
function check_fields($by, $done, $todo, $problem, $time){
if(empty($by)){
echo "door is leeg ";
}
else if(empty($done)){
echo "gedaan is leeg ";
}
else if(empty($todo)){
echo "te doen is leeg ";
}
else if(empty($problem)){
echo "problem is leeg ";
}
else if(empty($time)){
echo "time is leeg ";
}
else{
return true;
}
}
function insert_data($by, $done, $todo, $problem, $time){
$query = "INSERT INTO articles (by, done, todo, problem, time) VALUES ('$by', '$done', '$todo', $problem', '$time')";
mysql_query($query) or die ("toevoegen is mislukt " . mysql_error());
if($query){
header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SERVER']) ."/index.php");
exit;
}
}
function show_data(){
$query = "SELECT * FROM articles";
$result = mysql_query($query) or die ("fout in de query " . mysql_error() );
echo "<table border = \"1\">";
$count = 0;
while($rij = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "<tr>";
foreach ($rij as $col_value)
{
echo "<td>" . $col_value . "</td>";
}
$count ++;
echo "</tr>";
}
echo "</table>";
}
?>
weet iemand wat hier verkeerd gaat ?
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'by, done, todo, problem, time) VALUES ('dth', 'th', 'thtr', hrt', '10')' at line 1
dit is mijn code:
<?php
include ('connect.php');
if(isset($_POST['send'])){
// als er is geklikt eerst checkken of alles is ingevuld
if(check_fields($_POST['by'], $_POST['done'], $_POST['todo'], $_POST['problem'], $_POST['time'])){
insert_data($_POST['by'], $_POST['done'], $_POST['todo'], $_POST['problem'], $_POST['time']);
}
else{
echo "velden zijn niet juist ingevoerd ";
}
}
function check_fields($by, $done, $todo, $problem, $time){
if(empty($by)){
echo "door is leeg ";
}
else if(empty($done)){
echo "gedaan is leeg ";
}
else if(empty($todo)){
echo "te doen is leeg ";
}
else if(empty($problem)){
echo "problem is leeg ";
}
else if(empty($time)){
echo "time is leeg ";
}
else{
return true;
}
}
function insert_data($by, $done, $todo, $problem, $time){
$query = "INSERT INTO articles (by, done, todo, problem, time) VALUES ('$by', '$done', '$todo', $problem', '$time')";
mysql_query($query) or die ("toevoegen is mislukt " . mysql_error());
if($query){
header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SERVER']) ."/index.php");
exit;
}
}
function show_data(){
$query = "SELECT * FROM articles";
$result = mysql_query($query) or die ("fout in de query " . mysql_error() );
echo "<table border = \"1\">";
$count = 0;
while($rij = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "<tr>";
foreach ($rij as $col_value)
{
echo "<td>" . $col_value . "</td>";
}
$count ++;
echo "</tr>";
}
echo "</table>";
}
?>
weet iemand wat hier verkeerd gaat ?