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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:39:16+00:00 2026-06-05T21:39:16+00:00

I can run the following query in PHPMyAdmin, but for some reason I get

  • 0

I can run the following query in PHPMyAdmin, but for some reason I get a syntax error when I run it in a mysql method in PHP:

INSERT INTO product (model, stock_status_id, image, price, date_available, status, date_added, date_modified) 
VALUES('SP44152', 5, 'data/products/SP44152-1.jpg', '18.04', '2012-06-18', 1, '2012-06-19 00:31:35', '2012-06-19 00:57:01'); 
SET @lastid = LAST_INSERT_ID(); 
INSERT INTO product_description (product_id, language_id, name, Description) 
VALUES(@lastid, 1, 'Product item 1', 'Product Description'); 
INSERT INTO product_reward (product_id, customer_group_id, points) 
VALUES(@lastid, 1, 0);  
INSERT INTO product_to_category (product_id, category_id) 
VALUES(@lastid, 67); 
INSERT INTO product_to_store (product_id, store_id) VALUES(@lastid, 0);

the error code I am getting:

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 'SET @lastid = LAST_INSERT_ID(); INSERT INTO product_description (product_i' at line 3

I have tried removing the ; from the end of each line and I tried removing the field ‘status’ as I know that is also something you can use in MYSQL. There doesn’t seem to be much on the Internet that can help identify the cause on this one.

Any feedback is very welcome.

  • 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-05T21:39:18+00:00Added an answer on June 5, 2026 at 9:39 pm

    mysql_query does not like multiple, semi-colon separated statements:

    mysql_query() sends a unique query (multiple queries are not
    supported) to the currently active database on the server that’s
    associated with the specified link_identifier.

    Break down your query into multiple queries and execute them one-by-one:

    mysql_query("INSERT INTO product ...", $conn);
    $lastid = mysql_insert_id($conn); // you can use mysql_insert_id() PHP function
    mysql_query("INSERT INTO product_description ...", $conn);
    mysql_query("INSERT INTO product_reward ...", $conn);
    mysql_query("INSERT INTO product_to_category ...", $conn);
    mysql_query("INSERT INTO product_to_store ...", $conn);
    

    PS: I suggest that you look at alternatives to mysql_* functions.

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

Sidebar

Related Questions

In SQLite I can run the following query to get a list of columns
I'm trying to run the following query in SQL*Plus but I'm getting an error.
In my repository implementation I can run the following query using a lambda expression:
In batch script, I can run an R script with the following syntax: Rterm.exe
How can the following code be modified to run my insert statements 100 at
So, I can run the following statements from within mysql itself successfully. SET @fname
I have the following MySQL query that I execute from a .php page SELECT
How can I run the following query in PostgreSQL (the following should work on
I'm performing the following MySQL query inside phpmyadmin. The found_rows() function is not returning
Basically I want to run the following query: INSERT INTO historical_car_stats (historical_car_stats_id, year, month,

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.