1

So I'm trying to update a calendar with the new event title that is entered by the user through comparing the old title and updating it with the new one. Here is the code

$result = pg_prepare($conn, "event_update", "UPDATE calendar.calendar SET title = $1 WHERE title ILIKE $2");

$result = pg_execute($conn, "event_update", array($titleNew,$titleOld); 

This says that I'm not returning the right number of paramaters for my prepared statement.

$titleOld now holds 'title' but nothing is being changed and this works inside postgres, just not in the php.

user2415335
  • 53
  • 1
  • 2
  • 9

1 Answers1

2

You missed \ character for parameters in the string.

$result = pg_prepare($conn, "event_update", "UPDATE calendar.calendar SET title = \$1 WHERE title ILIKE \$2");
kyp404
  • 46
  • 2