kyleldi Posted June 2, 2008 Share Posted June 2, 2008 Hi All, I'm doing something quite simple here, but for some reason I can't get it to work. My sql query (in php) needs to select data based on two requirements. $query_rs_store = sprintf("SELECT * FROM store WHERE category = "%s" AND active = "Yes" ORDER BY id ASC", GetSQLValueString($colname_rs_store, "text")); The problem is I keep getting this Parse Error: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in ere.php I've tried using ' instead of " for the specific categories, but it still doesn't work. %s is a url variable, while active is not. Does this make a difference? Link to comment https://forums.phpfreaks.com/topic/108355-solved-sql-query-question/ Share on other sites More sharing options...
trq Posted June 2, 2008 Share Posted June 2, 2008 $query_rs_store = sprintf("SELECT * FROM store WHERE category = '%s' AND active = 'Yes' ORDER BY id ASC", GetSQLValueString($colname_rs_store, "text")); Link to comment https://forums.phpfreaks.com/topic/108355-solved-sql-query-question/#findComment-555481 Share on other sites More sharing options...
kyleldi Posted June 2, 2008 Author Share Posted June 2, 2008 When I try that I get this error: 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 ''' AND active = 'Yes' ORDER BY id ASC' at line 1. Any ideas? Link to comment https://forums.phpfreaks.com/topic/108355-solved-sql-query-question/#findComment-555484 Share on other sites More sharing options...
trq Posted June 2, 2008 Share Posted June 2, 2008 Have you made sure $colname_rs_store is defined? Link to comment https://forums.phpfreaks.com/topic/108355-solved-sql-query-question/#findComment-555485 Share on other sites More sharing options...
kyleldi Posted June 2, 2008 Author Share Posted June 2, 2008 Yes, it is. If I only call out the requirement of %s (my url variable) the query works fine. It's only when I try to add another requirement that it won't work. It's weird because I can do one or the other, but not both. Link to comment https://forums.phpfreaks.com/topic/108355-solved-sql-query-question/#findComment-555487 Share on other sites More sharing options...
trq Posted June 2, 2008 Share Posted June 2, 2008 Can you echo $query_rs_store for us? Link to comment https://forums.phpfreaks.com/topic/108355-solved-sql-query-question/#findComment-555489 Share on other sites More sharing options...
kyleldi Posted June 2, 2008 Author Share Posted June 2, 2008 I re-wrote the URL Variable script and made it pull $category instead of %s (technically doing the exact same thing) and now it works. Thanks for all your help! Link to comment https://forums.phpfreaks.com/topic/108355-solved-sql-query-question/#findComment-555498 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.