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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:56:48+00:00 2026-06-12T19:56:48+00:00

The problem I am having is that I have a user input a string…

  • 0

The problem I am having is that I have a user input a string… Could be anything less than 156 characters, and the DBI statement inserts the string perfectly if there are no apostrophes or quotation marks in the string.

This works fine-> I am working!
This doesn’t work-> I’m not working!

To insert I use the following code:

    $sth = $dbh->prepare("INSERT INTO table VALUES('$var1','$var2','$var3')");
    $sth->execute();

I know that Perl interpolates the strings different with ‘ ‘ and ” ” but my program throws a fit when I try that. I’ve also tried using a join to join that prepare statement together using ” ” marks. The variable that stores the 155 characters is $var3 if that matters, and all 3 are VARCHAR attributes. Any suggestions?

  • 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-12T19:56:50+00:00Added an answer on June 12, 2026 at 7:56 pm

    You need to escape your variables.

    It is exactly this oversight that hackers exploit to perform SQL injection attacks: read the story of poor little Bobby Tables. Indeed, you really should avoid ever evaluating your variables for SQL, by parameterising your prepared statement:

    $sth = $dbh->prepare('INSERT INTO table VALUES(?, ?, ?)');
    $sth->execute($var1, $var2, $var3);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple problem that gets an input from the user using a
Hi The problem am having is that I have multiple TreeView control and each
I'm having a problem with some for nested loops that I have to convert
I am having a problem with structuring rails application. Let's say that I have
I'm having a strange problem in that I have php inserting text into a
I am having a problem that just started happening in OS 3.1. I have
I have a website that is updated regularly and I am having a problem
I'm having a problem. I have a UIView, that looks like this : In
I'm having a problem with using this in js. I have a function that
Im having a very strange problem, i have a complicated view that returns incorrect

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.