MasterACE14 Posted January 20, 2008 Share Posted January 20, 2008 good afternoon, I have a cron job which runs hourly and does a few MySQL queries, I have a mix of normal queries eg. mysql_query("""); and ADOdb queries eg. $db->execute(""); The part of the code that isn't working is the part that relates to "Jousting". here it is(relevent code only): <?php // workout which knight won the joust, and workout joust winners and give them there gold $joust_rand = rand(1,2); // declare winner if($joust_rand == 1) { $winner = "henry"; } elseif($joust_rand == 2) { $winner = "richard"; } // select all fields from joust $joust_query = mysql_query("SELECT * FROM `jousting` WHERE `id`=1 LIMIT 1"); // select all winners from players $joust_winners = mysql_query("SELECT * FROM `players` WHERE `bet_knight`='$winner'"); // make available all fields in jousting while($rows = mysql_fetch_array($joust_query)) { // make available all fields in players(who were winners) while($winner_is = mysql_fetch_array($joust_winners)) { // if the winner was henry, do all the queries and gold dividing if($winner == "henry") { $none = "none"; // winner full name $winner_name = "Sir, Henry"; $loser_name = "Sir, Richard"; // divide all gold bet on henry between winners $divide_gold = $winner_is['bank'] + ($rows['bets_knight1'] / mysql_num_rows($joust_winners)); $query_jousta = $db->execute("update `jousting` set `knight1_wins`=`knight1_wins`+1, `winner`=? WHERE `id`=1 LIMIT 1", array($winner_name)); $query_joustb = $db->execute("update `players` set `bank`=?, `bet_gold`=0, `bet_knight`=? WHERE `id`=1 LIMIT 1", array($divide_gold,$none)); $queryc = $db->execute("update `jousting` set `bets_knight1`=0, `bets_knight2`=0, `winner`=?, `loser=? WHERE id=1", array($winner_name,$loser_name)); } // if the winner was richard, do all the queries and gold dividing elseif($winner == "richard") { $none = "none"; // winner full name $winner_name = "Sir, Richard"; $loser_name = "Sir, Henry"; // divide all gold bet on richard between winners $divide_gold = $winner_is['bank'] + ($rows['bets_knight2'] / mysql_num_rows($joust_winners)); $query_jousta = $db->execute("update `jousting` set `knight2_wins`=`knight2_wins`+1, `winner`=? WHERE `id`=1 LIMIT 1", array($winner_name)); $query_joustb = $db->execute("update `players` set `bank`=?, `bet_gold`=0, `bet_knight`=? WHERE `id`=1 LIMIT 1", array($divide_gold,$none)); $queryc = $db->execute("update `jousting` set `bets_knight1`=0, `bets_knight2`=0, `winner`=?, `loser=? WHERE id=1", array($winner_name,$loser_name)); } } } // end of both while loops ?> the queries that arent working are the ones that: update the gold the player has bet(`bet_gold` field in `players` table) update who lost the joust(`loser` field in `jousting` table) update the wins for the winning knight(`knight1_wins` or `knight2_wins` fields in `jousting` table) the rest seems to be working fine, i think... may of missed something :-\ I believe the problem is the way I have concocted variables into the queries. whether I do it like " . $var . " or ' . $var . ' or $var or '$var' I'm just not sure. note: I dont receive any parse errors or any errors of any kind. Thanks in advance Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/86861-mysql-insert-not-executing-some-queries-suspected-concoct-problem/ Share on other sites More sharing options...
trq Posted January 20, 2008 Share Posted January 20, 2008 Why don't you actually check the queries succeed or not before trying to run another? Its the most basic part of executing a query that alot of newcomers fail to do. Quote Link to comment https://forums.phpfreaks.com/topic/86861-mysql-insert-not-executing-some-queries-suspected-concoct-problem/#findComment-444008 Share on other sites More sharing options...
MasterACE14 Posted January 20, 2008 Author Share Posted January 20, 2008 I try adding or die('Query:<br />' . $sql . '<br /><br />Error:<br />' . mysql_error()); but I still dont get anything displayed on the page if there is a problem :-\ Quote Link to comment https://forums.phpfreaks.com/topic/86861-mysql-insert-not-executing-some-queries-suspected-concoct-problem/#findComment-444020 Share on other sites More sharing options...
trq Posted January 20, 2008 Share Posted January 20, 2008 but I still dont get anything displayed on the page if there is a problem Because your not using mysql. Quote Link to comment https://forums.phpfreaks.com/topic/86861-mysql-insert-not-executing-some-queries-suspected-concoct-problem/#findComment-444103 Share on other sites More sharing options...
MasterACE14 Posted January 20, 2008 Author Share Posted January 20, 2008 I am... Quote Link to comment https://forums.phpfreaks.com/topic/86861-mysql-insert-not-executing-some-queries-suspected-concoct-problem/#findComment-444237 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.