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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:47:46+00:00 2026-05-19T21:47:46+00:00

I have tried the following query in phpmyadmin and it returns the correct results,

  • 0

I have tried the following query in phpmyadmin and it returns the correct results, but when I try passing the result to a variable in php that variable is essentially empty (i.e., when I try using it in a while loop with mysql_fetch_array, I get nothing. And mysql_num_rows returns only 1).

Could this be tied to the fact that I’m creating a temporary table in MySQL? Here’s the query:

CREATE TEMPORARY TABLE solved
SELECT comments.nid FROM flag_content
LEFT JOIN comments ON flag_content.content_id=comments.cid
LEFT JOIN term_node ON term_node.nid=comments.nid
WHERE flag_content.fid=3 AND term_node.tid=522;

SELECT node.nid, node.title, users.name, node_counter.totalcount, node_comment_statistics.comment_count, node_comment_statistics.last_comment_timestamp
FROM node
LEFT JOIN term_node ON node.nid = term_node.nid
LEFT JOIN node_comment_statistics ON node.nid = node_comment_statistics.nid
LEFT JOIN node_counter ON node.nid = node_counter.nid
LEFT JOIN users ON node.uid = users.uid
LEFT JOIN solved ON node.nid=solved.nid
WHERE term_node.tid=522 AND solved.nid IS NULL;

I have this query stored in a PHP function:

function getPosts(){
   dbConnect(); //establishes connection
   //"....." in the following line is the above query
   return mysql_query(".......") or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $query . "<br />\nError: (" . mysql_errno() . ") " . mysql_error()); 
}

And the line of code that calls it is:

$result = getPosts();

When I call getPosts(), the query dies with a fatal error. I get two versions of the same error depending on whether the query is concatenated across multiple lines with “.” or simply written on a single line.

Error when concatenated across multiple lines:

Error: (1064) 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 'comments.nid FROM flag_content LEFT JOIN comments ON flag_content.content_id=com' at line 1

Error when written on a single line:

Error: (1064) 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 'SELECT node.nid, node.title, users.name, node_counter.totalcount, node_comment_s' at line 1
  • 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-19T21:47:46+00:00Added an answer on May 19, 2026 at 9:47 pm

    try executing the queries one at a time. create the temp table, select into it, then drop it as three separate queries. as a security precaution, the sql socket only allows one query in an execution block

    It would look something like…

    
    mysql_query("CREATE TEMPORARY TABLE solved
    SELECT comments.nid FROM flag_content
    LEFT JOIN comments ON flag_content.content_id=comments.cid
    LEFT JOIN term_node ON term_node.nid=comments.nid
    WHERE flag_content.fid=3 AND term_node.tid=522;");

    $result = mysql_query("SELECT node.nid, node.title, users.name, node_counter.totalcount, node_comment_statistics.comment_count, node_comment_statistics.last_comment_timestamp
    FROM node
    LEFT JOIN term_node ON node.nid = term_node.nid
    LEFT JOIN node_comment_statistics ON node.nid = node_comment_statistics.nid
    LEFT JOIN node_counter ON node.nid = node_counter.nid
    LEFT JOIN users ON node.uid = users.uid
    LEFT JOIN solved ON node.nid=solved.nid
    WHERE term_node.tid=522 AND solved.nid IS NULL;
    ");

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

Sidebar

Related Questions

I have tried to do this refering to following link. http://skypher.com/index.php/2008/07/28/function-list-for-php/ But no success.
I have been tried the following query and it succeeds (only returns the one
I tried the following query but it doesn't give the answer that I need
I have tried the following: <%= image_tag '...path_to_img', :filter => alpha(opacity=50) %> But it
I have tried the following code but has no effect: Imports system.Runtime.InteropServices <DllImport(UxTheme.DLL, BestFitMapping:=False,
I have tried with the following, but it just says & was unexpected at
I have tried for unload and beforeunload binding in following code, but none of
I have tried using the obvious method as outlined in the following example but
I have the following query that when executed, it just runs for hours and
I have a query that works in phpmyadmin however does not work in 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.