Jump to content

MySQL Query error


45 ACP

Recommended Posts

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

 

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.