Reputation: 1
My end goal is to hjave a simple web app that we can enter paper/toner usage, and runs reports. It is nothing complex, and serves to allow me to learn php. I am using PDO for the database work. I made the insert function work perfectly, but for the life of me, I cannot get the below statement to run. All I want to do is take the data, and then display it on an html form. MySQL is really really easy, but PDO is giving me a headache (I have searched everywhere, and cannot find a unified method to accomplish what I want)
include 'dbconnector.php';
$pastdate = $_POST['date'];
if (isset($_POST['datepull'])){
$pulldata = ("SELECT Paper, Black, Cyan, Magenta, Yellow, Blacksp, Cyansp,
Magentasp, Yellowsp FROM tablename WHERE Date = :date"):
$getdata = $database_connector->prepare($pulldata);
$getdata->bindParam(':date', $pastdate);
$getdata->execute();
$row = $getdata->fetch(PDO::FETCH_ASSOC);
print $row['Paper']. "\t";
}
else {
echo "It didnt work again";
}
Upvotes: 0
Views: 24
Reputation: 4709
Yo have a colon (:
) instead of a semicolon (;
) after the sql string. Besides date is a keyword, I think your date
value should be a string.
Try this:
$getdata->bindParam(':date', $pastdate, PDO::PARAM_STR);
Hope it helps.
Upvotes: 1