Q:

mysql commands out of sync ( i use mysql not mysqli !) 

today i faced a strange error witch i didn't faced before ! 
i Google it but not helped . 
in here i found some problem like me BUT it was mysqli !  
i am using mysql only not mysqli. 
mysql_query("SELECT id FROM s1_users WHERE id>4 AND ".time()." -  timestamp < 300");

but i get
mysql commands out of sync you can't run this command now

i ran this query's hundred time before worked fine but i don't know why its telling me this error. 

A:

Q: What causes this "strange error" to be returned? 

mysql commands out of sync you can't run this command now

A: That error isn't strange.  It's expected behavior. 
Reference: http://dev.mysql.com/doc/refman/5.5/en/commands-out-of-sync.html

If you get Commands out of sync; you can't run this command now in your client code, you are calling client functions in the wrong order. 

EDIT
Q: How do I debug my program? 
A: Check the return from your database interface calls for errors. 
Reference: How to debug small programs http://ericlippert.com/2014/03/05/how-to-debug-small-programs/
Make just a small change your code.  Generate the SQL text into a string variable as a separate step, before prepare/execute of the generated SQL text.  And before the prepare/execute, output the string containing the actual SQL text that's going to be submitted, e.g.
$sql = "SELECT id FROM s1_users WHERE id>4 AND ".time()." -  timestamp < 300";
echo "SQL=" .  $sql;  // for debugging

Then use a reference to $sql into your database interface function call (e.g. prepare or execute), pass the SQL statement to the database server.  Here's a good pattern to follow: whenever you generate dynamic SQL and submit it to the database, do it in two steps.  One step to generate the string, and a separate step that submits the generated SQL to the database. 
When you run the code, the "echo" (or vardump or whatever) will show you the actual SQL text that's going to be submitted to the database.   You can take that SQL statement to a different  client, and test it.  Likely, the database server is throwing an error on that statement, and you'll be able to spot it. 
It's also likely that your code (which you haven't shown us) isn't checking the return from the database interface calls, to see if there was an error or not.  I suspect your code is putting it's pinky finger to the corner of its mouth, Dr. Evil style, and saying "I'm just gonna assume it all went to plan.  What?" 

FOLLOWUP
Why do you need to supply the value from the PHP time() function as part of the SQL text?  If you need the current time from the database server, the MySQL NOW() function would give that to you.  If you need a unix timestamp version of that value (seconds since the beginning of the era in UTC), you can use the MySQL UNIX_TIMESTAMP function, e.g. UNIX_TIMESTAMP(NOW()). 
If you can have a static string as a SQL statement that achieves what you need, that is usually a better option.  If you need to supply literal values in a SQL statement, a better pattern for doing that is to use a prepared  statement with bind placeholders. 
(Yes, there's a time and a place for everything, including dynamically generated SQL.  But looking at what you are trying to achieve with your code, that time and place is never and nowhere.)