0

Im having an error with select statment using pdo, and Im not understanding the reason why this is happening.

Do you see something wrong here?

I'm having this error:

Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in $readGallery->execute();

$delId = $_GET['delid'];
$thumb = $_GET['thumb'];
$folder = '../uploads/';
$readGallery = $pdo->prepare("SELECT * FROM gallery WHERE news_id = ?");
$readGallery->bindParam(':news_id', $delId);
$readGallery->execute();
$numGallery =   $readGallery->rowCount();
2
  • 1
    WHERE news_id = :news_id this isn't mysqli() ;-) Commented Apr 7, 2014 at 18:07
  • To further elaborate on what @Fred-ii- said, please see this reference material... Commented Apr 7, 2014 at 18:08

1 Answer 1

2

change

$readGallery = $pdo->prepare("SELECT * FROM gallery WHERE news_id = ?");

to

$readGallery = $pdo->prepare("SELECT * FROM gallery WHERE news_id = :news_id");
Sign up to request clarification or add additional context in comments.

3 Comments

Weren't you supposed to be having lunch? lol +1 for ya, why not ;-)
well I belong to a timezone where its almost Tuesday 8th march 2014 :-)
Breakfast then, or late night snack ;-) It's lunchtime here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.