<?php
$action=isset($_POST['action']) ? $_POST['action'] : "";
if($action=='create'){
//include database connection
include("includes/connect.php");
try{
//write query
$query="INSERT INTO todo SET begindatum = ?, todobefore = ?, todo = ?, beschrijving , opdrachtklaar = ?";
[b]//prepare query for excecution
$stmt=$con->prepare($query)[/b]
//bind the parameters
//this is the first question mark
$stmt->bindParam(1, $_POST['begindatum']);
//this is the second question mark
$stmt->bindParam(2, $_POST['todobefore']);
//this is the third question mark
$stmt->bindParam(3, $_POST['todo']);
//this is the fourth question mark
$stmt->bindParam(4, $_POST['beschrijving']);
//this is the fourth question mark
$stmt->bindParam(5, $_POST['opdrachtklaar']);
// Execute the query
if($stmt->execute()){
echo"Record was saved.";
}else{
die('Unable to save record.');
}
}catch(PDOException$exception){ //to handle error
echo"Error: ".$exception->getMessage();
}
}
?>
hij geeft aan Notice: Undefined variable: con in C:\xampp\htdocs\deplanner\add.PHP on line 23
Fatal error: Uncaught Error: Call to a member function prepare() on null in C:\xampp\htdocs\deplanner\add.PHP:23 Stack trace: #0 {main} thrown in C:\xampp\htdocs\deplanner\add.PHP on line 23.
alleen ik snap niet waar de fout kan zitten. ik heb geprobeerd aan te passen en weg te gooien maar krijg het niet voor elkaar jullie zijn mij laatste hoop.
met vriendelijke groet,
Robin
[size=xsmall]Toevoeging op 07/03/2017 13:05:50:[/size]
hij gaat hier fout in op regel 13 en 14