is there something wrong with this query?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
jasper
Forum Newbie
Posts: 3
Joined: Thu Dec 30, 2004 6:37 pm

is there something wrong with this query?

Post by jasper »

Code: Select all

$sql = "
  SELECT G.level AS g_level, G.sp_cost, S.id, S.icon,
    S.level AS s_level, S.active, S.magic, S.mp_consume, S.hp_consume,
    S.range, S.skill_time, S.reuse_delay, S.effect, S.magic_level,
    N.name, N.description
  FROM GainSkills as G
  JOIN Skills as S
    ON (
      ( G.class_id = $class_infoїid] $ancestors )
      AND G.level >= $class_infoїmin_level]
      AND G.level <= $class_info&#1111;max_level]
      AND G.skill_id = S.id
      AND G.skill_level = S.level
      )
  LEFT JOIN SkillNames as N
    ON ( S.id = N.id AND S.level = N.level AND N.language = '$l2dp_lang' )
  ORDER BY G.level, S.active, N.name, S.level;";
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'd guess this

Code: Select all

$class_info&#1111;id] $ancestors
but... mind explaining? :roll:
jasper
Forum Newbie
Posts: 3
Joined: Thu Dec 30, 2004 6:37 pm

Post by jasper »

Hi thanks for the reply, that part does look a little weird. Well the original author gave his code away and right now, I'm just shiffting through them trying to get it to work. It was originally meant for postgre and I'm trying to get it to work on mysql.

This portion of the code has the $ancestors variable.

Code: Select all

$ancestors = "";
  if ( strlen( $class_info&#1111;'parents'] ) > 0 )
  &#123;
    $par = split( ";", $class_info&#1111;'parents'] );
    foreach ( $par as $p )
    &#123;
      // lookup class_id
      $sql = "SELECT id FROM Classes WHERE name = '$p';";
      $result = mysql_query( $sql, $dbc ); 
      $lookup = mysql_fetch_array( $result );
      $ancestors .= " OR class_id = " . $lookup&#1111;'id'];
    &#125;
  &#125;
Also, if you interested in seeing the whole php file, I changed skills.php into skills.txt so you can see in from my server at http://personal.no-ip.org/lineage/skills.txt
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

Its often helpful to echo out the query so you can see what each variable is resolved to and if it breaks the query or not.
Post Reply