Marcel1993 Posted December 22, 2010 Share Posted December 22, 2010 Hey, $todo_upgrades_sql = "SELECT * FROM todo_upgrades WHERE time_completion >= $time"; $todo_upgrades_res = mysql_query($todo_upgrades_sql) or die (mysql_error()); results: 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 '' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/222348-dont-know-why-a-sql-query-doesnt-work/ Share on other sites More sharing options...
Pikachu2000 Posted December 22, 2010 Share Posted December 22, 2010 Are you sure $time has a value? Quote Link to comment https://forums.phpfreaks.com/topic/222348-dont-know-why-a-sql-query-doesnt-work/#findComment-1150136 Share on other sites More sharing options...
shlumph Posted December 22, 2010 Share Posted December 22, 2010 It'd help to show the declaration of $time, as it's also part of the query. If you're using datetime, or date, you'll have to surround $time with quotes. Quote Link to comment https://forums.phpfreaks.com/topic/222348-dont-know-why-a-sql-query-doesnt-work/#findComment-1150137 Share on other sites More sharing options...
Marcel1993 Posted December 22, 2010 Author Share Posted December 22, 2010 Hey, $time has been defined before as $time = time(); Quote Link to comment https://forums.phpfreaks.com/topic/222348-dont-know-why-a-sql-query-doesnt-work/#findComment-1150492 Share on other sites More sharing options...
PFMaBiSmAd Posted December 22, 2010 Share Posted December 22, 2010 You need to echo the query so that you can see what it actually is, but the error is typical of the $time variable not having a value when the query was executed. Quote Link to comment https://forums.phpfreaks.com/topic/222348-dont-know-why-a-sql-query-doesnt-work/#findComment-1150494 Share on other sites More sharing options...
Marcel1993 Posted December 22, 2010 Author Share Posted December 22, 2010 Hey, thanks. As you said above the variable was without content. It was because the query was surrounded by a function - so I made a condition of the var filled with the time-content. Thank you very much! Quote Link to comment https://forums.phpfreaks.com/topic/222348-dont-know-why-a-sql-query-doesnt-work/#findComment-1150506 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.