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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:57:35+00:00 2026-06-05T04:57:35+00:00

I am still trying to convert mysql_* things into PDO and prepared statements. It

  • 0

I am still trying to convert mysql_* things into PDO and prepared statements. It is really hard work to do this in entire web but I am not giving up and I ran into some problems.

My question is about multiple mysql_query() commands in one function. So when i have something like this in code:

if (something)
{
   mysql_query("UPDATE account SET pass=$pass WHERE id=$id");
   mysql_query("UPDATE account_2 SET lock=$lock WHERE id=$id");
   mysql_query("UPDATE account_3 SET surname=$surname WHERE id=$id");                      
}

And want to tranfer it to PDO an prepared statements. I already know I have to do something like this:

if (something)
{
    $stmt = $db->prepare("UPDATE account SET pass=:pass WHERE id=:id");
    $stmt->bindValue(':pass', $pass, PDO::PARAM_STR);
    $stmt->bindValue(':id', $id, PDO::PARAM_INT);
    $stmt->execute();                      
}

I have actually two questions:
Is it ok to bindValue password as string (PDO::PARAM_STR)?
When I add other statements as it has more queries should I name them differently like $stmt2 or when it is executed I can do only $stmt all the time like this?

if (something)
{
    $stmt = $db->prepare("UPDATE account SET pass=:pass WHERE id=:id");
    $stmt->bindValue(':pass', $pass, PDO::PARAM_STR);
    $stmt->bindValue(':id', $id, PDO::PARAM_INT);
    $stmt->execute();

    $stmt = $db->prepare("UPDATE account_2 SET lock=:lock WHERE id=:id");
    $stmt->bindValue(':lock', $lock, PDO::PARAM_INT);
    $stmt->bindValue(':id', $id, PDO::PARAM_INT);
    $stmt->execute();                      
}

Or should I rather do this?

if (something)
{
    $stmt = $db->prepare("UPDATE account SET pass=:pass WHERE id=:id");
    $stmt->bindValue(':pass', $pass, PDO::PARAM_STR);
    $stmt->bindValue(':id', $id, PDO::PARAM_INT);
    $stmt->execute();

    $stmt2 = $db->prepare("UPDATE account_2 SET lock=:lock WHERE id=:id");
    $stmt2->bindValue(':lock', $lock, PDO::PARAM_INT);
    $stmt2->bindValue(':id', $id, PDO::PARAM_INT);
    $stmt2->execute();                      
}

And one more at the end. When I have in code function/check like this:

if (mysql_query("INSERT INTO account (id, pass, email, request_time, status) VALUES ('".$id."', '".$pass."', '".$mail."', '".time()."', '".$status."')"))
{
    blabla
}

How to use suck check in stmt and PDO if the insert command was executed if it needs to be there in PDO in the first place?

And last question … when I already bindValue in prepared statement in PDO do I later in code still need to use is_numeric() function?

So Summary:

1) Is it ok to bindValue password as string (PDO::PARAM_STR)?

2) When I add statements as it has more queries should I name them differently like $stmt, $stmt2, $stmt3 or every statement the same?

3) When I already bindValue in prepared statement in PDO do I later in code still need to use is_numeric() function (maybe for some cheating with the variable)?

Thank you all

  • 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-05T04:57:37+00:00Added an answer on June 5, 2026 at 4:57 am
    1. Yes

    2. you can name them $stmt because you won’t need a different one (once you execute you are done, so you can overwrite if you want to). But What I don’t get is why dont you just place it all in 1 statement in stead of 3 different ones?

    3. Don’t really get what you mean here? If you need to know if it’s numeric you will need is_numeric() yeah.

    And you can check if it was executed succesfully with $stmt->execute(); because it returns true if succesfull.

    So you would do

    $passed = $stmt->execute();
    
    if($passed)
    {
        //fetch
    }
    

    Here’s a simple example:

    $stmt = $db->prepare("UPDATE `account`
                             SET account.pass = ?
                           WHERE account.id = ?
                           LIMIT 1");
    
    $stmt->bindParam(1, $pass, PDO::PARAM_STR);
    $stmt->bindParam(2, $id, PDO::PARAM_INT);
    $stmt->setFetchMode(PDO::FETCH_ASSOC);
    
    if($stmt->execute())
    {
        $stmt->fetch(); //fetch your data
    }
    else
    {
        //error
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm trying to convert this Excel cell calculation into C#, but I can't
i am trying to convert array object into string but still it is returning
Still trying to figure this out from yesterday. I am trying to scroll an
I'm still trying to wrap my head around how things should be done in
I am trying to convert the user's input from the EditText into a Big
I'm trying to convert multiple .tif files into .png files using Imagemagick on the
I never worked with pgsql before and im trying to convert this function to
I was trying to convert from println to printf and this is what I
I'm trying to convert a byte[] to an image in C#. I know this
I am trying to convert UTF-8 string into UCS-2 string. I need to get

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.