Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

What is wrong with this PDO Delete Query?

I'm stripping this thing down to bear bones and I'm still coming up with an error. What am I doing wrong?

Here's the code:

require_once('../bootstrap.php');

$con=DatabaseFactory::CreateOneCommunityConnection();

//$participantid=$_POST['participantid'];
//$readingtypeid = $_POST['readingtypeid'];

$participantid=1;
$readingtypeid = 1;

//1. DELETE ALL READINGS FROM TBLPARTICIPANTREADING

$DeleteReadings=$con->prepare("delete from tblparticipantreading where participantid = :participantid");
$DeleteReadings=bindParam(':participantid', $participantid, PDO::PARAM_INT); //as soon as I add this line, I get an error that says the page can't be displayed. Why?
//$DeleteReadings->execute();

?>

I've got a good database connection. I can run $DeleteReadings=$con->prepare("delete from tblparticipantreading where participantid = :participantid"); and there are no errors, but as soon as I add $DeleteReadings=bindParam(':participantid', $participantid, PDO::PARAM_INT); , I get a 500 error.

What's wrong with what I'm doing? Where am I blowing it?
ASKER CERTIFIED SOLUTION
Avatar of Mukesh Yadav
Mukesh Yadav
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bruce Gust

ASKER

Sometimes, you just gotta look at yourself and go, "Why?"

Thank you!