-BRAIDZ- Posted August 30, 2015 Author Posted August 30, 2015 What I'm saying is that you're using mysql_real_escapestring() on numbers. Notice the "STRING" at the end of that function name. A number is NOT a string. Example: WHERE playerid = '" . mysql_real_escape_string($wj['playerid']) . "'"; , that looks like a number to me, you're using MRES() on it AND quoting it. It's a number. But, I don't know your system, you could be referencing a players name in the "playerid" field. I just don't know...I didn't make it. WHERE playerid = " . $wj['playerid']; Would be a better usage. Or, if you're unsure what the contents of $wj['playerid'] is going to be and you want to force it, then you'd use: WHERE playerid = " . intval($wj['playerid']); But, in reality, you should even be using the MySQL extension. Thanks, do I have to have the quotation mark in the bottom one? And yes it's referencing the playerid not the name, I will go through and change all these when I get back on the computer. Quote
-BRAIDZ- Posted August 30, 2015 Author Posted August 30, 2015 What I'm saying is that you're using mysql_real_escapestring() on numbers. Notice the "STRING" at the end of that function name. A number is NOT a string. Example: WHERE playerid = '" . mysql_real_escape_string($wj['playerid']) . "'"; , that looks like a number to me, you're using MRES() on it AND quoting it. It's a number. But, I don't know your system, you could be referencing a players name in the "playerid" field. I just don't know...I didn't make it. WHERE playerid = " . $wj['playerid']; Would be a better usage. Or, if you're unsure what the contents of $wj['playerid'] is going to be and you want to force it, then you'd use: WHERE playerid = " . intval($wj['playerid']); But, in reality, you should even be using the MySQL extension. Like this? $q_ry = "UPDATE memberstats SET my_labor = my_labor + " . ($wj['r_MANUALGAIN']) . " , my_intelligence = my_intelligence + " . ($wj['r_INTELGAIN']) . " , my_endurance = my_endurance + ". ($wj['r_ENDURGAIN']) . " WHERE playerid = " . ($wj['playerid']) . " "; mysql_query($q_ry) or die(mysql_error()); Quote
spikereloaded Posted August 30, 2015 Posted August 30, 2015 (edited) OK, in a case like this, where it's unclear where the error is coming from, I'd go back to the most primitive method of debugging possible. go line by line and add in echo 'test - passed'; exit; then save you're file, upload it and see if you get the error or you see 'test - passed'. see how far into your code you can get, before you start getting the error. When you get the error, you'll be able to tell which bit of code is giving you the issue. Like I said, it's primitive but it's a good way to get some clarity on which part of the code you're having issues with. Edited August 30, 2015 by spikereloaded Quote
AdamHull Posted August 30, 2015 Posted August 30, 2015 You only.need to wrap the things in your query if.your using a function like interval() or Mt_rand() and so on . The query you have posted will generate more errors Quote
-BRAIDZ- Posted August 30, 2015 Author Posted August 30, 2015 You only.need to wrap the things in your query if.your using a function like interval() or Mt_rand() and so on . The query you have posted will generate more errors So like this then? $q_ry = "UPDATE memberstats SET my_labor = my_labor + ($wj['r_MANUALGAIN']) , my_intelligence = my_intelligence + ($wj['r_INTELGAIN']) , my_endurance = my_endurance + ($wj['r_ENDURGAIN']) WHERE playerid = ($wj['playerid']) "; mysql_query($q_ry) or die(mysql_error()); Quote
AdamHull Posted August 30, 2015 Posted August 30, 2015 $q_ry = "UPDATE memberstats SET my_labor = my_labor + ".$wj['r_MANUALGAIN']." , my_intelligence = my_intelligence + ".$wj['r_INTELGAIN'].", my_endurance = my_endurance +".$wj['r_ENDURGAIN']." WHERE playerid = ".interval($wj['playerid']) "; mysql_query($q_ry) or die(mysql_error()); Notice how none of the variables has () around except where I declare interval Quote
-BRAIDZ- Posted August 30, 2015 Author Posted August 30, 2015 $q_ry = "UPDATE memberstats SET my_labor = my_labor + ".$wj['r_MANUALGAIN']." , my_intelligence = my_intelligence + ".$wj['r_INTELGAIN'].", my_endurance = my_endurance +".$wj['r_ENDURGAIN']." WHERE playerid = ".interval($wj['playerid']) "; mysql_query($q_ry) or die(mysql_error()); Notice how none of the variables has () around except where I declare interval Thanks mate, do I need to declare interval? Quote
AdamHull Posted August 30, 2015 Posted August 30, 2015 You don't have to, I put.it in to show.you when yo use () Quote
-BRAIDZ- Posted August 30, 2015 Author Posted August 30, 2015 You don't have to, I put.it in to show.you when yo use () Okay mate, thanks, I will fix it all up when I get back on the computer Quote
AdamHull Posted August 30, 2015 Posted August 30, 2015 I have tested this both on my local machine and my server, and both times this cron works perfect with no errors. Even when you do tidy this up, I think you will still have the same issue Quote
Coly010 Posted August 30, 2015 Posted August 30, 2015 I have tested this both on my local machine and my server, and both times this cron works perfect with no errors. Even when you do tidy this up, I think you will still have the same issue i think his issue could be coming from his DB structure : $q_ry = "UPDATE memberstats SET my_labor = my_labor + ".$wj['r_MANUALGAIN']." , my_intelligence = my_intelligence + ".$wj['r_INTELGAIN'].", my_endurance = my_endurance +".$wj['r_ENDURGAIN']." WHERE playerid = ".interval($wj['playerid']) "; mysql_query($q_ry) or die(mysql_error()); as his error is this: 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 '=* +* '200'************* WHERE playerid = '5'' at line 2 I'm going to throw it out there that there is a problem with one of the column names. :/ that's if that is the correct query that is throwing the error. as [MENTION=68644]spikereloaded[/MENTION] said, go through your file and add echo "test passed - NAME OF CRON <br />" , that way you will know which query is actually causing you a problem Quote
lucky3809 Posted August 30, 2015 Posted August 30, 2015 This is wrong.... $q_ry = "UPDATE memberstats SET my_labor = my_labor + ".$wj['r_MANUALGAIN']." , my_intelligence = my_intelligence + ".$wj['r_INTELGAIN'].", my_endurance = my_endurance +".$wj['r_ENDURGAIN']." WHERE playerid = ".interval($wj['playerid']) "; mysql_query($q_ry) or die(mysql_error()); As for if you look at the code and error the error is this part: WHERE playerid = ".interval($wj['playerid']) "; as for you did not add the right bracket closing it should be . than the double quote " at the end of the var you are using: WHERE playerid = ".interval($wj['playerid'])."; Quote
AdamHull Posted August 30, 2015 Posted August 30, 2015 This is wrong.... $q_ry = "UPDATE memberstats SET my_labor = my_labor + ".$wj['r_MANUALGAIN']." , my_intelligence = my_intelligence + ".$wj['r_INTELGAIN'].", my_endurance = my_endurance +".$wj['r_ENDURGAIN']." WHERE playerid = ".interval($wj['playerid']) "; mysql_query($q_ry) or die(mysql_error()); As for if you look at the code and error the error is this part: WHERE playerid = ".interval($wj['playerid']) "; as for you did not add the right bracket closing it should be . than the double quote " at the end of the var you are using: WHERE playerid = ".interval($wj['playerid'])."; thanks for pointing this out i did it quickly on my phone! LOL Quote
Coly010 Posted August 30, 2015 Posted August 30, 2015 This is wrong.... $q_ry = "UPDATE memberstats SET my_labor = my_labor + ".$wj['r_MANUALGAIN']." , my_intelligence = my_intelligence + ".$wj['r_INTELGAIN'].", my_endurance = my_endurance +".$wj['r_ENDURGAIN']." WHERE playerid = ".interval($wj['playerid']) "; mysql_query($q_ry) or die(mysql_error()); As for if you look at the code and error the error is this part: WHERE playerid = ".interval($wj['playerid']) "; as for you did not add the right bracket closing it should be . than the double quote " at the end of the var you are using: WHERE playerid = ".interval($wj['playerid'])."; That was another error added into the mix then, it's not the original error. Quote
lucky3809 Posted August 30, 2015 Posted August 30, 2015 Well you can find the problem by finding all the playerid= in the queries and go down them and add playerid='1',playerid='2',playerid= '3' and so on than run the cron and it will show you which query is giving the problem, by listing which number, that's how I always find my problem when I can't seem to know which query or echo statement it refers to. Quote
KyleMassacre Posted August 30, 2015 Posted August 30, 2015 For one 'interval()' I don't believe is a function, I believe he meant 'intval()' Quote
NonStopCoding Posted August 30, 2015 Posted August 30, 2015 For one 'interval()' I don't believe is a function, I believe he meant 'intval()' it kinda is but not like that lol but yea i think he meant to say intval http://php.net/manual/en/class.dateinterval.php Quote
KyleMassacre Posted August 30, 2015 Posted August 30, 2015 My original statement still stands ;) unless he has a function called interval like this: function interval($userid) { $date = new DateInterval($userid); return $date->somePropWhichOneIDontKnow; which would still not work because a players id probably isn't the best way to grab a date string Quote
IllegalPigeon Posted August 30, 2015 Posted August 30, 2015 The best way to do it, which I should have done originally, would be: WHERE playerid = " . (int) $wj['playerid']; Also, you don't need to keep ending the query like you are: WHERE playerid = " . intval($wj['playerid']) . ""; There's no point. You can just end it with : " . $blah; - 'tis neater. Quote
NonStopCoding Posted August 31, 2015 Posted August 31, 2015 The best way to do it, which I should have done originally, would be: WHERE playerid = " . (int) $wj['playerid']; Also, you don't need to keep ending the query like you are: WHERE playerid = " . intval($wj['playerid']) . ""; There's no point. You can just end it with : " . $blah; - 'tis neater. i prefer the {$var['something']} myself Quote
-BRAIDZ- Posted August 31, 2015 Author Posted August 31, 2015 Here is the code now, I have done a Syntax check online, and I'm getting these and that's all, so it should be fine, I worked out why it was updating twice, thank you for the help everyone :) From : PHP Code Checker. Warning: There are 6 functions in your code that have been deprecated in the current version of PHP : mysql_connect() mysql_error() mysql_fetch_array() mysql_num_rows() mysql_query() mysql_select_db() Code: <?php ini_set('error_reporting', E_ALL); $dbhost = "localhost"; $dbuser = "usernamehere"; $dbpass = "passwordhere"; $dbbase = "dbnamehere"; $cron_are_so_cool = "trick_is_da_bomb"; $db = "mysql_tut"; $con = mysql_connect($dbhost, $dbuser, $dbpass); mysql_select_db($dbbase); if ($_GET['code_to_run'] < 0) { die("<center><font color=red>Fatal error!</font> <br/><blink>IP logged as {$_SERVER['REMOTE_ADDR']}</blink></center>"); } else { /*----------------------------------Start cron minutes--------------------------*/ mysql_query("UPDATE members SET my_mailban = my_mailban - 1 WHERE my_mailban >= 1 ") or die(mysql_error()); mysql_query("UPDATE members SET my_forumban = my_forumban - 1 WHERE my_forumban >= 1 ") or die(mysql_error()); mysql_query("UPDATE none_agressive SET na_days = na_days - 1 WHERE na_days >= 1 ") or die(mysql_error()); mysql_query("DELETE FROM none_agressive WHERE na_days <= 0") or die(mysql_error()); mysql_query("UPDATE city_shop_dogs SET csd_daysold = csd_daysold + 1") or die(mysql_error()); mysql_query("UPDATE members_dogs SET md_daysold = md_daysold + 1") or die(mysql_error()); $newones = rand(1, 15); $morf = array( 1 => 'male', 2 => 'female' ); for ($i = 1; $i <= $newones; $i++) { $q_ry = array(); $q_ry = "INSERT INTO city_shop_dogs VALUES('NULL', '" . rand(1, 8) . "', '" . $morf[rand(1, 2)] . "', 0)"; mysql_query($q_ry) or die(mysql_error()); } $withjob = array(); $wj = array(); $q_ry = array(); $q_ry = "SELECT me.my_job,me.my_job_rank,me.playerid, sjr.*,m.my_level FROM members_extra me INNER JOIN system_job_ranks AS sjr ON me.my_job_rank = sjr.r_ID INNER JOIN members AS m ON me.playerid = m.playerid WHERE me.my_job > 0"; $withjob = array(); $withjob = mysql_query($q_ry) or die(mysql_error()); $wj = array(); while ($wj = mysql_fetch_array($withjob)) { $q_ry = array(); $q_ry = "UPDATE memberstats SET my_labor = my_labor + " . $wj['r_MANUALGAIN'] . " , my_intelligence = my_intelligence + " . $wj['r_INTELGAIN'] . " , my_endurance = my_endurance + " . $wj['r_ENDURGAIN'] . " WHERE playerid = " . $wj['playerid'] . " "; mysql_query($q_ry) or die(mysql_error()); $job = array( 1 => 'armypoints', 2 => 'grocpoints', 3 => 'casipoints', 4 => 'medipoints', 5 => 'educpoints', 6 => 'lawpoints' ); $wj['r_POINTS'] *= $wj['my_level']; $q_ry = array(); $q_ry = "UPDATE members_extra SET " . $job[$wj['my_job']] . " = " . $job[$wj['my_job']] . " + " . $wj['r_POINTS'] . " WHERE playerid = " . $wj['playerid'] . " "; mysql_query($q_ry) or die(mysql_error()); $q_ry = array(); $q_ry = "UPDATE members SET wallet = wallet + " . $wj['r_WAGES'] . " WHERE playerid = " . $wj['playerid'] . " "; mysql_query($q_ry) or die(mysql_error()); } function remove_staff($id) { $q_ry = array(); $q_ry = "SELECT p_maids,p_butler,p_guard,p_doctor,p_pilot FROM members_properties WHERE p_id = $id "; $uptime = array(); $uptime = mysql_query($q_ry); $ut = array(); $ut = mysql_fetch_array($uptime); $happloss = 0; if ($ut['p_maids'] != 0) { $q_ry = array(); $q_ry = "SELECT ps_name FROM property_staff WHERE ps_id = " . $ut['p_maids'] . " "; $wichmaids = array(); $wichmaids = mysql_query($q_ry); $wms = mysql_fetch_array($wichmaids); $wms = array(); if ($wms['ps_name'] == '5x Maid Service') { $happloss += 100; } if ($wms['ps_name'] == '3x Maid Service') { $happloss += 85; } if ($wms['ps_name'] == '2x Maid Service') { $happloss += 75; } if ($wms['ps_name'] == 'Maid Service') { $happloss += 50; } } if ($ut['p_butler'] != 0) { $q_ry = array(); $q_ry = "SELECT ps_name FROM property_staff WHERE ps_id = " . $ut['p_butler'] . " "; $wichbutlers = array(); $wichbutlers = mysql_query($q_ry); $wmb = mysql_fetch_array($wichbutlers); $wmb = array(); if ($wmb['ps_name'] == '3x Butler Service') { $happloss += 125; } if ($wmb['ps_name'] == '2x Butler Service') { $happloss += 100; } if ($wmb['ps_name'] == 'Butler Service') { $happloss += 75; } } if ($ut['p_guard'] != 0) { $q_ry = array(); $q_ry = "SELECT ps_name FROM property_staff WHERE ps_id= " . $ut['p_guard'] . " "; $wichguards = array(); $wichguards = mysql_query($q_ry); $wmg = mysql_fetch_array($wichguards); $wmg = array(); if ($wmg['ps_name'] == '10x Guard Service') { $happloss += 500; } if ($wmg['ps_name'] == '5x Guard Service') { $happloss += 300; } if ($wmg['ps_name'] == '3x Guard Service') { $happloss += 200; } if ($wmg['ps_name'] == '2x Guard Service') { $happloss += 150; } if ($wmg['ps_name'] == 'Guard Service') { $happloss += 100; } } if ($ut['p_doctor'] != 0) { $happloss += 25; } if ($ut['p_pilot'] != 0) { $happloss += 50; } $q_ry = array(); $q_ry = "UPDATE members_properties SET p_happy = p_happy - $happloss ', p_maids = 0, p_butler = 0, p_guard = 0, p_doctor = 0, p_pilot = 0, p_priceofstaff = 0, p_daysofstaff = 0 WHERE p_id = $id "; mysql_query($q_ry); $q_ry = array(); $q_ry = "UPDATE members SET my_maxhappy = my_maxhappy - $happloss ' WHERE my_property = $id "; mysql_query($q_ry); } function in_event($player, $text) { $player = abs(intval($player)); $text = stripslashes($text); mysql_query("INSERT INTO member_events VALUES('NULL', $player , $text , unix_timestamp(), 0)") or die(mysql_error()); mysql_query("UPDATE city_statistic SET cs_value = cs_value + 1 WHERE cs_id = 1") or die(mysql_error()); } function stock_credit($id, $credit) { $q_ry = array(); $q_ry = "UPDATE stock_market SET s_profit = s_profit + $credit , s_losses = s_losses - $credit WHERE s_id = $id "; mysql_query($q_ry); $q_ry = array(); $q_ry = "UPDATE stock_market SET s_profit = 0 WHERE s_profit <= 0"; mysql_query($q_ry); $q_ry = array(); $q_ry = "UPDATE stock_market SET s_losses = 0 WHERE s_losses <= 0"; mysql_query($q_ry); } mysql_query("UPDATE members_properties SET p_ltime = p_ltime - 1 WHERE p_leasedto > 0"); mysql_query("UPDATE members_properties SET p_daysofstaff = p_daysofstaff + 1 WHERE p_priceofstaff > 0"); //Check for expired rentings $q_ry = array(); $q_ry = "SELECT * FROM members_properties mp LEFT JOIN properties h ON mp.p_property = h.house_id WHERE mp.p_leasedto != 0 AND mp.p_ltime = 0"; $uptime = array(); $uptime = mysql_query($q_ry); while ($ut = mysql_fetch_array($uptime)) { $message1 = "The rent period for your " . htmlentities($ut['house_name']) . " has now finished, The " . htmlentities($ut['house_name']) . " has been returned to you."; $q_ry = array(); $q_ry = "INSERT INTO member_events VALUES ('NULL', " . $ut['p_playerid'] . ", $message1 , unix_timestamp(), 0)"; mysql_query($q_ry); $message2 = "The rent period for the " . htmlentities($ut['house_name']) . " has now finished, The " . htmlentities($ut['house_name']) . " has been returned to its owner."; $q_ry = array(); $q_ry = "INSERT INTO member_events VALUES ('NULL', " . $ut['p_leasedto'] . " , $message2 , unix_timestamp(), 0)"; mysql_query($q_ry); $q_ry = array(); $q_ry = "SELECT playerid FROM members WHERE my_property = " . $ut['p_id'] . " "; $mys = array(); $mys = mysql_query($q_ry); if (mysql_num_rows($mys)) { $my = array(); while ($my = mysql_fetch_array($mys)) { $q_ry = array(); $q_ry = "SELECT p_id FROM members_properties WHERE p_playerid = " . $my['playerid'] . " AND p_property = 1"; $myshack = array(); $myshack = mysql_query($q_ry); $msh = array(); $msh = mysql_fetch_array($myshack); $q_ry = array(); $q_ry = "UPDATE members SET my_property = " . $msh['p_id'] . " my_happy = 100 my_maxhappy = 100 WHERE playerid = " . $my['playerid'] . " "; mysql_query($q_ry); } } remove_staff($ut['p_id']); $q_ry = array(); $q_ry = "UPDATE members_properties SET p_leasedto = 0, p_ltime = 0 WHERE p_id = " . $ut['p_id'] . " "; mysql_query($q_ry); } //Check for expired rentings //Charge daily upkeep $q_ry = array(); $q_ry = "SELECT * FROM members_properties mp LEFT JOIN properties h ON mp.p_property = h.house_id WHERE mp.p_property != 1 "; $upprops = array(); $upprops = mysql_query($q_ry); $up = array(); while ($up = mysql_fetch_array($upprops)) { $total = ($up['p_priceofstaff'] + $up['house_tax']); if ($up['p_leasedto'] != 0) { //Check money of tenant $q_ry = array(); $q_ry = "SELECT playerid FROM members WHERE playerid = " . $up['p_leasedto'] . " AND wallet <= - $total "; $myc = array(); $myc = mysql_query($q_ry); if ($up['p_priceofstaff']) { stock_credit(5, 1); if (mysql_num_rows($myc)) { remove_staff($up['p_id']); $message3 = "You did not have enough to pay your staff for today, They have packed up and left!"; in_event($up['p_leasedto'], $message3); } } $q_ry = array(); $q_ry = "UPDATE members SET wallet = wallet - $total WHERE playerid = " . $up['p_leasedto'] . " "; } else { //Check money of member $q_ry = array(); $q_ry = "SELECT wallet FROM members WHERE playerid = " . $up['p_playerid'] . " AND wallet <= - $total "; $myc = array(); $myc = mysql_query($q_ry); if ($up['p_priceofstaff']) { stock_credit(5, 1); if (mysql_num_rows($myc)) { remove_staff($up['p_id']); $message3 = "You did not have enough to pay your staff for today, They have packed up and left!"; in_event($up['p_playerid'], $message3); } } $q_ry = array(); $q_ry = "UPDATE members SET wallet = wallet - $total WHERE playerid = " . $up['p_playerid'] . " "; } mysql_query($q_ry); } //Charge daily upkeep /*-----------------------------------End cron minutes---------------------------*/ function award_check($user, $number, $award) { $q_ry = array(); $q_ry = "SELECT ma_id,ma_tier FROM members_awards WHERE ma_playerid = $user AND ma_award = $award "; $got_award = array(); $got_award = mysql_query($q_ry) or die(mysql_error()); if (mysql_num_rows($got_award)) { $ga = array(); $ga = mysql_fetch_array($got_award); if ($ga['ma_tier'] >= $number) { //Got it } else { $q_ry = array(); $q_ry = "UPDATE members_awards SET ma_tier = $number , ma_viewed = 0, ma_time = unix_timestamp() WHERE ma_id = " . $ga['ma_id'] . " "; mysql_query($q_ry) or die(mysql_error()); $q_ry = array(); $q_ry = "UPDATE members SET my_merits = my_merits + 1 WHERE playerid = $user "; mysql_query($q_ry) or die(mysql_error()); } } else { $q_ry = array(); $q_ry = "INSERT INTO members_awards VALUES ('NULL', $award , $number ', $user , 0, unix_timestamp())"; mysql_query($q_ry) or die(mysql_error()); $q_ry = array(); $q_ry = "UPDATE members SET my_merits = my_merits + 1 WHERE playerid = $user "; mysql_query($q_ry) or die(mysql_error()); } } $q_ry = array(); $q_ry = "SELECT * FROM award_checks ac LEFT JOIN awards a ON ac.ac_award_id = a.a_id"; $award_checks = array(); $award_checks = mysql_query($q_ry) or die(mysql_error()); while ($aw = mysql_fetch_array($award_checks)) { $q_ry = array(); $q_ry = "SELECT " . $aw['ac_identify'] . "," . $aw['ac_what'] . " FROM " . $aw['ac_table'] . " WHERE " . $aw['ac_what'] . " >= '" . $aw['ac_amount'] . "'"; $thisaward = array(); $thisaward = mysql_query($q_ry) or die(mysql_error()); if (mysql_num_rows($thisaward)) { while ($ta = mysql_fetch_array($thisaward)) { award_check($ta[$aw['ac_identify']], $aw['ac_number'], $aw['ac_award_id']); } } } mysql_query("UPDATE members SET my_dondays = my_dondays - 1 WHERE my_dondays > 0"); mysql_query("UPDATE members SET my_maxenergy = 100 WHERE my_dondays <= 0"); mysql_query("UPDATE members SET my_partner_days = my_partner_days + 1 WHERE my_partner > 0"); mysql_query("UPDATE members SET brew = 0"); mysql_query("UPDATE members_extra SET my_daysold = my_daysold + 1"); mysql_query("UPDATE members_extra SET my_ctokens = my_ctokens_daily,my_cstreak = 0"); mysql_query("UPDATE members_extra SET energy_refill = 0"); $q_ry = array(); $q_ry = "SELECT playerid FROM members WHERE my_faction > 0"; $facdays = array(); $facdays = mysql_query($q_ry) or die(mysql_error()); $fd = array(); $q_ry = array(); while ($fd = mysql_fetch_array($facdays)) { $q_ry = "UPDATE members_extra SET my_faction_days = my_faction_days + 1 WHERE playerid = " . $fd['playerid'] . " "; mysql_query($q_ry) or die(mysql_error()); } $q_ry = array(); $q_ry = "DELETE FROM votes_count WHERE vc_site = 'apex' || vc_site = 'ultra'"; mysql_query($q_ry) or die(mysql_error()); $q_ry = array(); $q_ry = "SELECT * FROM stock_holdings WHERE sh_saletime > 0 AND (sh_saletime+1036800) <= '" . (time()) . "' AND sh_playerid != '3'"; $validstocks = array(); $validstocks = mysql_query($q_ry) or die(mysql_error()); $v = array(); while ($v = mysql_fetch_array($validstocks)) { $qty = $v['sh_qty']; $creditamnt = $v['sh_nowprice'] * $qty; $newprice = $v['sh_nowprice']; $q_ry = array(); $q_ry = "UPDATE members SET wallet = wallet + $creditamnt ' WHERE playerid = " . $v['sh_playerid'] . " "; mysql_query($q_ry); $message = "Someone bought " . $qty . " of your stocks for \$" . number_format($creditamnt) . "!"; in_event($v['sh_playerid'], $message); $q_ry = array(); $q_ry = "UPDATE stock_holdings SET sh_playerid = 1, sh_payed = ($newprice) , sh_time = '" . time() . "', sh_sale = 1, sh_saletime = '" . time() . "' WHERE sh_id = " . $v['sh_id'] . " "; mysql_query($q_ry) or die(mysql_error()); } $yearago = (time() - 32140800); $sixmonths = $yearago / 2; $threemonths = $sixmonths / 2; $onemonth = $sixmonths / 6; $twoweeks = $onemonth / 2; $q_ry = array(); $q_ry = "DELETE FROM member_mail WHERE mm_time <= $onemonth "; mysql_query($q_ry) or die(mysql_error()); $q_ry = array(); $q_ry = "DELETE FROM member_events WHERE e_time <= $onemonth "; mysql_query($q_ry) or die(mysql_error()); $q_ry = array(); $q_ry = "DELETE FROM attack_logs WHERE time <= $onemonth "; mysql_query($q_ry) or die(mysql_error()); $q_ry = array(); $q_ry = "DELETE FROM faction_events WHERE fe_time <= $onemonth "; mysql_query($q_ry) or die(mysql_error()); $q_ry = array(); $q_ry = "DELETE FROM stock_history WHERE h_time <= $sixmonths "; mysql_query($q_ry) or die(mysql_error()); } ?> Quote
IllegalPigeon Posted August 31, 2015 Posted August 31, 2015 i prefer the {$var['something']} myself The problem with that, braces don't adhere to PSR-2 standards. Also, casting to an (int) is a lot faster. Plus, braces are ugly. Quote
-BRAIDZ- Posted August 31, 2015 Author Posted August 31, 2015 The problem with that, braces don't adhere to PSR-2 standards. Also, casting to an (int) is a lot faster. Plus, braces are ugly. Nothing I need to change about the updated code? I'd like to thank everyone here for the help, I am slowly learning, and learning to code has been a great experience, it's something I've always wanted to do, I've just never had the motivation. But now I've got the motivation, I'm going to look into doing a course in Web development, or just do one of the short courses that are free online, one day I aim to be able to build a custom engine. This may take me years, and I will overcome a lot of obstacles and need some help, but I will get there. I think it's easier to learn from someone else of other work rather than via doing a course, because I've read heaps of stuff on the net, and it's like wait hold on, you lost me at the first sentence, they don't get straight to the point, they like to blabber crap first, then it's like hey wait up, I've got to go back now haha. All you guys here are awesome, I have come across so many different ways people code though. :) Quote
NonStopCoding Posted August 31, 2015 Posted August 31, 2015 (edited) The problem with that, braces don't adhere to PSR-2 standards. Also, casting to an (int) is a lot faster. Plus, braces are ugly. haha i think they look alright :P i guess it comes down to what you prefer :D Edited August 31, 2015 by NonStopCoding Quote
IllegalPigeon Posted August 31, 2015 Posted August 31, 2015 haha i think they look alright :P i guess it comes down to what you prefer :D And PSR standards...which should be adhered to. Quote
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.