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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:53:53+00:00 2026-05-18T10:53:53+00:00

Hi im having an interesting problem. Update: From the comments im getting below this

  • 0

Hi im having an interesting problem.

Update: From the comments im getting below this seems to be an issue of trying to run multiple queries at the same time. I had assumed that since I was doing it in phpmyadmin, then it was all good. How does one go about running multiple queries? I am using mysqli? I am using mysql 5.x and using mysqli

Im running my query from my application and if the query does not function I echo it to the screen. Along with is’s error

When i run my application I get my query printed to the screen and this 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 ‘ALTER TABLE tmp_bulletins ADD INDEX (bb_id); ‘ at line 13

When I copy the query which was echoed to the screen and run it in phpmyadmin it works fine every time. I have then tried taking the query that was echoed to the screen and running that on the database through my application and it doesn’t work.

As far as I can tell, the exact same query(the one printed to my screen) is working through phpmyadmin, but not through my applcation.

Is there any reason that this might happen? Does phpmyadmin make some changes to a query before it runs it on the database?

Here is the query

CREATE TEMPORARY TABLE tmp_bulletins

                   SELECT {$table}.id AS bb_id,count(bb_replies.id) AS num_responses,bb_locations.title AS location,bb_locations.description AS location_description,bb_categories.title AS category,bb_categories.description AS category_description,Concat(users.first_name,' ',users.last_name) AS full_name,users.first_name AS first_name,users.last_name as last_name,users.id AS user_id,{$table}.title AS post_title,{$table}.content,{$table}.created_date,{$table}.rank 
                   FROM `{$table}` 
                   LEFT JOIN bb_locations ON {$table}.bb_locations_id = bb_locations.id
                   LEFT JOIN bb_categories ON {$table}.bb_categories_id = bb_categories.id
                   LEFT JOIN users ON {$table}.users_id = users.id
                   LEFT JOIN bb_replies ON {$table}.id = bb_replies.bbs_id
                   WHERE `bb_locations_id` IN ({$locations_csv}) AND `bb_categories_id` IN ({$categories_csv}) {$addWhere}
                   GROUP BY bb_id,location,location_description,category,category_description,first_name,last_name,user_id,post_title,content,created_date,rank
                   {$order} {$limit} ;

              ALTER TABLE tmp_bulletins ADD INDEX (`bb_id`);


              CREATE TEMPORARY TABLE tmp_ratings      

                   SELECT bbs_id,
                   sum(CASE WHEN user_id = {$user_id} THEN like_dislike_id END) AS thisUsersRating,
                   SUM(CASE WHEN like_dislike_id = 2 THEN 1 ELSE 0 END) AS likes, 
                   SUM(CASE WHEN like_dislike_id = 1 THEN 1 ELSE 0 END) AS dislikes
                   FROM bb_ratings
                   GROUP BY bbs_id;  

              ALTER TABLE tmp_ratings ADD INDEX (`bbs_id`); 

              SELECT * FROM tmp_bulletins
          LEFT JOIN tmp_ratings on tmp_bulletins.bb_id = tmp_ratings.bbs_id;

And the query that it produces(editing the look as we speak)

    CREATE TEMPORARY TABLE tmp_bulletins 
    SELECT bbs.id AS bb_id,count(bb_replies.id) AS num_responses, 
    bb_locations.title AS
     location,bb_locations.description AS location_description,
    bb_categories.title AS
     category,bb_categories.description AS category_description,
    Concat(users.first_name,' ',users.last_name) AS full_name,
    users.first_name AS first_name,
    users.last_name as last_name,users.id AS user_id,
    bbs.title AS post_title,
    bbs.content,bbs.created_date,bbs.rank FROM `bbs` 
    LEFT JOIN bb_locations ON bbs.bb_locations_id = bb_locations.id 
    LEFT JOIN bb_categories ON bbs.bb_categories_id = bb_categories.id 
    LEFT JOIN users ON bbs.users_id = users.id LEFT JOIN bb_replies ON bbs.id = bb_replies.bbs_id WHERE `bb_locations_id` IN (1,2) AND `bb_categories_id` IN (1,2) 
    GROUP BY bb_id,location,location_description,category,category_description,first_name,last_name,user_id,post_title,content,created_date,rank LIMIT 0,5; ALTER TABLE tmp_bulletins 
    ADD INDEX (`bb_id`); 

    CREATE TEMPORARY TABLE tmp_ratings 
    SELECT bbs_id, sum(CASE WHEN user_id = 1 THEN like_dislike_id END) AS thisUsersRating, SUM(CASE WHEN like_dislike_id = 2 THEN 1 ELSE 0 END) AS likes,
    SUM(CASE WHEN like_dislike_id = 1 THEN 1 ELSE 0 END) AS dislikes FROM bb_ratings GROUP BY bbs_id; 
ALTER TABLE tmp_ratings ADD INDEX (`bbs_id`); 

    SELECT * FROM tmp_bulletins LEFT JOIN tmp_ratings on tmp_bulletins.bb_id = tmp_ratings.bbs_id
  • 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-18T10:53:53+00:00Added an answer on May 18, 2026 at 10:53 am

    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.

    are you executing multiple queries at once?

    EDIT

    Your queries are complex, simplify it and run query by query. To identify the problem.

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

Sidebar

Related Questions

No related questions found

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.