This may be a purely PHP problem, but the error message says "SQL syntax. Check the manual that corresponds to your MySQL server version..."
More important, I haven't been able to find a solution on any PHP forums. :) This is the complete error message: Failed to run SELECT F.IDArea, C.IDArea, C.Name, C.Pop, C.Nationality, C.NationalityPlural, C.NationalityAdjective FROM cia_people C, famarea2 F WHERE (C.Nationality is not null) AND (F.IDArea = 'eur') ORDER BY $_POST['order'], $_POST['direction'] - 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 '['order'], $_POST['direction']' at line 11 But the line it references isn't really line 11. This is it: $_POST[\'order\'], $_POST[\'direction\']'; $res = mysql_query($sql) or die('Failed to run ' . $sql . ' - ' . mysql_error()); Someone suggested the problem is the word "order." So I replaced every instance of "order" with "reorder" and got the same results. Another individual suggested I remove the backward slashes in the first line, but I had to add those to get rid of a series of parse errors. Does anyone have a clue what the problem/solution is? Or can you tell me exactly what I'm supposed to look up in the manual? Thanks. <head>[DATABASE CONNECTION]</head> <body> <div class="formdiv"> <form action="remote.php" method="GET"> <select name="order"> <option value="cia_people.Name'">Country, etc.</option> <option value="cia_people.Pop'">Population</option> <option value="cia_people.Nationality'">Nationality</option> <option value="cia_people.NationalityPlural'">Nationality: Plural</option> <option value="cia_people.NationalityAdjective'">Nationality: Adjective</option> <option value="famarea2.IDParentReg">Geographic Region</option> </select> <input type="radio" name="direction" value="0">+ <input type="radio" name="direction" value="1">- <input type="submit" name="submit" value="Submit"> </form> </div> <?php $colors = array( '#eee', '', '#ff9', '', '#cff', '', '#cfc', '' ); $n=0; $size=count($colors); $result = mysql_query('select count(*) FROM cia_people C, famarea2 F WHERE C.IDArea = F.IDArea AND F.IDParent = "eur" AND C.Nationality is not null'); if (($result) && (mysql_result ($result , 0) > 0)) { // continue here with the code that starts //$res = mysql_query ("SELECT * FROM type..... } else { die('Invalid query: ' . mysql_error()); } switch($order) { case 1: $order = 'cia_people.Name'; break; case 2: $order = 'cia_people.Pop'; break; case 3: $order = 'cia_people.Nationality'; break; case 4: $order = 'cia_people.NationalityPlural'; break; case 5: $order = 'cia_people.NationalityAdjective'; break; case 6: $order = 'famarea2.IDParentReg'; break; default: $order = 'cia_people.Name'; break; } switch($direction) { case 0: $direction = 'ASC'; break; case 1: $direction = 'DESC'; break; default: $direction = 'ASC'; break; } //-- [...] $sql = 'SELECT F.IDArea, C.IDArea, C.Name, C.Pop, C.Nationality, C.NationalityPlural, C.NationalityAdjective FROM cia_people C, famarea2 F WHERE (C.Nationality is not null) AND (F.IDArea = \'eur\') ORDER BY $_POST[\'order\'], $_POST[\'direction\']'; $res = mysql_query($sql) or die('Failed to run ' . $sql . ' - ' . mysql_error()); echo '<table class="sortphp" id="tab_cia_people_peo"> <thead> <tr><th>Country</th><th>X</th></tr> </thead> <tbody>'; //<!-- BeginDynamicTable --> $rowcounter=0; while ($row = mysql_fetch_array ($res)) { $c=$colors[$rowcounter++%$size]; echo "<tr style=\"background-color:$c\" class='". $row['Name'] ."'><". $_SERVER['PHP_SELF'] .'?id='. $row['IDArea'] ."> <td class='tdname' '". $row['Name'] ."'>". $row['Name'] ."</td> <td> </td></tr>\n"; } ?> </tr> </tbody> </table> </body> </html> ?> __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]