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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:15:57+00:00 2026-06-02T20:15:57+00:00

I am trying to let users edit the content that they post. The content

  • 0

I am trying to let users edit the content that they post. The content is seperated into two sections the title and the text. It also has a category but I don’t want to let them edit that. So here is the code that is suppose to update any changes to the title:

$sql = "UPDATE

topics

SET topic_subject = " . mysql_real_escape_string($_POST[‘topic_subject’]) . "

WHERE

topic_id = " . mysql_real_escape_string($_GET[‘id’]);

The code that updates the content has the same format.
I get the id from the url of the page and once they click submit on the editing page the form calls the page that contains this code. It gives me this error:

An error occurred while inserting your data. Please try again later.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near ‘WHERE topic_id =’ at line 4

I am not an expert in SQL and don’t know what the problem could be. Thanks in advance.

  • 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-02T20:16:01+00:00Added an answer on June 2, 2026 at 8:16 pm

    You’re missing single quotes around your string value:

    $subject = mysql_real_escape_string($_POST['topic_subject']);
    $topic_id = (is_numeric($_GET['id']) ? $_GET['id'] : 'NULL');
    $sql = "
        UPDATE topics
        SET topic_subject = '$subject'
        WHERE topic_id = $topic_id
    ";
    

    My code also assumes topic_id is an int column, so I’m checking if the value is numeric instead of escaping it.

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

Sidebar

Related Questions

I'm trying to let users type in date and time values into an input
I am trying to figure out how to let my users post a tweet
I'm trying to think an interface for a time-keeping system that will let users
Let's say i have a Domain Model that im trying to make compatible with
I am trying to create a rewrite rule that accomplishes two things: Redirect (www.)?domain.com
I am trying to use the jQuery Countown plugin to let my users now
So let's say I'm trying to get a list of all my users who
I'm trying to let a user "make his own service". most direct method I
I am trying to let GoogleBot login to my website and bypass the authentication.
I am using the jQuery Datepicker( http://keith-wood.name/datepick.html ). I am trying to let the

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.