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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:43:44+00:00 2026-06-11T11:43:44+00:00

I went through the process of converting mysql_* code into PDO code. I’ve run

  • 0

I went through the process of converting mysql_* code into PDO code. I’ve run it and checked that it works and everything. I just want Stack Overflow’s review of it, to make sure that I’m killing the connection properly, whether I should use some other method instead (e.g. transactions), making sure there are not massive security flaws. Here’s the code:

<?php
    try {
        $link = new PDO('mysql:****;dbname=****;charset=UTF-8','****','****');
        $link->exec("INSERT INTO Registration (`First Name`, `Last Name`) VALUES ('$_POST[fname]', '$_POST[lname]')");
    } catch(PDOException $e) {
        print "Error!: " . $e->getMessage() . "<br/>";
        die();
    }
?>

Like I said, it works, but I want it to be safe and effective when 100 people register at the same time. Does everything look okay?

  • 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-11T11:43:46+00:00Added an answer on June 11, 2026 at 11:43 am

    No .. you are converting mysql_ to PDO 1:1. This way, issues in mysql_ will also be a issue in PDO.

    You should look at prepared queries and parameter binding.

    Here is a example of what I mean:

    $dbh = new PDO('mysql:****;dbname=****;charset=UTF-8','****','****');
    
    $first = 'John';
    $last = 'Doe';
    
    $stmt = $dbh->prepare(
       "INSERT INTO Registration (firstname, lastname) VALUES (:first, :last)");
    $stmt->bindParam(':first', $first);
    $stmt->bindParam(':last', $last);
    
    $stmt->execute();
    
    // insert another row with different values
    $first = 'John';
    $last = 'Smith';
    $stmt->execute();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just went through the whole certificate/keychain/provisioning/appID/profile/DNA test process to get my app running
I just installed Delphi XE 2 and went through the whole installation process; however,
I went through the dev portal provisioning process twice now trying to get it
I went through a document at Adobe Livedocs that describes working with pdf: http://livedocs.adobe.com/flex/3/html/help.html?content=PDF_1.html
I went through couple of articles that talk about Web Workers in HTML5 and
I just went through writing a fairly lengthly application in c++ using mingw and
I just went through trying to make an alarm clock app with local notifications
I just exported my first Android app. the process went fine, including signing procedure.
I went looking through Raphael.js 's source code to find out how he converted
Did you ever went through the process of replacing the BOOST_FOREACH by the range-based

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.