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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:50:10+00:00 2026-05-26T20:50:10+00:00

The following is throwing a syntax error. The entire query works in a MySQL

  • 0

The following is throwing a syntax error. The entire query works in a MySQL client with literals, but breaks down when passing from PHP. In PHP, each query works if submitted separately, but not if within START and COMMIT.

The error:

1064: You have an error in your SQL syntax; check the manual ...etc...right
syntax to use near 'INSERT INTO user_degrees (user_id, degree_id, acadcat_id
, inst_id) VALUES (' at line 2

Query:

$query="START TRANSACTION;

INSERT INTO user_degrees (user_id, degree_id, acadcat_id, inst_id) 
VALUES ((SELECT id FROM users WHERE users.username = '$user')
   , '$degreeid', '$studyfocus', '$institution');

UPDATE users 
SET degree".$dnum." = (SELECT LAST_INSERT_ID())
WHERE username = '$user';

COMMIT;";

All the $vars are class properties and pass integers, except for $user, which passes a username session variable. $dnum is used to change column names between instances of the class and I might be concatenating it incorrectly within MySQL.

  • 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-26T20:50:11+00:00Added an answer on May 26, 2026 at 8:50 pm

    PHP’s mysql driver only allows a single query per mysql_query() call as a security measure. You’ll have to issue multiple separate queries:

    $result = mysql_query("START TRANSACTION");
    $result = mysql_query("INSERT ...");
    $result = mysql_query("UPDATE ...");
    $result = mysql_query("COMMIT;");
    

    … with appropriate checking at each stage to make sure the query didn’t fail (which I’ve omitted from here).

    Note that this security measure only applies to top-level queries. One one top-level query per call. You can have as many subqueries as you want/need.

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

Sidebar

Related Questions

having an issue getting this to work. MySQL keeps throwing the following: ERROR 1064
I ve got the following query which is throwing the following error Unkown Column
The following code is throwing the error this.element is null. However, the wid_cont is
The following code is throwing two alerts as expected in IE but not in
The following Java code is throwing a compiler error: if ( checkGameTitle(currGame) ) ArrayList<String>
jQuery-Lint is throwing the following error for me: $(.around_divboxes).css is not a function $('.around_divboxes').css('marginLeft',
I have the following T-SQL query to delete a record from a series of
Why is the following code throwing me an error undefined reference to sqrt .
SVN => Get Lock is throwing following error: Command Lock Error Invalid authz configuration
Netty is throwing the following exception when i send a message asynchronously from my

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.