Jump to content

Recommended Posts

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()){

Link to comment
https://forums.phpfreaks.com/topic/273221-list-problem/
Share on other sites

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 by Jessica
Link to comment
https://forums.phpfreaks.com/topic/273221-list-problem/#findComment-1406013
Share on other sites

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]]

Link to comment
https://forums.phpfreaks.com/topic/273221-list-problem/#findComment-1406014
Share on other sites

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()){

Link to comment
https://forums.phpfreaks.com/topic/273221-list-problem/#findComment-1406015
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.