Skip to main content
deleted 13 characters in body
Source Link
Your Common Sense
  • 158k
  • 42
  • 227
  • 374

I am looking to get row count to check if same email is already in database or not. i have tried couple of mechanism but no success. when i run my query directly in the database it gives me the row count but via PDO execute it gives me 0.

i have used fetchAll method to manually count, even used rowCount method that also not working

  $sql = 'SELECT count(*) FROM inbox WHERE uid = "'.$email_number.'"? AND from_email = "'.$email_f.'"';?'; 
  $result = $link->prepare($sql); 
  $result->execute([$email_number,$email_f]); 
  $number_of_rows = $result->fetchColumn(); 

issue is with this $email_f, it contains html

SELECT count(*) FROM inbox WHERE uid = "6961" 
AND from_email = "abc Offers <[email protected]>"

this is the query which i have printed from $sql and when i execute it in database directly in phpmyadmin, it works fine. give me count of 3 but via execute i get 0.

I am looking to get row count to check if same email is already in database or not. i have tried couple of mechanism but no success. when i run my query directly in the database it gives me the row count but via PDO execute it gives me 0.

i have used fetchAll method to manually count, even used rowCount method that also not working

  $sql = 'SELECT count(*) FROM inbox WHERE uid = "'.$email_number.'" AND from_email = "'.$email_f.'"'; 
  $result = $link->prepare($sql); 
  $result->execute(); 
  $number_of_rows = $result->fetchColumn(); 

issue is with this $email_f, it contains html

SELECT count(*) FROM inbox WHERE uid = "6961" 
AND from_email = "abc Offers <[email protected]>"

this is the query which i have printed from $sql and when i execute it in database directly in phpmyadmin, it works fine. give me count of 3 but via execute i get 0.

I am looking to get row count to check if same email is already in database or not. i have tried couple of mechanism but no success. when i run my query directly in the database it gives me the row count but via PDO execute it gives me 0.

i have used fetchAll method to manually count, even used rowCount method that also not working

$sql = 'SELECT count(*) FROM inbox WHERE uid = ? AND from_email = ?'; 
$result = $link->prepare($sql); 
$result->execute([$email_number,$email_f]); 
$number_of_rows = $result->fetchColumn(); 

issue is with this $email_f, it contains html

SELECT count(*) FROM inbox WHERE uid = "6961" 
AND from_email = "abc Offers <[email protected]>"

this is the query which i have printed from $sql and when i execute it in database directly in phpmyadmin, it works fine. give me count of 3 but via execute i get 0.

edited title
Link
Your Common Sense
  • 158k
  • 42
  • 227
  • 374

Having issue with matching rows in the database using PDO

edited tags
Link
Dharman
  • 34k
  • 27
  • 105
  • 156
edited title
Link
Your Common Sense
  • 158k
  • 42
  • 227
  • 374
Loading
added 10 characters in body
Source Link
Your Common Sense
  • 158k
  • 42
  • 227
  • 374
Loading
Source Link
Loading