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 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? 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. 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(); 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. 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! 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
Archived
This topic is now archived and is closed to further replies.