I’m having trouble getting data to actually insert into a mysql database. There are no errors, but the data never succeeds in getting to the db.
I have two files at the moment:
One is a config which has the connection code:
[php]$pdoExec = ‘’;
/CONNECT TO THE DB/
try {
$db = new PDO(‘mysql:host=localhost;dbname=familybudget;charset=utf8’,‘testun’,‘testpw’);
}
catch(Exception $e) {
echo “an error has occurred”;
}
[/php]
and the other is inside the php file where the form is located.
[php]if(isset($_POST[‘Insert’]))
{
//SET THE VARIABLES AS ENTERED ON THE FORM
$addDate = $_POST['addDate'];
$addMinutes = $_POST['addMinutes'];
$addSeconds = $_POST['addSeconds'];
$addPay = $_POST['addPay'];
//PREPARE THE INSERT OPERATION
$pdoQuery = "INSERT INTO 'logrev'('Date', 'Minutes', 'Seconds', 'Paid') VALUES (:addDate,:addMinutes,:addSeconds,:addPay)";
$pdoResult = $db->prepare($pdoQuery);
//EXECUTE THE INSERT OPERATION
$pdoExec = $pdoResult->execute(array(":addDate"=>$addDate, ":addMinutes"=>$addMinutes, ":addSeconds"=>$addSeconds, ":addPay"=>$addPay));
}
if($pdoExec)
{
echo ‘data good’;
}else{
echo ‘No Data Entered’;
}
[/php]
I’m not sure where to begin or read as I don’t know what’s happening. There are no errors while running it but the data just doesn’t make it into the db and the NO DATA ENTERED is kicked off every time. So the $pdoExec is failing somehow.
Any help would be greatly appreciated. I am a firm believer in the RTFM method but I’m not sure which part to read on this one. Yep, I’m a beginner! :-\