twohoursonelife / OneLifeWeb

Web services used by the game server and client of OneLife, now seperate from the monolith repository.
https://twohoursonelife.com
Other
3 stars 2 forks source link

MySQL Fatal Error #2

Open connorhsm opened 2 years ago

connorhsm commented 2 years ago

Fitness Server causing fatal error:

Fatal error: Database query failed:
SELECT life_id, life_player_id, name, age, display_id, relation_name, offspring.score_change, offspring.death_time, TIMESTAMPDIFF( SECOND, offspring.death_time, CURRENT_TIMESTAMP ) as died_sec_ago FROM fitnessServer_offspring AS offspring INNER JOIN fitnessServer_lives AS lives ON offspring.life_id = lives.id WHERE offspring.player_id = AND offspring.death_time > DATE_SUB( NOW(), INTERVAL 168 HOUR ) ORDER BY offspring.death_time DESC LIMIT 20;

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 offspring.death_time > DATE_SUB( NOW(), INTERVAL 168 HOUR ) ORDER BY offspri' at line 1

Suspected code/query causing issues: https://github.com/twohoursonelife/OneLifeWeb/blob/567951a2eebca0e130e8f008b0f90ffaad36ec89/web/public/fitnessServer/server.php#L2132-L2141

connorhsm commented 2 years ago

@risvh I'm having some trouble figuring what causes this error. I believe the query I've found in server.php is executed when displaying the Genes page on the client, but can't reproduce the error myself. I also can't spot any immediate errors in the query, apart from some formatting differences in the PHP.

Are you able to offer any help here?

connorhsm commented 2 years ago

Although ...WHERE offspring.player_id = ?? AND offspring.death_time >... It looks as if there might be a missing ID in the query, where I have added the ??.

risvh commented 2 years ago

Yes there should be an ID there "WHERE offspring.player_id = $id ". and further above $id = fs_mysqli_result( $result, 0, "player_id" ); which in turn comes from the offspring table https://github.com/twohoursonelife/OneLifeWeb/blob/567951a2eebca0e130e8f008b0f90ffaad36ec89/web/public/fitnessServer/server.php#L2116-L2128