Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8785805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:27:18+00:00 2026-06-13T21:27:18+00:00

I hope this question does not seem vague but I am converting the old

  • 0

I hope this question does not seem vague but I am converting the old mysql statements to the PDO prepared statements and I have searched but cannot find the answer to this. What is the equivalent of $count=mysql_num_rows($stmt); in PDO? I have included my code so you can see what I am doing but basically I am creating a login page for users I have a PDO statement using SELECT to search the database for a matching username and password row. If it comes up with one then it will increase the $count variable to one so that my IF statment is true.

CHECK_LOGIN.PHP

<?php
require 'functions.php';
require 'DB.php';
ob_start();

// Define $myusername and $mypassword 
$myusername=$_POST['myusername']; 
$mypassword =$_POST['mypassword'];
$mypassword = md5($_POST['mypassword']);

checkLogin($conn,$myusername,$mypassword,$stmt);

// Mysql_num_row is counting table row
$count=mysql_num_rows($stmt);

// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){

// Register $myusername, $mypassword and redirect to file "login_success.php"
    session_start();
    $_SESSION['myusername'] = $myusername;
    session_is_registered("myusername");
    session_is_registered("mypassword"); 
    $myusername1 = $_SESSION['myusername'];
    //UPDATE LAST LOGIN IN DATABASE
    date_default_timezone_set('America/Chicago');
    $last_login = date('m/d/Y h:i:s a', time());
    lastLogin($conn,$myusername1,$last_login);
    header("location:form.php");


}
else {

echo "Wrong Username or Password";

}
ob_end_flush();
?>

function in FUNCTION.PHP

function checkLogin($conn,$myusername,$mypassword,$stmt){

$myusername = stripslashes($myusername);
$myusername = mysql_real_escape_string($myusername);
$stmt = $conn->prepare('SELECT * FROM `CLL_users` WHERE `user_name`=:myusername AND `password`=:mypassword');
$stmt->execute(array(':myusername' => $myusername, ':mypassword' => $mypassword));
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:27:19+00:00Added an answer on June 13, 2026 at 9:27 pm

    Check example #2 from here: PDOStatement::rowCount

    For most databases, PDOStatement::rowCount() does not return the number of rows affected by a SELECT statement. Instead, use PDO::query() to issue a SELECT COUNT(*) statement with the same predicates as your intended SELECT statement, then use PDOStatement::fetchColumn() to retrieve the number of rows that will be returned. Your application can then perform the correct action.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope this question does not come off as broad as it may seem
I hope this question is not a duplicate but I didn't find anything equivalent
I hope this question will not be rejected as there is no code. But
This question may have been asked already - but unfortunately, I could not find
I'm not sure if this question has been asked before, but I can't seem
I hope this is not a silly question, but I am very inexperienced in
I hope this question has not been asked yet, but I want to know
Hope this question is not stupid since I am an amateur web designer. I
I hope this question isn't too dumb. We have many websites internally that need
I hope this question is not 'controversial' - I'm just basically asking - has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.