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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:03:35+00:00 2026-05-19T16:03:35+00:00

I have an UPDATE query I’d like to perform. But there need to be

  • 0

I have an UPDATE query I’d like to perform.

But there need to be 2 conditions met before we can update a quantity in the database.

First, the sessions_id() must match one of the sessionid’s in the sessionid column, and second, the Description of the product must match the description of the product corresponding to the sessionid.

Here’s what I have:

mysql_query(UPDATE cart 
               SET quantity = $q, 
             WHERE sessionid = "'.session_id().'" 
               AND description = $d') or die(mysql_error());

Now, it is giving me the following error:

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 sessionid=”bqlbh5rdogbhmq70skhtkbvmb0″ AND description=$d’ at line 1

However, I have copied this update query straight from W3Schools, so it must be correct, right? Any help at all would be appreciated.

  • 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-19T16:03:35+00:00Added an answer on May 19, 2026 at 4:03 pm

    It should look that way:

    mysql_query("UPDATE cart SET quantity = $q WHERE sessionid='" .session_id(). "' AND description = '$d'") or die(mysql_error());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an UPDATE query where I explicitely reference the database, but MySQL still
I have a bit of a monster update query that I can't quite fit
i have an update query where i need to pass multiple parameter. Please guide
I have 200,000 plus records in mysql database. When I run update query lets
I have an update query like following: update table TABLE1 set COL1 = 'X'
I have written a query which is a composite query like one update query
I have an object model that's mapped to a database table. The update query
I have SQL update query problem. I would like to be able to update
I have update query like update dedupctntest a set a.city = case when exists(
I have something like 40K rows and i must run update query like this:

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.