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 8047159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:00:54+00:00 2026-06-05T06:00:54+00:00

I have an old mysql code which worked correctly in the application: $query =

  • 0

I have an old mysql code which worked correctly in the application:

  $query = "
SELECT * FROM Tutor t  
WHERE 
(t.Tutorusername = '".mysql_real_escape_string($tutorusername)."')
AND
(t.Tutorpassword = '".mysql_real_escape_string($tutorpassword)."')
";


$num = mysql_num_rows($result = mysql_query($query));


while($row = mysql_fetch_array($result))
  {

  ...

}

But I now wnat to change from Mysql and instead use mysqli. My question is that is the mysqli code below exactly correct and the same equivalent to the mysql code above?

$query = $mysqli->prepare("
    SELECT * FROM Tutor t  
    WHERE 
    (t.Tutorusername = '".mysqli_real_escape_string($tutorusername)."')
    AND
    (t.Tutorpassword = '".mysqli_real_escape_string($tutorpassword)."')
    ");

    $query->bind_result($Tutor);

    $num = $query->num_rows($result = $query->execute());


    while($row = $result->fetch())
      {

...

}
  • 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-05T06:00:56+00:00Added an answer on June 5, 2026 at 6:00 am

    No need to use preapre() here because you are concatenating the sql string.

    $sql="SELECT * FROM Tutor t
            WHERE 
            t.Tutorusername='".mysqli_real_escape_string($tutorusername)."'
            AND 
            t.Tutorpassword = '".mysqli_real_escape_string($tutorpassword)."'");
    
    $result=$mysqli->query($sql);
    if($result)
    {
     $row=$result->fetch_row();
     if($row)
        print_r($row);
    }
    

    For prepare() method you have to specify the parameters:

      $sql="SELECT * FROM Tutor t 
              WHERE t.Tutorusername=? AND t.Tutorpassword=?";
    
       $stmt=$mysqli->prepare($sql);
       $stmt->bind_param("s",$tutorusername);
       $stmt->bind_param("s",$tutorpassword);
    
       $stmt->execute(); 
    
       //I presume that the table "T" has three columns
       $stmt->bind_result($col1,$col2,$col2);
       while($stmt->fetch())
       {
         echo "<br/>", $col1,$col2,$col3;
        }
    

    PS: Read PHP manual for mysqli API.

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

Sidebar

Related Questions

I have this old-style non-PDO MySQL query (the code isn't tightened up, just to
I have old code that uses size_t which IIRC comes from cstring.h. On OS
I have an old mysql code which I want to convert into PHP data
In old mysql() code, to escape a string, I did this: t.TeacherUsername = '.mysql_real_escape_string($teacherusername).'
I have a problem, an old program with mysql querys doesn't works in new
I have a hard drive with an old Ubuntu Server installation running mysql that
I currently have a news website setup in PHP/MYSQL that's a bit old and
Most of the software company have old software which continue maintain, and they also
I have an old Fortran program for reading records from text files. The records
basically i need to write a query for mysql, but i have no experience

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.