Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.

I'm trying to make the PDO query below working, but somehow it doesn't. This is how far i mine brain exploded! :D Is there somebody who can say what i'm doint wrong?

Thnx in advanced :)

$dbh = new PDO("mysql:host=localhost;dbname=databasename", "user", "pass"); $stmt = $dbh->prepare("SELECT * FROM `something` WHERE `email`=':email' and `name`=':name'"); $stmt->bindParam(':email', '[email protected]',PDO::PARAM_STR); $stmt->bindParam(':name', 'name',PDO::PARAM_INT); $stmt->execute(); if($stmt->rowCount() == 1) { echo "row count 1"; } else if ($stmt->rowCount() == 0) { echo "row count 0"; } else if ($stmt->rowCount() > 1) { echo "row count greater then 1"; } 

I'm trying to make the PDO query below working, but somehow it doesn't. This is how far i mine brain exploded! :D Is there somebody who can say what i'm doint wrong?

Thnx in advanced :)

$dbh = new PDO("mysql:host=localhost;dbname=databasename", "user", "pass"); $stmt = $dbh->prepare("SELECT * FROM `something` WHERE `email`=':email' and `name`=':name'"); $stmt->bindParam(':email', '[email protected]',PDO::PARAM_STR); $stmt->bindParam(':name', 'name',PDO::PARAM_INT); $stmt->execute(); if($stmt->rowCount() == 1) { echo "row count 1"; } else if ($stmt->rowCount() == 0) { echo "row count 0"; } else if ($stmt->rowCount() > 1) { echo "row count greater then 1"; } 

I'm trying to make the PDO query below working, but somehow it doesn't. This is how far i mine brain exploded! Is there somebody who can say what i'm doint wrong?

$dbh = new PDO("mysql:host=localhost;dbname=databasename", "user", "pass"); $stmt = $dbh->prepare("SELECT * FROM `something` WHERE `email`=':email' and `name`=':name'"); $stmt->bindParam(':email', '[email protected]',PDO::PARAM_STR); $stmt->bindParam(':name', 'name',PDO::PARAM_INT); $stmt->execute(); if($stmt->rowCount() == 1) { echo "row count 1"; } else if ($stmt->rowCount() == 0) { echo "row count 0"; } else if ($stmt->rowCount() > 1) { echo "row count greater then 1"; } 
added 72 characters in body
Source Link
Jens
  • 69.6k
  • 15
  • 107
  • 133

I'm trying to make the PDO query below working, but somehow it doesn't. This is how far i mine brain exploded! :D Is there somebody who can say what i'm doint wrong?

Thnx in advanced :)

$dbh = new PDO("mysql:host=localhost;dbname=databasename", "user", "pass"); $stmt = $dbh->prepare("SELECT * FROM something WHERE email=':email' and name=':name'"); $stmt->bindParam(':email', '[email protected]',PDO::PARAM_STR); $stmt->bindParam(':name', 'name',PDO::PARAM_INT); $stmt->execute();

$dbh = new PDO("mysql:host=localhost;dbname=databasename", "user", "pass"); $stmt = $dbh->prepare("SELECT * FROM `something` WHERE `email`=':email' and `name`=':name'"); $stmt->bindParam(':email', '[email protected]',PDO::PARAM_STR); $stmt->bindParam(':name', 'name',PDO::PARAM_INT); $stmt->execute(); if($stmt->rowCount() == 1)  {   echo "row count 1";  }  else if ($stmt->rowCount() == 0)  {   echo "row count 0";  }  else if ($stmt->rowCount() > 1)  {   echo "row count greater then 1";  } 

I'm trying to make the PDO query below working, but somehow it doesn't. This is how far i mine brain exploded! :D Is there somebody who can say what i'm doint wrong?

Thnx in advanced :)

$dbh = new PDO("mysql:host=localhost;dbname=databasename", "user", "pass"); $stmt = $dbh->prepare("SELECT * FROM something WHERE email=':email' and name=':name'"); $stmt->bindParam(':email', '[email protected]',PDO::PARAM_STR); $stmt->bindParam(':name', 'name',PDO::PARAM_INT); $stmt->execute();

if($stmt->rowCount() == 1) { echo "row count 1"; } else if ($stmt->rowCount() == 0) { echo "row count 0"; } else if ($stmt->rowCount() > 1) { echo "row count greater then 1"; } 

I'm trying to make the PDO query below working, but somehow it doesn't. This is how far i mine brain exploded! :D Is there somebody who can say what i'm doint wrong?

Thnx in advanced :)

$dbh = new PDO("mysql:host=localhost;dbname=databasename", "user", "pass"); $stmt = $dbh->prepare("SELECT * FROM `something` WHERE `email`=':email' and `name`=':name'"); $stmt->bindParam(':email', '[email protected]',PDO::PARAM_STR); $stmt->bindParam(':name', 'name',PDO::PARAM_INT); $stmt->execute(); if($stmt->rowCount() == 1)  {   echo "row count 1";  }  else if ($stmt->rowCount() == 0)  {   echo "row count 0";  }  else if ($stmt->rowCount() > 1)  {   echo "row count greater then 1";  } 
Source Link
hexedecimal
  • 299
  • 1
  • 3
  • 11

PDO and rowcount

I'm trying to make the PDO query below working, but somehow it doesn't. This is how far i mine brain exploded! :D Is there somebody who can say what i'm doint wrong?

Thnx in advanced :)

$dbh = new PDO("mysql:host=localhost;dbname=databasename", "user", "pass"); $stmt = $dbh->prepare("SELECT * FROM something WHERE email=':email' and name=':name'"); $stmt->bindParam(':email', '[email protected]',PDO::PARAM_STR); $stmt->bindParam(':name', 'name',PDO::PARAM_INT); $stmt->execute();

if($stmt->rowCount() == 1) { echo "row count 1"; } else if ($stmt->rowCount() == 0) { echo "row count 0"; } else if ($stmt->rowCount() > 1) { echo "row count greater then 1"; }