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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:04:04+00:00 2026-06-18T10:04:04+00:00

$_pdo = new Data(‘mysql:host=’.$db_host.’;dbname=’.$db_name.’;port=’.$db_port, $db_user, $db_pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => ‘SET NAMES ‘.$charset)); Variables come from

  • 0

$_pdo = new Data(‘mysql:host=’.$db_host.’;dbname=’.$db_name.’;port=’.$db_port, $db_user, $db_pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => ‘SET NAMES ‘.$charset));

Variables come from form.
User can make a sql injection if I don’t strip this variables?

  • 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-18T10:04:05+00:00Added an answer on June 18, 2026 at 10:04 am

    If you are accepting input from a form to create the connection I would probably use some sanitization functions to clean it up before using it. If this is being stored in a text file or a database it would be a good idea to sanitize before it is saved as well before it is used.

    http://php.net/manual/en/function.filter-var.php

    $db_host = filter_var($db_host,FILTER_SANITIZE_FULL_SPECIAL_CHARS);
    

    Equivalent to calling htmlspecialchars() with ENT_QUOTES set. Encoding
    quotes can be disabled by setting FILTER_FLAG_NO_ENCODE_QUOTES. Like
    htmlspecialchars(), this filter is aware of the default_charset and if
    a sequence of bytes is detected that makes up an invalid character in
    the current character set then the entire string is rejected resulting
    in a 0-length string.
    http://www.php.net/manual/en/filter.filters.sanitize.php

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

Sidebar

Related Questions

<?php try{ $conn = new PDO(mysql:host=$DB_SERVER;dbname=$DB_NAME,$DB_USER,$DB_PASS); } class SessionManager { var $life_time; function SessionManager()
$dbo = new PDO(mysql:host=localhost;dbname=database, databaseuser, databasepassword, array(PDO::MYSQL_ATTR_INIT_COMMAND => SET NAMES utf8)); $dbo -> exec(set
Why doesn't this PHP PDO snippet work? $DBH = new PDO(mysql:host=$host;dbname=$dbname, $user, $pass); $STH->bindParam(':fftb',
function comp_post_code($comp_post_code){ global $host, $dbname, $user, $pass; $DBH = new PDO(mysql:host=$host;dbname=$dbname, $user, $pass); $DBH->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
I have a very simple test script: <?php $DSN = "mysql:host=db.example.edu;port=3306;dbname=search_data"; try { $DB
Using this php code: try{ $dbh = new PDO(mysql:host=$host;dbname=$dbname,$user,$pass); $dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); //
I have the following code: $link = new PDO(mysql:dbname=$databasename;host=127.0.0.1,$username,$password); $query = $link->prepare(SELECT * FROM
I'm using this code and I'm beyond frustration: try { $dbh = new PDO('mysql:dbname='
I am trying to place cleaned form data into a MySQL database using PDO.
I am trying to retrieve the data from mysql database using PDO but I

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.