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

  • Home
  • SEARCH
  • 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 6835531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:14:37+00:00 2026-05-26T23:14:37+00:00

I have started in web development not long time ago. I know some stuff

  • 0

I have started in web development not long time ago. I know some stuff now, but I’m really concerned about security issues that may arise. I know simple security solutions like preg_replace , but I’m not confident with that.

So I would like to ask you for any sort of speaking “universal” security standards that can be applied in the following cases. As I mentioned, I’m not pro so it would be great if you can start with something simple, yet useful. If possible could you provide examples please?

I did have a look at php manual, although I would like to know additional info from person.

Here are some typical MySQL / PHP things I use in my projects. Could you suggest any improvements to make them more secure?

$sql = mysql_query("SELECT * FROM stories WHERE showing = 1 ORDER BY cr_date DESC LIMIT 5") or die (mysql_error("There was an error in connection"));
        while($row = mysql_fetch_assoc($sql)){
            $story_id = $row["id"];
            // etc...
        }

$username = $_POST['username'];
$sql = mysql_query("INSERT INTO myMembers (username, //etc... ) 
VALUES('$username' //etc.. ")or die (mysql_error());

$username = $_GET['username']; 
//gets username from url like http://myweb.com/profile.php?username=blabla
  • 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-05-26T23:14:37+00:00Added an answer on May 26, 2026 at 11:14 pm

    First of all, thank you for caring about web security. Many PHP developers don’t know anything about it, and don’t care to learn. They are the ones who are exposing our passwords and bank accounts to hackers. Be part of the solution! 🙂

    1. Treat the mysql extension as if it is deprecated.

    Use the PDO or mysqli extensions instead. The plain mysql extension does not support prepared statements, and some other features, such as transaction control. No one should be using mysql if they have PDO_mysql or mysqli available to them.

    2. Do not interpolate external data into SQL.

    Anytime you get a value from $_GET or $_POST, you should consider it to be unsafe to use in any SQL statement, or shell_exec(), or other instance where you execute the string as some kind of code.

    3. Use prepared query parameters instead of interpolation.

    It’s really easy. In fact, it’s easier to use query parameters than it is to interpolate variables into SQL strings. You don’t need to worry about escaping, or long complex string-concatenation.

    See example code here: http://us.php.net/manual/en/pdo.prepare.php

    4. For corner cases, use careful filtering.

    A query parameter takes the place for one literal value in an SQL expression. Not table names, not column names, not SQL keywords, not lists of values or full expressions. For those, you do need to use string interpolation, but see my presentation SQL Injection Myths and Fallacies for examples of how you can “whitelist” values to interpolate.

    Also check out the PHP filter extension, which offers a flexible way of validating inputs or stripping off invalid characters to make sure only the valid part of the input is used.


    Looking at your examples, the SELECT query has no dynamic values interpolated from external sources like $_GET. So that one is safe.

    The INSERT query takes a value from the request, which could contain malicious content that changes the way your query runs. This one is a good candidate for using query parameters.

    Also consider that SQL injection is one of the two most prevalent security issues with PHP. The other one is Cross-Site Scripting (XSS). This is not directly related to SQL, but you should learn about it too.

    Here’s a good resource for learning more about web programming security: OWASP.org cheat sheets.

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

Sidebar

Related Questions

I've been a web developer for some time now, and have recently started learning
I have been searching for the perfect web development IDE for some time now.
I have looked around SO and the web for quite some time now and
I have started learning some web development lately and have noticed lot's of sites
I have started design of a ColdFusion application that is entirely web based. Not
I have recently started experimenting with Django for some web applications in my spare
I have just started web development.I want to make a screen to do basic
Previously I have only really worked on applications, but now I am trying to
I'm new to web development and have started using JSONP and Google's Feed API
I am good in web development but recently started using PHP and developed few

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.