Undeaded Posted November 21, 2008 Report Share Posted November 21, 2008 (edited) Sedeju daudz stundas un neka neizdodas man uzrakstit kodu... <? function do_money() { if ((isset($_SESSION['pass'])) && (isset($_SESSION['user']))); { require("config.php"); $login = stripslashes($_SESSION['user']); $fromname = stripslashes($_POST['from_character_money']); $toname = stripslashes($_POST['to_character_money']); $sql_online_check = mssql_query("SELECT Name,Money from Charecter where Name='$fromname'"); $fromrow = mssql_fetch_row($sql_online_check); $sql_online_check2 = mssql_query("SELECT Name,Money from Charecter where Name='$toname'"); $torow = mssql_fetch_row($sql_online_check2); $from_money_check=$fromrow[1]; $to_money_check=$torow[1]; if (empty($fromname) || empty($toname)) { echo "izvelaties speletajus!"; } elseif ($from_money_check < 1999999999){ echo "$fromname pietruk naudas!"; } elseif ($to_money_check > 100000000){ echo "$toname parak daudz naudas lai parmest vel 2000000000 naudas"; } else { $msquery = " UPDATE dbo.Character SET Money = Money-2000000000 WHERE Name='$fromname' UPDATE dbo.Character SET Money = Money+2000000000 WHERE Name ='$toname' "; $msresults= mssql_query($msquery); echo "Viss ok! 2000000000 naudas parmesti no $fromname uz $toname"; } } } ?> ka es tikaj netaisiju... bet visu laiku rad so kljudu elseif ($from_money_check < 1999999999){ echo "$fromname pietruk naudas!"; } rakstiju gad ta: elseif ($from_money_check<1999999999){ echo "$fromname pietruk naudas!"; } gan ta: elseif ($from_money_check<'1999999999'){ echo "$fromname pietruk naudas!"; } gan ta: elseif ($fromrow[1]<'1999999999'){ echo "$fromname pietruk naudas!"; } gan ta: elseif ($fromrow['1']<'1999999999'){ echo "$fromname pietruk naudas!"; } gan ta: elseif ($fromrow[1] < 1999999999){ echo "$fromname pietruk naudas!"; } visu laiku rada kljudu, bet nauda ir! viss oki ka var uzrakstit laj kods skatijas cik naudas ir speletajem? Edited November 21, 2008 by Undeaded Link to comment Share on other sites More sharing options...
bubu Posted November 21, 2008 Report Share Posted November 21, 2008 mjā.. mūsdienu skripteri - nemāk pareizi pielietot datu tipus. Nevajag randomā miksēt integerus un stringus. Labums no tā nekāds. Kodu arī derētu pareizāk identēt, citādi grūti lasās. Bet par tēmu - kā tu zini, ka "nauda ir! viss oki"? Izvadi lūdzu naudu uz ekrāna un pasaki mums cik tur rāda. echo $from_money_check; Link to comment Share on other sites More sharing options...
Undeaded Posted November 21, 2008 Author Report Share Posted November 21, 2008 Lūdzu nevajag taisīt bezjēdzīgas QUOTEs ja rakstit $from_money_check; tad viņš neko nerad databaze ir nauda 2 milliardi, tad sanak ka te ir kļuda??? $sql_online_check = mssql_query("SELECT Name,Money from Charecter where Name='$fromname'"); $fromrow = mssql_fetch_row($sql_online_check); Link to comment Share on other sites More sharing options...
bubu Posted November 21, 2008 Report Share Posted November 21, 2008 Ja neko nerāda uz to echo, tad tas $from_money_check ir nepareizs. Parādi, ko rāda uz: print_r($fromrow); Link to comment Share on other sites More sharing options...
Val Posted November 21, 2008 Report Share Posted November 21, 2008 Tev tiešām ir mssql? Link to comment Share on other sites More sharing options...
Undeaded Posted November 22, 2008 Author Report Share Posted November 22, 2008 ja ir... es neesmu jau tik stulbs... Link to comment Share on other sites More sharing options...
Val Posted November 22, 2008 Report Share Posted November 22, 2008 pa rindiņai ej cauri un izdrukā starprezultātus. tad arī redzēsi, kur viss nogāžas. Link to comment Share on other sites More sharing options...
NoSound Posted November 23, 2008 Report Share Posted November 23, 2008 (edited) 1. Neiesaku datubāzē glabāt tādus ciparus ! Tā vietā var money fieldā glabāt 200 un brīdī, kad tiek veikta datu sūknēšana no db - pareizināt to ar 100000 ( tikai piemērs ). 2. Tas viss ir baigi forši, bet - es neredzu nevienu include, kas norādītu uz mysql konfirgurāciju .. Kam tad tas php fails vienojas klāt ? Kalkulatoram .. ? Apdomā šos abus punktus un dod ziņu vai kaut kas ir mainījies :) Edited November 23, 2008 by NoSound Link to comment Share on other sites More sharing options...
bubu Posted November 23, 2008 Report Share Posted November 23, 2008 NoSound: kāds tur sakars ar MySQL? Link to comment Share on other sites More sharing options...
NoSound Posted November 23, 2008 Report Share Posted November 23, 2008 bubu : /UPDATE/ nav saistīts ar MySQL ? Ja taisa kaut kādu mysql_close() kaut kur pa vidu, to neatjaunojot - loģiski ka rodas problēmas ( tas tikai bija tā .. starp citu, ieteikums uz priekšdienām tieši saistībā ar WBGD ) ! Link to comment Share on other sites More sharing options...
andrisp Posted November 23, 2008 Report Share Posted November 23, 2008 Dažu cilvēku padomi vienkārši gāž no kājām. :) Vēl varēji ieteikt, lai pārbauda vai datorā vispār ir PHP. NoSound, btw, autors izmanto mssql nevis mysql. Link to comment Share on other sites More sharing options...
Undeaded Posted November 23, 2008 Author Report Share Posted November 23, 2008 (edited) 2. Tas viss ir baigi forši, bet - es neredzu nevienu include, kas norādītu uz mysql konfirgurāciju .. Kam tad tas php fails vienojas klāt ? Kalkulatoram .. ? require("config.php"); tur ir: error_reporting(0); $dbhost = "127.0.0.1"; $dbuser = "login"; $dbpasswd = "pass"; $dbname = "databazesnosaukums"; $msconnect = mssql_connect($dbhost, $dbuser, $dbpasswd); $msdb = mssql_select_db($dbname,$msconnect); databaze table Character column Money: data type: int, length: 4 Edited November 23, 2008 by Undeaded Link to comment Share on other sites More sharing options...
bubu Posted November 23, 2008 Report Share Posted November 23, 2008 Undead: tu izdarīji to, ko es #4 postā paprasīju? Vai arī viss tev tagad strādā? Link to comment Share on other sites More sharing options...
Undeaded Posted November 23, 2008 Author Report Share Posted November 23, 2008 (edited) Parādi, ko rāda uz: print_r($fromrow); nestrada vispar... neko nerada... es te visu kodu nerakstiju... man vel ir tur: $sql_online_check3 = mssql_query("SELECT * FROM MEMB_STAT WHERE ConnectStat=0 AND memb___id='$login'"); $online_check = mssql_num_rows($sql_online_check3); $online_check rada (echo un print), bet $fromrow nerada probeju gan mssql_fetch_row gan mssql_num_row pats kods strada, bet man vajag šos divus elseif... laj nebutu kļudas Edited November 23, 2008 by Undeaded Link to comment Share on other sites More sharing options...
bubu Posted November 23, 2008 Report Share Posted November 23, 2008 Ja print_r tev neko nerāda, tad $fromrow ir NULL vai false, vai kautkas tml. Pamēģini ar vardump($fromrow). Un vai esi pārliecināts, ka SELECT kverijs atgriež kaut vienu rezultātu? Ja jau mssql_fetch_row atgriež false, tad selekts neko neizselektē. Tā rakstīts manuālī. Uzreiz pēc kverija kļūdas pārbaudīt mēģināji? if (!$sql_online_check) { die('MSSQL error: ' . mssql_get_last_message()); } Link to comment Share on other sites More sharing options...
Recommended Posts