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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:48:58+00:00 2026-06-06T17:48:58+00:00

I am starting a very basic site that uses a single line form to

  • 0

I am starting a very basic site that uses a single line form to post into a database and then later echo that $comment variable on the page. I don’t know PDO, but am willing to learn if I truly need it for something this simple.

else
mysql_query("INSERT INTO posts (postid, post_content)
VALUES ('', '$comment <br />')");
}
mysql_close($con);

Above this code I have basic strpos commands to block out some of the things I don’t want posted.

Am I going to experience any issues with injections down the road from how I am doing this?

  • 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-06T17:48:59+00:00Added an answer on June 6, 2026 at 5:48 pm

    No, it’s not safe, you need to use mysql_real_escape_string to escape $comment.

    But, PDO is nothing difficult and make your code stronger.

    // create the connection. something like mysql_connect/mysql_error
    try {
        $dbh = new PDO($dsn, $user, $password);
    } catch (PDOException $e) {
        echo 'Connection failed: ' . $e->getMessage();
    }
    
    // create the prepared statement.
    $stmt = $dbh->prepare("INSERT INTO posts (postid, post_content) VALUES (?, ?)");
    // execute it with parameters.
    $stmt->execute(array('', $comment.'<br>'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just starting out learning C# and I've become stuck at something very basic.
First of all I have to admit that these are very basic and primitive
I am really starting with Message Queue and I am looking for very basic
I'm just starting to play with asp.net mvc and I've got a very basic
I'm just starting to mess around with a very, very basic call to the
I'm a newbie in WPF, so it probably is something very basic that I'm
Starting from scratch with very little knowledge of .NET, how much ASP.NET should I
I am very familiar with C# but starting to work more in Java. I
Starting from Android 3.2 I have this strange problem. It's very easy to reproduce:
I am very new to Dynamics CRM, and starting to learn how to develop

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.