Welcome to WebmasterWorld Guest from 54.197.116.116

Forum Moderators: open

Message Too Old, No Replies

MySQL Hidden record?!

mysql hidden record

   
6:33 pm on Oct 18, 2005 (gmt 0)

5+ Year Member



i made a table to store past events (where each event is a record) however, when i retrieve the entire contents (SELECT *) and order the results by a field in descending order (ORDER BY 'date' DESC) there is one record the most recent record) that will not display unless i double it (two identical records)- then it will display (once)!
This is soo frustrating!
i have deduced that it must be a MySQL issue and not a PHP one...

Does anybody have any ideas on what could be causing this?

6:35 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



have you tried deleting the original and leaving the dupe in case there is some corruption in the row?

if you add another record does it still do it?

6:53 pm on Oct 18, 2005 (gmt 0)

5+ Year Member



i just inserted a new record with unique information and now both (of the duplicate) records show up, but not the new one...
7:02 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



are you using a limit on your query that might be offset by 1?

are you sure it isn't a php loop counter issue?

7:06 pm on Oct 18, 2005 (gmt 0)

5+ Year Member



i have (this is not the exact code only an idea of it)

"SELECT * FROM table ORDER BY `date` DESC";
$r = mysql_query($q, $db)

and the only loop that i do is:

while ($result = mysql_fetch_object($r))
{print...}

7:29 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



do you do anything else at all with $r bfore your mysql_fetch_object?

anything that might offset the internal pointer?

7:35 pm on Oct 18, 2005 (gmt 0)

5+ Year Member



i assigned it as so
$r = mysql_query($q, $db)
where $q = the MySQL: Select statement...

Thank you for your patience, and tolerace (since this seems to be more PHP based than MySQL related...)

9:05 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



The quickest way to determine where the problem lies -- MySQL or PHP -- would be to run the query statement from a command line. Take a look at the result set and see if all the rows you expect to see are there. To get the same exact query statement that is being processed by your PHP script, dump the statement to your browser, copy and paste it to the command line, and check the results.
$q = "SELECT * FROM table ORDER BY `date` DESC"; 
exit("$q"); // script stops here, copy the statement from the browser
$r = mysql_query($q, $db);
while ($result = mysql_fetch_object($r)) {
// print ...
}

On a side note, although MySQL allows you to use 'date' as a column name, I still try to keep away from using reserved words.