Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [MySQL syntax error
Forum PHP.pl > Forum > Przedszkole
T1000
Witam Mam problem ze składnią MySql wywala mi błąd
Kod
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\inc\doctest.php on line 21[code]
[code]Query failed: SELECT upload_id, file_name, date AS d, title AS d, FROM uploads ORDER BY date_entered DESC - 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 'FROM uploads ORDER BY date_entered DESC' at line 1

  1. <?php
  2. $query = "SELECT upload_id, file_name, ROUND(file_size/1024) AS fs, description,
  3. DATE_FORMAT(upload_date, '%M %e, %Y') AS d FROM uploads ORDER BY upload_date DDESC";
  4. $result = mysql_query ($query);
  5. ?>

A całość wygląda tak
  1. <?php
  2.  
  3. $first = TRUE; //Initialize the variable.
  4.  
  5. //query the db
  6. $query = "SELECT 'upload_id', file_name, ROUND(file_size/1024) AS fs, description,
  7. DATE_FORMAT(upload_date, '%M %e, %Y') AS d FROM uploads ORDER BY upload_date DDESC";
  8. $result = mysql_query ($query);
  9.  
  10. //Display all the URLs
  11. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  12.  
  13. //If this is the first record then create the table header
  14. if ($first) {
  15. echo '<table border="0" width="100%" cellspacing="3" cellpadding="3" align="center">
  16. <tr>
  17. <td align="left" width="20%"><font size="+1">File Name</font></td>
  18. <td align="left" width="40%"><font size="+1">Description</font></td>
  19. <td align="center" width="20%"><font size="+1">File Size</font></td>
  20. <td align="left" width="20%"><font size="+1">Upload Date</font></td>
  21. </tr>';
  22. } //End of first IF
  23.  
  24. //Display each record
  25. echo " <tr>
  26. <td align=\"left\"><a href=\"download_file.php?uid={$row['upload_id']}\">{$row['file_name']}</a></td>
  27. <td align=\"left\">" . stripslashes($row['description']) . "</td>
  28. <td align=\"center\">{$row['fs']}kb</td>
  29. <td align=\"left\">{$row['d']}</td>
  30. </tr>\n";
  31.  
  32. $first = FALSE; //one record has been returned
  33. } //End of while loop
  34.  
  35. //If no records were displayed...
  36. if($first) {
  37. echo '<div align="center"> There are currently no files to be viewed.</div>';
  38. } else {
  39. echo '</table>'; //Close table
  40. }
  41.  
  42. $result = mysql_query ($query) or die("Query failed: $query - ".mysql_error());
  43. mysql_close(); //Close the db connection
  44.  
  45. ?>
Ar2r
Popraw koniec zapytania - DESC a nie DDESC
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.