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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:12:03+00:00 2026-05-13T09:12:03+00:00

Im writing a php script that is used to update a database but it

  • 0

Im writing a php script that is used to update a database but it is giving errors when i tries to run the query it returns an error along the lines of

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 'id=15"' at line 1

Where it says “To use near” seems to display part of the query after there is a space in the data. Im assuming i need to put single quotes around where the data to the query from the php variables but when i try to put them in (even escaping the quotes) i get parse errors from the script

The SQL Query is

    mysql_query("UPDATE Videos SET Title=".$_POST['Title'].", Preacher=".$_POST['Preacher'].", Date=".$_POST['Date'].", Service=".$_POST['Service'].", File=".$_POST['File'].", Description=".$_POST['Description']."WHERE id=".$_GET['vid_id']."\"") or die(mysql_error());

Thank in advance for any help

  • 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-13T09:12:03+00:00Added an answer on May 13, 2026 at 9:12 am

    You need to escape the variables properly and surround them by single quotes:

    mysql_query("UPDATE
                    Videos
                SET
                    Title = '".mysql_real_escape_string($_POST['Title'])."',
                    Preacher = '".mysql_real_escape_string($_POST['Preacher'])."', 
                    Date = '".mysql_real_escape_string($_POST['Date'])."',
                    Service = '".mysql_real_escape_string($_POST['Service'])."',
                    File = '".mysql_real_escape_string($_POST['File'])."',
                    Description = '".mysql_real_escape_string($_POST['Description'])."'
                WHERE
                    id = '".mysql_real_escape_string($_GET['vid_id'])."'")
    or die(mysql_error());
    

    Without escaping your variables properly, you are making yourself vulnerable to SQL injection attacks.

    EDIT

    To simplify the above, you can do a few tricks:

    // Apply mysql_escape_string to every item in $_POST
    array_map('mysql_real_escape_string', $_POST);
    // Get rid of $_POST, $_POST['Title'] becomes $p_Title
    extract($_POST, EXTR_PREFIX_ALL, 'p_');
    
    // Use sprintf to build your query
    $query = sprintf("UPDATE
                    Videos
                SET
                    Title = '%s',
                    Preacher = '%s', 
                    Date = '%s',
                    Service = '%s',
                    File = '%s',
                    Description = '%s'
                WHERE
                    id = '%s'",
                $p_Title,
                $p_Preacher,
                $p_Service,
                $p_File,
                $p_Description,
                mysql_real_escape_string($_GET['vid_id']));
    
    mysql_query($query) or die(mysql_error());
    

    Note that mixing $_POST and $_GET variables is not encouraged. You should supply the update ID through an hidden input field in the form.

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

Sidebar

Ask A Question

Stats

  • Questions 287k
  • Answers 287k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Just chain the CSS classes together, separated by periods: $('.button.check').html("sample… May 13, 2026 at 5:04 pm
  • Editorial Team
    Editorial Team added an answer With a dictionary, GetHashCode() is critical. For things that are… May 13, 2026 at 5:04 pm
  • Editorial Team
    Editorial Team added an answer You can use Xuggler (on Windows, Mac or Linux) to… May 13, 2026 at 5:04 pm

Related Questions

I'm using PHPUnderControl which runs on top of Cruise Control for my continuous integration
I'm writing an application in PHP that uses a LOT of global variables that
I'm writing a template engine (something that will add data to a template to
I am writing a php/mysql app that uses a few different tables. Table 1
Is that possible? I'm writing a web-admin interface for a network-system. I need to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.