SkyRanger Posted January 16, 2013 Share Posted January 16, 2013 I have gone over this code 50 times now, I know there is a problem, I know I see the problem but can't find the problem. Can somebody please have a look and tell me what the problem is: if ($resultd = $mysqli->query("SELECT * FROM users order by sdate desc where valid='1' limit 5")) { while($row = $resultd->fetch_assoc()){ Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 16, 2013 Share Posted January 16, 2013 (edited) Why don't YOU tell US what the problem is? IE, why do you THINK there is a problem. Try checking for errors. Try running the query in phpmyadmin. What HAVE you done besides stare at it? :-P Oh and also once you get your error, you're going to want to read this page of the manual. http://dev.mysql.com/doc/refman/5.0/en/select.html Edited January 16, 2013 by Jessica Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 16, 2013 Share Posted January 16, 2013 The following is the SELECT query syntax definition. When an element is present, it must be in the order shown. The most commonly used parts highlighted in red - SELECT [ALL | DISTINCT | DISTINCTROW ] [HIGH_PRIORITY] [sTRAIGHT_JOIN] [sql_SMALL_RESULT] [sql_BIG_RESULT] [sql_BUFFER_RESULT] [sql_CACHE | SQL_NO_CACHE] [sql_CALC_FOUND_ROWS] select_expr [, select_expr ...] [FROM table_references [WHERE where_condition] [GROUP BY {col_name | expr | position} [ASC | DESC], ... [WITH ROLLUP]] [HAVING where_condition] [ORDER BY {col_name | expr | position} [ASC | DESC], ...] [LIMIT {[offset,] row_count | row_count OFFSET offset}] [PROCEDURE procedure_name(argument_list)] [iNTO OUTFILE 'file_name' [CHARACTER SET charset_name] export_options | INTO DUMPFILE 'file_name' | INTO var_name [, var_name]] [FOR UPDATE | LOCK IN SHARE MODE]] Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted January 16, 2013 Author Share Posted January 16, 2013 Thank you Jessica and PFMaBiSmAd, after going over the syntax def. I noticed that moving my code around so much and so many times I mixed everything up. And the more I moved something the more I broke it. Works now. if ($resultd = $mysqli->query("SELECT * FROM users where valid='1' order by sdate desc limit 5")) { while($row = $resultd->fetch_assoc()){ Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 16, 2013 Share Posted January 16, 2013 You still need to start checking for errors. If you don't get in the habit of it (or write a wrapper for this) it will take you longer to debug future problems. Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted January 16, 2013 Author Share Posted January 16, 2013 Yeah I know, If I don';t get back in the habit, I am just going to cause myself more headaches. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.