Please help with error


#1

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ORDER BY msg_time DESC’ at line 1
Failed query: SELECT msg_id FROM tablename WHERE msg_recip=20 AND msg_status=1 AND msg_time< ORDER BY msg_time DESC

I’m running MySQL - 4.1.20

The statement is:

SELECT msg_id FROM tablename WHERE msg_recip=$usrdata[m_id] AND msg_status=1 AND msg_time<$en[msg_time] ORDER BY msg_time DESC


#2
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY msg_time DESC' at line 1

So look in the SQL query near ‘ORDER BY msg_time DESC’

Failed query: SELECT msg_id FROM tablename WHERE msg_recip=20 AND msg_status=1 AND msg_time< ORDER BY msg_time DESC

Lookie what I found:

... AND msg_time< ORDER ...

MySQL, as any other database, or language, doesn’t really like it when you leave them on a cliffhanger like that :wink:

The statement is:

SELECT msg_id FROM tablename WHERE msg_recip=$usrdata[m_id] AND msg_status=1 AND msg_time<$en[msg_time] ORDER BY msg_time DESC

Check the $en[msg_time] variable.

Basic stuff, read Debugging. Or read the error message. It’s what I did :wink:


#3

thanks for the quick reply Zyppora. I’m trying to find where the variable is set…but i can’t find it…this is K-rate software. any ideas (anyone)


#4

here’s the statement:

<? global $usrdata; $res = sql_query("SELECT msg_id FROM $msgtable WHERE msg_recip=$usrdata[m_id] AND msg_status=1 AND msg_time < $en[msg_time] ORDER BY msg_time DESC"); $en['rw'] = sql_num_rows($res); $line = sql_fetch_assoc($res); $en = array_merge($en, $line); ?>

it used to work fine until i change to another mysql version


#5

K-rate software? Anywayz, could you please zip the file and put up a link here so I can take a look at the rest of the script? Coz if it breaks at a different version of MySQL, then it doesn’t sound like it’s all that sturdy.


#6

thank you very much Zyppora for helping. I fixed it last night. thanks