homepage Welcome to WebmasterWorld Guest from 54.227.77.237
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

Databases Forum

    
MySQL Hidden record?!
mysql hidden record
feralo




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

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?

 

jatar_k




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

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?

feralo




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

i just inserted a new record with unique information and now both (of the duplicate) records show up, but not the new one...

jatar_k




msg:1578342
 7:02 pm on Oct 18, 2005 (gmt 0)

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?

feralo




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

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...}

jatar_k




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

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

anything that might offset the internal pointer?

feralo




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

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...)

coopster




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

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved