Jump to content

[SOLVED] Need help with a query


Darkmatter5

Recommended Posts

Here's the code

 

function list_genres($type,$default) {
  include 'library/config.inc.php';
  $conn=mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
  mysql_select_db($dbname);

  $Qgenre_id=mysql_query("SELECT genre_id FROM game_genres WHERE game_id=$default") or die(mysql_error());
  $Dgenre_id=mysql_fetch_array($Qgenre_id);
  $query=mysql_query("SELECT * FROM genres ORDER BY genre ASC") or die(mysql_error());
  echo "<select name='g' method='post' class='text_boxes'>";
  if($type=="list") { echo "<option value='all'>All Games</option>"; }
    while($row=mysql_fetch_array($query)) {
      $r1=$row['genre_id'];
      $r2=$row['genre'];
      switch($type) {
        case "list":
          if($default==$r1) { echo "<option value='$r1' selected='selected'>$r2</option>"; }
          else { echo "<option value='$r1'>$r2</option>"; }
          break;
        case "form":
          if($Dgenre_id['genre_id']==$r1) { echo "<option value='$r1' selected='selected'>$r2</option>"; }
          else { echo "<option value='$r1'>$r2</option>"; }
          break;
      }
    }
    echo "</select>";

    mysql_close($conn);
}

 

The line that runs the function on a page of mine is "<?php $vein->list_genres(form,23); ?>.  the error I'm getting is this "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 '' at line 1".  What the heck does that mean?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/143783-solved-need-help-with-a-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.