Jump to content

Recommended Posts

Here's the query

SET SESSION SQL_BIG_SELECTS=1;
SELECT CONCAT(forename,' ',surname) AS name, c.class, pc.abil_strength AS str, pc.abil_dexterity AS dex, pc.abil_constitution AS con, pc.abil_intelligence AS `int`, pc.abil_wisdom AS wis, pc.abil_charisma AS cha, strmod.modifier AS strmod, dexmod.modifier AS dexmod, conmod.modifier AS conmod, intmod.modifier AS intmod, wismod.modifier AS wismod, chamod.modifier AS chamod
FROM d_player_characters AS pc
Inner Join d_classes AS c ON c.class_id=pc.first_class_id
Inner Join t_ability_modifiers AS strmod ON strmod.score=pc.abil_strength
Inner Join t_ability_modifiers AS dexmod ON dexmod.score=pc.abil_dexterity
Inner Join t_ability_modifiers AS conmod ON conmod.score=pc.abil_constitution
Inner Join t_ability_modifiers AS intmod ON intmod.score=pc.abil_intelligence
Inner Join t_ability_modifiers AS wismod ON wismod.score=pc.abil_wisdom
Inner Join t_ability_modifiers AS chamod ON chamod.score=pc.abil_charisma
WHERE pc.character_id='11'

 

Here's the PHP code that runs this query.

$select="SET SESSION SQL_BIG_SELECTS=1;
  SELECT CONCAT(forename,' ',surname) AS name, c.class, pc.abil_strength AS str, pc.abil_dexterity AS dex, pc.abil_constitution AS con, pc.abil_intelligence AS `int`, pc.abil_wisdom AS wis, pc.abil_charisma AS cha, strmod.modifier AS strmod, dexmod.modifier AS dexmod, conmod.modifier AS conmod, intmod.modifier AS intmod, wismod.modifier AS wismod, chamod.modifier AS chamod
  FROM d_player_characters AS pc
  Inner Join d_classes AS c ON c.class_id=pc.first_class_id
  Inner Join t_ability_modifiers AS strmod ON strmod.score=pc.abil_strength
  Inner Join t_ability_modifiers AS dexmod ON dexmod.score=pc.abil_dexterity
  Inner Join t_ability_modifiers AS conmod ON conmod.score=pc.abil_constitution
  Inner Join t_ability_modifiers AS intmod ON intmod.score=pc.abil_intelligence
  Inner Join t_ability_modifiers AS wismod ON wismod.score=pc.abil_wisdom
  Inner Join t_ability_modifiers AS chamod ON chamod.score=pc.abil_charisma
  WHERE pc.character_id='$id'";
$result=mysql_query($select) or die(mysql_error());
$row=mysql_fetch_array($result);
echo "<table border='0' width='100%'>
  <tr><td colspan='4'><b>Character: </b>$row[name]</td></tr>
  <tr><td colspan='4'><b>First class: </b>$row[class]</td></tr>
  <tr><td colspan='4'> </td></tr>
  <tr><th colspan='2'><b>Abilities</b></th><th>Mods</th><th> </th></tr>
  <tr><td width='40'><b>STR:</b></td><td width='30' align='right' class='abil'>$row[str]</td><td width='30' align='center' class='abil_mod'>$row[strmod]</td><td> </td></tr>
  <tr><td><b>DEX:</b></td><td align='right' class='abil'>$row[dex]</td><td align='center' class='abil_mod'>$row[dexmod]</td><td> </td></tr>
  <tr><td><b>CON:</b></td><td align='right' class='abil'>$row[con]</td><td align='center' class='abil_mod'>$row[conmod]</td><td> </td></tr>
  <tr><td><b>INT:</b></td><td align='right' class='abil'>$row[int]</td><td align='center' class='abil_mod'>$row[intmod]</td><td> </td></tr>
  <tr><td><b>WIS:</b></td><td align='right' class='abil'>$row[wis]</td><td align='center' class='abil_mod'>$row[wismod]</td><td> </td></tr>
  <tr><td><b>CHA:</b></td><td align='right' class='abil'>$row[cha]</td><td align='center' class='abil_mod'>$row[chamod]</td><td> </td></tr>";
echo "</table>";

 

I'm getting the following 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 'SELECT CONCAT(forename,' ',surname) AS name, c.class, pc.abil_strength AS str, p' at line 2".

 

The query executes find in Navicat, but PHP doesn't seem to like it. If this is a PHP problem i'm sorry I posted it in the wrong forum. I just suspect it's the "SET SESSION SQL_BIG_SELECT=1;" that PHP doesn't like. So I suspect I'll have to go another route to make PHP like the code. Is there an easier way to write this query that PHP won't complain about?

 

Any help is appreciated!

Link to comment
https://forums.phpfreaks.com/topic/162571-help-with-a-query-with-multiple-joins/
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.