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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:38:18+00:00 2026-05-26T08:38:18+00:00

I have a PHP script that is inserting a record into a database after

  • 0

I have a PHP script that is inserting a record into a database after getting the data from a user-filled form. I developed on my local machine (WAMP server) and have the following code in my PHP script:

$name = mysql_real_escape_string($_POST['name']);
        $email = mysql_real_escape_string($_POST['email']);

        //connecting to db
        mysql_connect("host", "user", "pass") or die('save_failed');
        mysql_select_db("db") or die('save_failed');

        //inserting into table
        mysql_query("INSERT INTO table(name, email) VALUES('" . $name . "', '" . $email . "' ) ") 
        or die('save_failed');  

The script worked just as expected and the records were being successfully inserted into the table.

As soon as I moved the script to my webserver, I realized the values being stored in the database were empty strings. Removing mysql_real_escape_string fixed this.

Why is it that mysql_real_escape_string won’t work on my webserver?

The database I’m working on hasn’t changed. Even when developing locally, I was hitting my webserver DB.
PHP ver on localhost is 5.3.8 while on the webserver it is 5.2.

Does PHP 5.2 not support mysql_real_escape_string, and if so what is the alternative?

  • 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-26T08:38:19+00:00Added an answer on May 26, 2026 at 8:38 am

    Put mysql_connect("host", "user", "pass") or die('save_failed'); before mysql_real_escape_string.

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

Sidebar

Related Questions

I have a PHP script that pulls keywords from a MySQL database and I
I have a php script that displays a web form to the user. When
I have created a php script to import rss feed into the database. The
I have a php script that inserts values into mySQL table INSERT INTO stories
I have the following form that I am inserting in to a database with
I have a php script that I've put together from examples on the internet.
I have one PHP script inserting rows in a MySQL database. Each row has
I have a php data migration script that serializes an array of text. Somehow,
I have a PHP CLI script, that processes a csv file, inserting it's content
I have php script that creates a temporary watermark image for users that are

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.