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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:01:05+00:00 2026-05-23T14:01:05+00:00

So I do this: <?php session_start(); include(../loginconnect.php); mysql_real_escape_string($_POST[int]); $int = nl2br($_POST[int]); $query = UPDATE

  • 0

So I do this:

   <?php
    session_start();
    include("../loginconnect.php");
mysql_real_escape_string($_POST[int]);
    $int = nl2br($_POST[int]);
    $query = "UPDATE `DB`.`TABLE` SET `interests`='$int' WHERE `user`='$_SESSION[user]'";
    mysql_query($query) or die(mysql_error());
    mysql_close($con);
    ?>

And let’s say that $_POST[int] is “Foo’ bar.” The single-quote remains unescaped AND I get a MySQL error when running the script, due to the quote. What’s wrong?

  • 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-23T14:01:05+00:00Added an answer on May 23, 2026 at 2:01 pm

    m_r_e_s() RETURNS the escaped value, it doesn’t modify the original.

    $int = mysql_real_escape_string($_POST['int']);
    
    $query = "UPDATE ... interests = '$int' ...";
    

    Note that I’ve added quotes around the int in the POST value. Without the quotes, PHP sees it as a constant value (e.g. define()). If it doesn’t find a constant of that name, it politely assumes you meant it to be used a string and adjust accordingly, but issues a warning. If you had done

    define('int', 'some totally wonky value');
    

    previously, then you’d be accessing the wrong POST value, because PHP would see it as $_POST[some totally wonky value] instead.

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

Sidebar

Related Questions

Okay. I have this code on my site: <?php session_start(); include database.php; include bruger.php;
<?php session_start(); include(connect.php); $timeout = 60 * 30; $fingerprint = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']); if(isset($_POST['userName']))
I have this code <?php session_start(); if (isset($_GET[cmd])) $cmd = $_GET[cmd]; else die(You should
when I run this code for the first time <?php session_start(); echo SID; ?>
There is an array of user states stored in the session. This works: <?php
I have this PHP code echo '<a href=# onclick=updateByQuery(\'Layer3\', ' . json_encode($query) . ');>Link
<?php session_start(); // store session data $_SESSION['count']=0; ?> <html><head></head> <body> <?php include (getElement.php); echo
Heres my code <?php session_start(); include('config.php'); if(isset($_GET['search_word'])) { // echo $_GET['search_word'] . '<br />';
Index.php <?php session_start(); require_once('../inc/db/dbc.php'); include('login_helper.php'); ?> <!-- html form --> Login/Logout Links depending on
I have this code in script.php: <?php session_start(); $user_session = $_SESSION['u_name']; class check_sess {

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.