Jump to content

Strange MySQL query troubles


Depthcharge

Recommended Posts

Hey all, I'm new to php and the boards here but I need some help badly.

 

I'm trying to run a series of four queries to populate corresponding tables on my page.  The oddness is that I can only run one of these queries and it doesn't matter which one it is, as long as its the first on the page.  To verify this I logged into mysql directly and tested the queries and all of them run as desired. 

 

The code for all 4 tables is identical save for the query table names.  Basically what happens is the first query runs and the first table gets populated.  Following that, the second query fails and this message is displayed:

 

"Couldn�t execute query: 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 ') AS EnginesEquipped ON Engine.EngineID = EnginesEquipped.EngineID' at line 1"

 

Clearly the syntax is alright though since I the problem is completely order independent and the mysql client has no problems with it, right?

The relevant PHP code is below:

 

<code>

 

// TABLE OPENING TAGS AND TABLE HEADERS...

 

<?php

$sql = "SELECT * FROM Armor LEFT JOIN (SELECT * FROM DesignHasArmor WHERE DesignHasArmor.DesignID = $DesignID) AS ArmorsEquipped ON Armor.ArmorID = ArmorsEquipped.ArmorID";

 

$result = mysql_query($sql) or die("Couldn’t execute query:  ". mysql_error());

 

$rows = mysql_num_rows($result);

 

if ($rows != 0)

{

    while ($row = mysql_fetch_array($result))

    {

          extract($row);

 

          // OUTPUT STUFF HERE...

    }

}

?>

 

// TABLE CLOSING TAGS...

</code>

 

 

Ok, I hope that explains my hang up.  If anyone has any ideas I'd love to hear them.

 

-DC

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.