Jeg har et problem med en mysql streng i php.
Strengen virker når jeg skriver:
- $query = mysql_query("SELECT * FROM `images` WHERE ip='$ip' LIMIT 5") ;
men når jeg skriver fungere det slet ikke.
- $query = mysql_query("SELECT * FROM `images` WHERE ip='$ip' DESC LIMIT 5");
Jeg vil gerne have at de 5 nyeste (ikke de 5 første billeder) med en bestemt ip bliver vist.
koden ser ud som følger
- $conn = mysql_connect($hostname, $username, $password) OR DIE ("Unable to connect to database! Please try again later.");
- mysql_select_db($dbname) OR DIE ("Unable to find the database! Please try again later.");
- $query = mysql_query("SELECT * FROM `images` WHERE ip='$ip' LIMIT 5") ;
- if (!$query) {
- echo 'Could not show last uploaded pictures: ' . mysql_error();
- exit;
- }
- $row = mysql_fetch_row($query);
- echo "YOUR LAST UPLOADED FILES<br />";
- while($row = mysql_fetch_array($query))
- {
- echo "<a href='upload/" .$row['name']. "'><img class='uploaded_pics' src='upload/" .$row['name']. "' alt='' />" . "</a>";
- }
- mysql_close($conn);
Hvad gør jeg forkert?