45 ACP Posted July 10, 2010 Share Posted July 10, 2010 Hi guys, For some reason, mysql_query cannot process this query: UPDATE Roster SET InjuryTime='0', Morale='0' WHERE PlayerID='1'; UPDATE Roster SET InjuryTime='0', Morale='-6' WHERE PlayerID='2'; UPDATE Roster SET InjuryTime='0', Morale='8' WHERE PlayerID='3' Oddly enough though, I can login directly to my MySQL server and submit the query, and it works. Any help? Thanks. -45 ACP Link to comment https://forums.phpfreaks.com/topic/207350-mysql-query-error/ Share on other sites More sharing options...
dylpotato Posted July 10, 2010 Share Posted July 10, 2010 UPDATE Roster SET InjuryTime='0', Morale='0' WHERE PlayerID='1'; UPDATE Roster SET InjuryTime='0', Morale='-6' WHERE PlayerID='2'; UPDATE Roster SET InjuryTime='0', Morale='8' WHERE PlayerID='3' Are you passing all three SQL statements as an argument to the mysql_query function? I'm not sure you can do that, I think you need to execute each one with a separate mysql_query function. It would help if you posted the rest of your code, there may be a simple typo. Link to comment https://forums.phpfreaks.com/topic/207350-mysql-query-error/#findComment-1084055 Share on other sites More sharing options...
kenrbnsn Posted July 10, 2010 Share Posted July 10, 2010 I do not believe you can execute multiple queries in one mysql_query() call. You would need to execute each query separately. Ken Link to comment https://forums.phpfreaks.com/topic/207350-mysql-query-error/#findComment-1084056 Share on other sites More sharing options...
Mchl Posted July 10, 2010 Share Posted July 10, 2010 that's because mysql_query can only process one query at a time, and you're feeding it with three queries. I hate you Ken Link to comment https://forums.phpfreaks.com/topic/207350-mysql-query-error/#findComment-1084057 Share on other sites More sharing options...
kenrbnsn Posted July 10, 2010 Share Posted July 10, 2010 Mchl: GMTA Link to comment https://forums.phpfreaks.com/topic/207350-mysql-query-error/#findComment-1084062 Share on other sites More sharing options...
45 ACP Posted July 10, 2010 Author Share Posted July 10, 2010 I guess the answer for me is that mysql_query can only pass one query at a time. So I also guess my server can somehow separate these queries automatically? Anyways, second question: can I and HOW can I re-structure my query into something mysql_query can handle? If somebody could answer this it would be wonderful. These three queries are actually a snippet of the 3500 queries I need to pass, haha. I HAVE done it before with a simple for loop, but I'm trying to optimize my code a bit... -45 ACP Link to comment https://forums.phpfreaks.com/topic/207350-mysql-query-error/#findComment-1084245 Share on other sites More sharing options...
ChemicalBliss Posted July 11, 2010 Share Posted July 11, 2010 Since PHP is limited to a single query per mysql_query() call (to generate a Resource ID for each query), you should look at why you need to pass that many updates at once. Looks to me like you could optimize the code that deals with morale and injurytime in the frontend. Why are you modifying those fields for multiple players? -cb- Link to comment https://forums.phpfreaks.com/topic/207350-mysql-query-error/#findComment-1084258 Share on other sites More sharing options...
45 ACP Posted July 11, 2010 Author Share Posted July 11, 2010 The possibility of modifying those two fields frontend has been explored, but is not possible for other technical reasons (server bandwidth issues... yes, when you're passing 3500 queries, you tend to blow up your memory limit, lol), although thanks for the suggestion. Well then, since this was not (as I thought) a syntax error, I guess I'll just have to find another way. Thanks for your quick and helpful answers everybody. Link to comment https://forums.phpfreaks.com/topic/207350-mysql-query-error/#findComment-1084260 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.