Darkmatter5 Posted February 4, 2009 Share Posted February 4, 2009 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 More sharing options...
Darkmatter5 Posted February 4, 2009 Author Share Posted February 4, 2009 Argh, please disregard, the $default should have been '$default' in the $Qgenre_id query. Thanks anyways! Link to comment https://forums.phpfreaks.com/topic/143783-solved-need-help-with-a-query/#findComment-754379 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.