Powered by Invision Power Board


Pages: (7) « First ... 4 5 [6] 7  ( Go to first unread post ) Reply to this topicStart new topicStart Poll

> [MOD] Casino, play 2 games and win or lose upload
Traasje
Posted: May 1 2005, 03:21 PM
Quote Post


Power User
***

Group: Power Users
Posts: 139
Member No.: 1,392
Joined: 14-December 04



what version of mysql do you have?
PMEmail Poster
Top
samehzone
Posted: May 1 2005, 09:35 PM
Quote Post


Power User
***

Group: Power Users
Posts: 50
Member No.: 4,582
Joined: 16-April 05



thanks very funny biggrin.gif


--------------------
PMEmail Poster
Top
tape
  Posted: May 2 2005, 03:28 AM
Quote Post


Member
**

Group: Members
Posts: 16
Member No.: 2,679
Joined: 29-January 05



I don't know something
CODE

<?php
//ob_start("ob_gzhandler");
require_once("include/bittorrent.php");
dbconn(false);
loggedinorreturn();
parked();       <------ What is this.

When I use your code I have blank page, but when I comment //parked(); like this I can see the page.

So I want to know that line is important? or not? smile.gif

Thank you for this MOD.
Very Good MOD. biggrin.gif

This post has been edited by tape on May 2 2005, 03:32 AM


--------------------
user posted image
PMEmail Poster
Top
ChupaCabra
Posted: May 2 2005, 03:39 AM
Quote Post


Member
***

Group: Power Users
Posts: 167
Member No.: 379
Joined: 28-September 04



that line is used if you have parked account mod..
if you don't have it it's not important
PM
Top
tape
  Posted: May 2 2005, 03:47 AM
Quote Post


Member
**

Group: Members
Posts: 16
Member No.: 2,679
Joined: 29-January 05



QUOTE (ChupaCabra @ May 2 2005, 03:39 AM)
that line is used if you have parked account mod..
if you don't have it it's not important

biggrin.gif Thank you very much. laugh.gif


--------------------
user posted image
PMEmail Poster
Top
VooDooTo
Posted: May 2 2005, 12:36 PM
Quote Post


Destructive Admin
***

Group: Power Users
Posts: 100
Member No.: 4,184
Joined: 3-April 05



I have tried all the things you said to do , but I still get blank page when I try to open casino.php ? Is there any code to include in bittorrent.php or somewhere else , because I can't get how to make this thing work ?
PMEmail PosterUsers Website
Top
macosbrain
Posted: May 2 2005, 01:37 PM
Quote Post


Power User
***

Group: Power Users
Posts: 45
Member No.: 3,966
Joined: 27-March 05



i don´t think that you need to include something. just the sql table.

my config (if this helps):

-tracker based on BrokenStones tracker (heavily modded)
-winXP
-XAMPP


--------------------
macosbrain.com is my site
PMEmail Poster
Top
ChupaCabra
Posted: May 2 2005, 01:41 PM
Quote Post


Member
***

Group: Power Users
Posts: 167
Member No.: 379
Joined: 28-September 04



QUOTE (VooDooTo @ May 2 2005, 12:36 PM)
I have tried all the things you said to do , but I still get blank page when I try to open casino.php ? Is there any code to include in bittorrent.php or somewhere else , because I can't get how to make this thing work ?

Find
CODE

parked();

CODE

Replace with
//parked();
PM
Top
Traasje
Posted: May 2 2005, 02:12 PM
Quote Post


Power User
***

Group: Power Users
Posts: 139
Member No.: 1,392
Joined: 14-December 04



macosbrain?
do you have a idea for my biggrin.gif
PMEmail Poster
Top
LucianBoy
Posted: May 2 2005, 02:17 PM
Quote Post


Power User
***

Group: Power Users
Posts: 58
Member No.: 4,701
Joined: 21-April 05



Ho has the all code ???
can someone post the all code for the MOD CASINO ??? plz


--------------------
Sorry for my verry BAD ENGLESH
Torrents source 200505051951 by LucianBoy
PMEmail PosterUsers WebsiteYahoo
Top
tape
  Posted: May 3 2005, 04:10 AM
Quote Post


Member
**

Group: Members
Posts: 16
Member No.: 2,679
Joined: 29-January 05



QUOTE (LucianBoy @ May 2 2005, 02:17 PM)
Ho has the all code ???
can someone post the all code for the MOD CASINO ??? plz

In this code I fix something for my Tracker.

My Table
CODE

--
-- โครงสร้างตาราง `casino`
--

CREATE TABLE `casino` (
 `userid` int(10) NOT NULL default '0',
 `win` bigint(20) default NULL,
 `lost` bigint(20) default NULL,
 `trys` int(11) NOT NULL default '0',
 `date` datetime NOT NULL default '0000-00-00 00:00:00',
 `enableplay` enum('yes','no') NOT NULL default 'yes',
 PRIMARY KEY  (`userid`)
) TYPE=MyISAM;


casino.php
CODE

<?php
//ob_start("ob_gzhandler");
require_once("include/bittorrent.php");
dbconn(false);
loggedinorreturn();
//parked();

//////////////////////////////////config
//////who is able to play just
//$player = UC_PEASANT;
$player = UC_USER;
//$player = UC_POWER_USER;
//$player = UC_VIP;
//$player = UC_UPLOADER;
//$player = UC_MODERATOR;
//$player = UC_ADMINISTRATOR;
//$player = UC_SYSOP;
$mb_basic=1024*1024;
$max_download_user = $mb_basic*1024*25; //// 25 GB
$max_download_global = $mb_basic*$mb_basic*2.5; //// 2.5 TB :-)
$required_ratio = 0.4; ///i think you know this
$max_trys = 50; ///50 games and no more

//////////////////this is the funny part
$user_everytimewin_mb = $mb_basic * 70; ////// means users that wins under 70 mb get a cheat_value of 0 -> win every time
$cheat_value = 1; // higher value -> less winner
$cheat_breakpoint = 2; ////very important value -> if (win MB > max_download_global/cheat_breakpoint)
$cheat_value_max = 5; ////// then cheat_value = cheat_value_max -->> i hope you know what i mean. ps: must be higher as cheat_value.
$cheat_ratio_user = 0.4; ///if casino_ratio_user > cheat_ratio_user -> $cheat_value = rand($cheat_value,$cheat_value_max)
$cheat_ratio_global = 0.4; /// same as user just global
$win_amount = 3; // how much do the player win in the first game eg. bet 300, win_amount=3 ---->>> 300*3= 900 win
$win_amount_on_number = 6; // same as win_amount for the number game
$show_real_chance = false; ///shows the user the real chance true or false
$bet_value1 = $mb_basic * 20; ///this is in MB but you can also choose gb or tb :-)
$bet_value2 = $mb_basic * 50;
$bet_value3 = $mb_basic * 100;
$bet_value4 = $mb_basic * 250;
$bet_value5 = $mb_basic * 500;
$bet_value6 = $mb_basic * 1024;
$bet_value7 = $mb_basic * 2048;

//////////////////////////////////config end

if (get_user_class() < $player)
stderr("Sorry ".$CURUSER["username"]," Do not allow your class to play casino");

$query ="select * from casino where userid = '".$CURUSER["id"]."'";
$result = mysql_query($query) or die (mysql_error());
if(mysql_affected_rows()!=1)
{
mysql_query("INSERT INTO casino (userid, win, lost, trys, date) VALUES(" . $CURUSER["id"] . ",0,0,0, '" . get_date_time() . "')") or mysql_error();
//stderr("Hi ".$CURUSER["username"], "This is the first time you try to play at the Casino please refresh the site");
$result = mysql_query($query); ///query another time to get the new user, if the stderr is uncomment
}

$row = mysql_fetch_array($result);
$user_win = $row["win"];
$user_lost = $row["lost"];
$user_trys = $row["trys"];
$user_date = $row["date"];
$user_enableplay = $row["enableplay"];

if($user_enableplay=="no")
stderr("Sorry ".$CURUSER["username"],"your banned from casino");

if($user_trys > $max_trys)
stderr("Sorry ".$CURUSER["username"],"your playtime is over");

if(($user_win - $user_lost) > $max_download_user)
stderr("Sorry ".$CURUSER["username"],"you have reached the max download for a single user");

if ($CURUSER["downloaded"] > 0)
  $ratio = number_format($CURUSER["uploaded"] / $CURUSER["downloaded"], 2);
else
  if ($CURUSER["uploaded"] > 0)
    $ratio = 999;
  else
    $ratio = 0;
if($ratio < $required_ratio)
 stderr("Sorry ".$CURUSER["username"],"your ratio is under ".$required_ratio);  

$global_down2 = mysql_query(" select (sum(win)-sum(lost)) as globaldown, sum(win) as win, sum(lost) as lost from casino") or die (mysql_error());
$row = mysql_fetch_array($global_down2);
$global_down = $row["globaldown"];
$global_win = $row["win"];
$global_lost = $row["lost"];

if ($user_win > 0)
  $casino_ratio_user = number_format($user_lost / $user_win, 2);
else
  if ($user_lost > 0)
    $casino_ratio_user = 999;
  else
    $casino_ratio_user = 0;
   
if ($global_win > 0)
  $casino_ratio_global = number_format($global_lost / $global_win, 2);
else
  if ($global_lost > 0)
    $casino_ratio_global = 999;
  else
    $casino_ratio_global = 0;

//get users that bet the first time or win very less :-)
if($user_win < $user_everytimewin_mb)
 $cheat_value = 0;
else
{
 //i think this is a god idea GLOBAL
 if($global_down > ($max_download_global / $cheat_breakpoint))
  $cheat_value = $cheat_value_max;
 if($casino_ratio_global < $cheat_ratio_global)
  $cheat_value = rand($cheat_value,$cheat_value_max);
 
 //i think this is a god idea for EACH USER
 if(($user_win - $user_lost) > ($max_download_user / $cheat_breakpoint))
  $cheat_value = $cheat_value_max;
 if($casino_ratio_user < $cheat_ratio_user)
  $cheat_value = rand($cheat_value,$cheat_value_max);
}

if($global_down > $max_download_global)
stderr("Sorry ".$CURUSER["username"],"but global max win is above ".mksize($max_download_global));


////////////////////////////////////////////////////////////////////////////////////////////////

if((($_POST["color"]=="red"||$_POST["color"]=="black")||($_POST["number"]=="1"||$_POST["number"]=="2"||$_POST["number"]=="3"||$_POST["number"]=="4"||$_POST["number"]=="5"||
$_POST["number"]=="6"))&&($_POST["betmb"]==$bet_value1||$_POST["betmb"]==$bet_value2||$_POST["betmb"]==$bet_value3||$_POST["betmb"]==$bet_value4||$_POST["betmb"]==$bet_value5||
$_POST["betmb"]==$bet_value6||$_POST["betmb"]==$bet_value7))  
{
if($_POST["number"])
{
$win_amount = $win_amount_on_number;
$cheat_value = $cheat_value+5;
$winner_was = $_POST["number"];
}
else
$winner_was = $_POST["color"];

$win = $win_amount*$betmb;

if($CURUSER["uploaded"] < $betmb)
stderr("Sorry ".$CURUSER["username"],"but you have not uploaded ".mksize($betmb));

stdhead();


if(rand(0,$cheat_value)==$cheat_value)
{
stdmsg("Yes ".$CURUSER["username"],"You got it and win ".mksize($win)." because <font color=\"".$winner_was."\"><b>".$winner_was."</b></font> is the winner. <p><a href=casino.php><b>เล่นต่อ ติดลม!!!</b></a></p>");
mysql_query("UPDATE users SET uploaded = uploaded + ".$win." WHERE id=".$CURUSER["id"]) or sqlerr();
mysql_query("UPDATE casino SET date = '".get_date_time()."', trys = trys + 1, win = win + ".$win." WHERE userid=".$CURUSER["id"]) or sqlerr();
}
else
{
if($_POST["number"])
{
 do
 {
  $fake_winner = rand(1,6);
 }
 while($_POST["number"]==$fake_winner);
}
else
{
 if($_POST["color"]=="black")
  $fake_winner= "red";
 else
  $fake_winner= "black";
}


stdmsg("Sorry ".$CURUSER["username"],"You lost ".mksize($betmb)." because <font color=\"".$fake_winner."\"><b>".$fake_winner."</b></font> and not <font color=\"".$winner_was."\"><b>".$winner_was."</b></font> was the winner. <p><a href=casino.php><b>เล่นต่อ ติดลม!!!</b></a></p>");
mysql_query("UPDATE users SET uploaded = uploaded - ".$betmb." WHERE id=".$CURUSER["id"]) or sqlerr();
mysql_query("UPDATE casino SET date = '".get_date_time()."', trys = trys + 1 ,lost = lost + ".$betmb." WHERE userid=".$CURUSER["id"]) or sqlerr();
}
 
}
else
{

stdhead();
print("<h1>Welcome, <a href=userdetails.php?id=$CURUSER[id]>$CURUSER[username]</a>!</h1>\n");

print("<table cellspacing=0 cellpadding=10 width=500>\n");
print("<tr><td colspan=2 cellspacing=0 cellpadding=5>");
echo("<h1>Game 1:</h1>");

print("<form name=casino method=post action=$phpself>");
print("<table class=message width=100% cellspacing=0 cellpadding=5>\n");
 tr("Bet on color:","<input type=submit value='Do it!' >",1);
 tr("Black",'<input name="color" type="radio" checked value="black">',1);
 tr("<font color=red>Red</font>",'<input name="color" type="radio" value="red">',1);
 tr("How much",'
 <select name="betmb">
 <option value="'.$bet_value1.'">'.mksize($bet_value1).'</option>
 <option value="'.$bet_value2.'">'.mksize($bet_value2).'</option>
 <option value="'.$bet_value3.'">'.mksize($bet_value3).'</option>
 <option value="'.$bet_value4.'">'.mksize($bet_value4).'</option>
 <option value="'.$bet_value5.'">'.mksize($bet_value5).'</option>
 <option value="'.$bet_value6.'">'.mksize($bet_value6).'</option>
 <option value="'.$bet_value7.'">'.mksize($bet_value7).'</option>
 </select>',1);
 
if($show_real_chance)
 $real_chance=$cheat_value+1;
else
 $real_chance=2;
tr("Your chance","1 : ".$real_chance,1);
tr("You can win",$win_amount." * stake",1);
echo('</table><br>');
print("</form>");

echo("<h1>Game 2:</h1>");
print("<form name=casino2 method=post action=$phpself>");
print("<table class=message width=100% cellspacing=0 cellpadding=5>\n");
 tr("Bet on number:","<input type=submit value='Do it!' >",1);
 tr("Number",'<input name="number" type="radio" checked value="1">1&nbsp;&nbsp;<input name="number" type="radio" value="2">2&nbsp;&nbsp;<input name="number" type="radio" value="3">3<br><input name="number" type="radio" value="4">4&nbsp;&nbsp;<input name="number" type="radio" value="5">5&nbsp;&nbsp;<input name="number" type="radio" value="6">6',1);
 //tr("",'<input name="number" type="radio" value="4">4&nbsp;&nbsp;<input name="number" type="radio" value="5">5&nbsp;&nbsp;<input name="number" type="radio" value="6">6',1);
 tr("How much",'
 <select name="betmb">
 <option value="'.$bet_value1.'">'.mksize($bet_value1).'</option>
<option value="'.$bet_value2.'">'.mksize($bet_value2).'</option>
<option value="'.$bet_value3.'">'.mksize($bet_value3).'</option>
<option value="'.$bet_value4.'">'.mksize($bet_value4).'</option>
<option value="'.$bet_value5.'">'.mksize($bet_value5).'</option>
<option value="'.$bet_value6.'">'.mksize($bet_value6).'</option>
<option value="'.$bet_value7.'">'.mksize($bet_value7).'</option>
 </select>',1);
 
if($show_real_chance)
 $real_chance=$cheat_value+5;
else
 $real_chance=6;
tr("Your chance","1 : ".$real_chance,1);
tr("You can win",$win_amount_on_number." * stake",1);
echo('</table><br>');
print("</form>");
print("</td></tr></table><br>");

print("<table cellspacing=0 cellpadding=10>\n");
print("<tr><td>");
print("<h1>User stats</h1>\n");
print("<table class=message  cellspacing=0 cellpadding=5>\n");
 tr("You can win",mksize($max_download_user),1);
 tr("Won",mksize($user_win),1);
 tr("Lost",mksize($user_lost),1);
 tr("Ratio",$casino_ratio_user,1);
echo('</table>');
print("</td><td>");
print("<h1>Global stats</h1>\n");
print("<table class=message  cellspacing=0 cellpadding=5>\n");
 tr("Users can win",mksize($max_download_global),1);
 tr("Won",mksize($global_win),1);
 tr("Lost",mksize($global_lost),1);
 tr("Ratio",$casino_ratio_global,1);
echo('</table>');
print("</td></tr>");
echo('</table>');

echo('<p><center><a href="casino_player.php"><b>แสดงรายชื่อผู้เล่นทั้งหมด และอัตราได้เสีย</b></a></center></p>');

}
stdfoot();
?>


casino_player.php
CODE

<?

require "include/bittorrent.php";
dbconn(false);
loggedinorreturn();
ob_start("ob_gzhandler");

if (get_user_class() >= UC_ADMINISTRATOR)
$edit = 1;


$res2 = mysql_query("select count(*) from casino") or die(mysql_error());
$row2 = mysql_fetch_array($res2);
$count = $row2[0];


$perpage = 50;

list($pagertop, $pagerbottom, $limit) = pager($perpage, $count, $_SERVER["PHP_SELF"] ."?" );

$res = mysql_query("select users.id as userid,users.username, users.downloaded,users.uploaded,casino.win,casino.lost from casino inner join users on casino.userid = users.id  ORDER BY (casino.win - casino.lost) DESC $limit") or sqlerr();

stdhead("Players");



if (mysql_num_rows($res) == 0)
print("<p align=center><b>No players</b></p>\n");
else
{
print("<p align=center><b><h1>Results</h1></b></p>\n");
print("<p align=center><a href=casino.php>Back to casino</a></p>\n");
echo $pagertop;
print("<table border=1 cellspacing=0 cellpadding=5>\n");


if($edit==0)
print("<tr><td class=colhead>Username</td><td class=colhead align=left>Uploaded</td><td class=colhead align=left>Downloaded</td><td class=colhead align=left>Ratio</td><td class=colhead align=left>Won</td><td class=colhead align=left>Lost</td><td class=colhead align=left>Tries</td><td class=colhead align=left>Total</td>\n");
else
print("<tr><td class=colhead>Username</td><td class=colhead align=left>Uploaded</td><td class=colhead align=left>Downloaded</td><td class=colhead align=left>Ratio</td><td class=colhead align=left>Won</td><td class=colhead align=left>Lost</td><td class=colhead align=left>Tries</td><td class=colhead align=left>Total</td><td class=colhead align=left>edit user</td>\n");


while ($arr = mysql_fetch_assoc($res))
{
$rez = mysql_query("select * from casino where userid=$arr[userid]");
$arz = mysql_fetch_array($rez);
if ($arr["downloaded"] > 0)
{
    $ratio = number_format($arr["uploaded"] / $arr["downloaded"], 3);
    $ratio = "<font color=" . get_ratio_color($ratio) . ">$ratio</font>";
 }
 else
    if ($arr["uploaded"] > 0)
      $ratio = "Inf.";
else
$ratio = "---";
$uploaded =mksize($arr["uploaded"]);
$downloaded = mksize($arr["downloaded"]);
if ($CURUSER[id] == $arr[userid])
$bg = "bgcolor=#c0c0c0";
else
$bg = "";

$all = $arz[win]-$arz[lost];
if($all < 0)
{
$all = $all * -1;
$minus = "-";
}

if($edit==0)
print("<tr><td $bg><a href=userdetails.php?id=$arr[userid]><b>$arr[username]</b></a></td><td align=left $bg>$uploaded</td><td align=left $bg>$downloaded</td><td align=left $bg>$ratio</td><td align=left $bg>".mksize($arz[win])."</td><td align=left $bg>".mksize($arz[lost])."</td><td align=left $bg>$arz[trys]</td><td align=left $bg> $minus".mksize($all)."</td></tr>\n");
else
print("<tr><td $bg><a href=userdetails.php?id=$arr[userid]><b>$arr[username]</b></a></td><td align=left $bg>$uploaded</td><td align=left $bg>$downloaded</td><td align=left $bg>$ratio</td><td align=left $bg>".mksize($arz[win])."</td><td align=left $bg>".mksize($arz[lost])."</td><td align=left $bg>$arz[trys]</td><td align=left $bg> $minus".mksize($all)."</td><td align=left $bg><form name=edit-player method=post action=casino_player_edit.php><input type=hidden name=userid value=$arr[userid]> <input class=btn type=submit value=edit ></form></td></tr>\n");

}
print("</table>\n");
}


stdfoot();

?>


casino_player_edit.php
CODE

<?

require "include/bittorrent.php";
dbconn(false);
loggedinorreturn();
ob_start("ob_gzhandler");

if (get_user_class() <= UC_ADMINISTRATOR)
stderr("Sorry ".$CURUSER["username"]," Do not allow your class to edit the casino play");

$result = mysql_query("select * from casino where userid = '".$userid."'") or die(mysql_error());
if (mysql_num_rows($result) == 0)
stderr("Sorry","No players with the userid $userid</b></p>\n");
else
{
$row = mysql_fetch_array($result);
$user_win = $row["win"];
$user_lost = $row["lost"];
$user_trys = $row["trys"];
$user_date = $row["date"];
$user_enableplay = $row["enableplay"];
stdhead();

if($_POST["userid"]!=NULL&&$_POST["won"]!=NULL&&$_POST["lost"]!=NULL&&$_POST["trys"]!=NULL&&$_POST["date"]!=NULL&&$_POST["enableplay"]!=NULL)
{
$dif_win = $won - $user_win;   ///// this is tricky
$dif_lost = $lost - $user_lost; ///// this is tricky
$up = $dif_win - $dif_lost;   ///// this is tricky
mysql_query("UPDATE users SET uploaded = uploaded + ".$up." WHERE id=".$userid) or sqlerr();
mysql_query("UPDATE casino SET date = '".$date."', trys = ".$trys." ,lost = ".$lost.",win = ".$won.",enableplay= '".$enableplay."' WHERE userid=".$userid) or sqlerr();

stdmsg("Stats for user ".$userid." are now updated" ,"sorry but no problems occured :-)");

}
else
{
 if ($user_win > 0)
   $casino_ratio_user = number_format($user_lost / $user_win, 2);
 else
   if ($user_lost > 0)
     $casino_ratio_user = 999;
   else
     $casino_ratio_user = 0;
     
 if($user_enableplay=="yes")
 {
  $select="<option value=yes checked >yes</option>";
  $select.="<option value=no>no</option>";
 }
 else
 {
  $select="<option value=yes >yes</option>";
  $select.="<option value=no checked>no</option>";
 }


print("<h1>Welcome, you are now able to edit user nr. <a href=userdetails.php?id=$userid>$userid</a>!</h1>\n");
print("<p align=center><a href=casino.php>Back</a></p>\n");
print("<form name=edit-player method=post action=$phpself><input type=hidden name=userid value=$userid>");
print("<table  cellspacing=0 cellpadding=3 width=400>\n");
tr("user ratio:",$casino_ratio_user,1);
tr("user won:","<input type=text name=won value='$user_win' >&nbsp;&nbsp;".mksize($user_win),1);
tr("user lost:","<input type=text name=lost value='$user_lost' >&nbsp;&nbsp;".mksize($user_lost),1);
tr("user play ","<input type=text name=trys value='$user_trys' >&nbsp;&nbsp;<b>games</b>",1);
tr("last access:","<input type=text name=date value='$user_date' >",1);
tr("allow user to play:",'<select name="enableplay">'.$select.'</select> ',1);
print("<tr><td colspan=2 align=center><input type=submit value='change user stats'></td></tr>");
print("</table>\n");
print("</form>");
}
}
stdfoot();
?>


My Tracker is ForStudent Bittorrent Tracker

This post has been edited by tape on May 4 2005, 05:31 AM


--------------------
user posted image
PMEmail Poster
Top
VooDooTo
Posted: May 3 2005, 05:13 AM
Quote Post


Destructive Admin
***

Group: Power Users
Posts: 100
Member No.: 4,184
Joined: 3-April 05



Really thank you . Now it works smile.gif !
PMEmail PosterUsers Website
Top
VooDooTo
Posted: May 3 2005, 05:51 AM
Quote Post


Destructive Admin
***

Group: Power Users
Posts: 100
Member No.: 4,184
Joined: 3-April 05



QUOTE (Traasje @ May 1 2005, 07:34 PM)
when i try game 2 i get this:
Sorry Traasje
you lost 0.00 kB because 4 and not 1 was the winner
mySQL Error
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 'WHERE id=2' at line 1

I got the same error . It's from the database I think . Can somebody give me a working database code ?
PMEmail PosterUsers Website
Top
tape
  Posted: May 4 2005, 05:35 AM
Quote Post


Member
**

Group: Members
Posts: 16
Member No.: 2,679
Joined: 29-January 05



QUOTE (VooDooTo @ May 3 2005, 05:51 AM)
QUOTE (Traasje @ May 1 2005, 07:34 PM)
when i try game 2 i get this:
Sorry Traasje
you lost 0.00 kB because 4 and not 1 was the winner
mySQL Error
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 'WHERE id=2' at line 1

I got the same error . It's from the database I think . Can somebody give me a working database code ?

This is my SQL table.
CODE

--
-- โครงสร้างตาราง `casino`
--

CREATE TABLE `casino` (
 `userid` int(10) NOT NULL default '0',
 `win` bigint(20) default NULL,
 `lost` bigint(20) default NULL,
 `trys` int(11) NOT NULL default '0',
 `date` datetime NOT NULL default '0000-00-00 00:00:00',
 `enableplay` enum('yes','no') NOT NULL default 'yes',
 PRIMARY KEY  (`userid`)
) TYPE=MyISAM;


I'm sorry.
I can't answer your question about SQL error because I known about PHP very little I can edit only HTML.
I'm very sorry.

But when I use my code I don't have SQL error. biggrin.gif


--------------------
user posted image
PMEmail Poster
Top
mushkin
Posted: May 4 2005, 06:05 AM
Quote Post


Member
**

Group: Members
Posts: 16
Member No.: 1,317
Joined: 10-December 04



This is working with no SQL errors for me:

just copy the lines 152 + 153:
QUOTE
mysql_query("UPDATE users SET uploaded = uploaded + ".$win." WHERE id=".$CURUSER["id"]) or sqlerr();
mysql_query("UPDATE casino SET date = '".get_date_time()."', trys = trys + 1, win = win + ".$win." WHERE userid=".$CURUSER[id]) or sqlerr();


and delete the mysql_query at 176 + 177 (that is very similar) and paste it.

it will give you a casino.php like this:
QUOTE
<?php
ob_start("ob_gzhandler");
require_once("include/bittorrent.php");
dbconn(false);
loggedinorreturn();
//parked();

//////////////////////////////////config
//////who is able to play just
//$player = UC_PEASANT;
$player = UC_USER;
//$player = UC_POWER_USER;
//$player = UC_VIP;
//$player = UC_UPLOADER;
//$player = UC_MODERATOR;
//$player = UC_ADMINISTRATOR;
//$player = UC_SYSOP;
$mb_basic=1024*1024;
$max_download_user = $mb_basic*1024*2; //// 25 GB
$max_download_global = $mb_basic*$mb_basic*2.5; //// 2.5 TB :-)
$required_ratio = 0.4; ///i think you know this
$max_trys = 50; ///50 games and no more

//////////////////this is the funny part
$user_everytimewin_mb = $mb_basic * 20; ////// means users that wins under 70 mb get a cheat_value of 0 -> win every time
$cheat_value = 5; // higher value -> less winner
$cheat_breakpoint = 2; ////very important value -> if (win MB > max_download_global/cheat_breakpoint)
$cheat_value_max = 6; ////// then cheat_value = cheat_value_max -->> i hope you know what i mean. ps: must be higher as cheat_value.
$cheat_ratio_user = 0.4; ///if casino_ratio_user > cheat_ratio_user -> $cheat_value = rand($cheat_value,$cheat_value_max)
$cheat_ratio_global = 0.4; /// same as user just global
$win_amount = 3; // how much do the player win in the first game eg. bet 300, win_amount=3 ---->>> 300*3= 900 win
$win_amount_on_number = 6; // same as win_amount for the number game
$show_real_chance = true; ///shows the user the real chance true or false
$bet_value1 = $mb_basic * 20; ///this is in MB but you can also choose gb or tb :-)
$bet_value2 = $mb_basic * 50;
$bet_value3 = $mb_basic * 100;
$bet_value4 = $mb_basic * 250;
$bet_value5 = $mb_basic * 500;
$bet_value6 = $mb_basic * 1024;
$bet_value7 = $mb_basic * 2048;

//////////////////////////////////config end

if (get_user_class() < $player)
stderr("Sorry ".$CURUSER["username"]," Do not allow your class to play casino");

$query ="select * from casino where userid = '".$CURUSER["id"]."'";
$result = mysql_query($query) or die (mysql_error());
if(mysql_affected_rows()!=1)
{
mysql_query("INSERT INTO casino (userid, win, lost, trys, date) VALUES(" . $CURUSER["id"] . ",0,0,0, '" . get_date_time() . "')") or mysql_error();
//stderr("Hi ".$CURUSER["username"], "This is the first time you try to play at the Casino please refresh the site");
$result = mysql_query($query); ///query another time to get the new user, if the stderr is uncomment
}

$row = mysql_fetch_array($result);
$user_win = $row["win"];
$user_lost = $row["lost"];
$user_trys = $row["trys"];
$user_date = $row["date"];
$user_enableplay = $row["enableplay"];

if($user_enableplay=="no")
stderr("Sorry ".$CURUSER["username"],"your banned from casino");

if($user_trys > $max_trys)
stderr("Sorry ".$CURUSER["username"],"your playtime is over");

if(($user_win - $user_lost) > $max_download_user)
stderr("Sorry ".$CURUSER["username"],"you have reached the max download for a single user");

if ($CURUSER["downloaded"] > 0)
  $ratio = number_format($CURUSER["uploaded"] / $CURUSER["downloaded"], 2);
else
  if ($CURUSER["uploaded"] > 0)
    $ratio = 999;
  else
    $ratio = 0;
if($ratio < $required_ratio)
stderr("Sorry ".$CURUSER["username"],"your ratio is under ".$required_ratio); 

$global_down2 = mysql_query(" select (sum(win)-sum(lost)) as globaldown, sum(win) as win, sum(lost) as lost from casino") or die (mysql_error());
$row = mysql_fetch_array($global_down2);
$global_down = $row["globaldown"];
$global_win = $row["win"];
$global_lost = $row["lost"];

if ($user_win > 0)
  $casino_ratio_user = number_format($user_lost / $user_win, 2);
else
  if ($user_lost > 0)
    $casino_ratio_user = 999;
  else
    $casino_ratio_user = 0;
   
if ($global_win > 0)
  $casino_ratio_global = number_format($global_lost / $global_win, 2);
else
  if ($global_lost > 0)
    $casino_ratio_global = 999;
  else
    $casino_ratio_global = 0;

//get users that bet the first time or win very less :-)
if($user_win < $user_everytimewin_mb)
$cheat_value = 0;
else
{
//i think this is a god idea GLOBAL
if($global_down > ($max_download_global / $cheat_breakpoint))
  $cheat_value = $cheat_value_max;
if($casino_ratio_global < $cheat_ratio_global)
  $cheat_value = rand($cheat_value,$cheat_value_max);

//i think this is a god idea for EACH USER
if(($user_win - $user_lost) > ($max_download_user / $cheat_breakpoint))
  $cheat_value = $cheat_value_max;
if($casino_ratio_user < $cheat_ratio_user)
  $cheat_value = rand($cheat_value,$cheat_value_max);
}

if($global_down > $max_download_global)
stderr("Sorry ".$CURUSER["username"],"but global max win is above ".mksize($max_download_global));


////////////////////////////////////////////////////////////////////////////////////////////////

if((($_POST["color"]=="red"||$_POST["color"]=="black")||($_POST["number"]=="1"||$_POST["number"]=="2"||$_POST["number"]=="3"||$_POST["number"]=="4"||$_POST["number"]=="5"||
$_POST["number"]=="6"))&&($_POST["betmb"]==$bet_value1||$_POST["betmb"]==$bet_value2||$_POST["betmb"]==$bet_value3||$_POST["betmb"]==$bet_value4||$_POST["betmb"]==$bet_value5||
$_POST["betmb"]==$bet_value6||$_POST["betmb"]==$bet_value7)) 
{
if($_POST["number"])
{
$win_amount = $win_amount_on_number;
$cheat_value = $cheat_value+5;
$winner_was = $_POST["number"];
}
else
$winner_was = $_POST["color"];

$win = $win_amount*$betmb;

if($CURUSER["uploaded"] < $betmb)
stderr("Sorry ".$CURUSER["username"],"but you have not uploaded ".mksize($betmb));

stdhead();


if(rand(0,$cheat_value)==$cheat_value)
{
stdmsg("Yes ".$CURUSER["username"],"You got it and win ".mksize($win)." because <font color=\"".$winner_was."\"><b>".$winner_was."</b></font> is the winner. <p><a href=casino.php><b>??????? ?????!!!</b></a></p>");
mysql_query("UPDATE users SET uploaded = uploaded + ".$win." WHERE id=".$CURUSER["id"]) or sqlerr();
mysql_query("UPDATE casino SET date = '".get_date_time()."', trys = trys + 1, win = win + ".$win." WHERE userid=".$CURUSER[id]) or sqlerr();
}
else
{
if($_POST["number"])
{
do
{
  $fake_winner = rand(1,6);
}
while($_POST["number"]==$fake_winner);
}
else
{
if($_POST["color"]=="black")
  $fake_winner= "red";
else
  $fake_winner= "black";
}


stdmsg("Yes ".$CURUSER["username"],"You got it and win ".mksize($win)." because <font color=\"".$winner_was."\"><b>".$winner_was."</b></font> is the winner. <p><a href=casino.php><b>??????? ?????!!!</b></a></p>");
mysql_query("UPDATE users SET uploaded = uploaded + ".$win." WHERE id=".$CURUSER["id"]) or sqlerr();
mysql_query("UPDATE casino SET date = '".get_date_time()."', trys = trys + 1, win = win + ".$win." WHERE userid=".$CURUSER[id]) or sqlerr();
}

}
else
{

stdhead();
print("<h1>Welcome, <a href=userdetails.php?id=$CURUSER[id]>$CURUSER[username]</a>!</h1>\n");

print("<table cellspacing=0 cellpadding=10 width=500>\n");
print("<tr><td colspan=2 cellspacing=0 cellpadding=5>");
echo("<h1>Jeu N°1:</h1>");

print("<form name=casino method=post action=$phpself>");
print("<table class=message width=100% cellspacing=0 cellpadding=5>\n");
tr("Parier sur une couleur:","<input type=submit value='Envoi!' >",1);
tr("NOIR",'<input name="color" type="radio" checked value="black">',1);
tr("<font color=red>ROUGE</font>",'<input name="color" type="radio" value="red">',1);
tr("Combien",'
<select name="betmb">
<option value="'.$bet_value1.'">'.mksize($bet_value1).'</option>
<option value="'.$bet_value2.'">'.mksize($bet_value2).'</option>
<option value="'.$bet_value3.'">'.mksize($bet_value3).'</option>
<option value="'.$bet_value4.'">'.mksize($bet_value4).'</option>
<option value="'.$bet_value5.'">'.mksize($bet_value5).'</option>
<option value="'.$bet_value6.'">'.mksize($bet_value6).'</option>
<option value="'.$bet_value7.'">'.mksize($bet_value7).'</option>
</select>',1);

if($show_real_chance)
$real_chance=$cheat_value+1;
else
$real_chance=2;
tr("Vos chances","1 : ".$real_chance,1);
tr("Vous pouvez gagner",$win_amount." x votre mise",1);
echo('</table><br>');
print("</form>");

echo("<h1>Jeu N°2:</h1>");
print("<form name=casino2 method=post action=$phpself>");
print("<table class=message width=100% cellspacing=0 cellpadding=5>\n");
tr("Parier sur un nombre:","<input type=submit value='Envoi!' >",1);
tr("Nombre",'<input name="number" type="radio" checked value="1">1&nbsp;&nbsp;<input name="number" type="radio" value="2">2&nbsp;&nbsp;<input name="number" type="radio" value="3">3<br><input name="number" type="radio" value="4">4&nbsp;&nbsp;<input name="number" type="radio" value="5">5&nbsp;&nbsp;<input name="number" type="radio" value="6">6',1);
//tr("",'<input name="number" type="radio" value="4">4&nbsp;&nbsp;<input name="number" type="radio" value="5">5&nbsp;&nbsp;<input name="number" type="radio" value="6">6',1);
tr("Combien",'
<select name="betmb">
<option value="'.$bet_value1.'">'.mksize($bet_value1).'</option>
<option value="'.$bet_value2.'">'.mksize($bet_value2).'</option>
<option value="'.$bet_value3.'">'.mksize($bet_value3).'</option>
<option value="'.$bet_value4.'">'.mksize($bet_value4).'</option>
<option value="'.$bet_value5.'">'.mksize($bet_value5).'</option>
<option value="'.$bet_value6.'">'.mksize($bet_value6).'</option>
<option value="'.$bet_value7.'">'.mksize($bet_value7).'</option>
</select>',1);

if($show_real_chance)
$real_chance=$cheat_value+5;
else
$real_chance=6;
tr("Vos chances","1 : ".$real_chance,1);
tr("Vous pouvez gagner",$win_amount_on_number." x vote mise",1);
echo('</table><br>');
print("</form>");
print("</td></tr></table><br>");

print("<table cellspacing=0 cellpadding=10>\n");
print("<tr><td>");
print("<h1>User stats</h1>\n");
print("<table class=message  cellspacing=0 cellpadding=5>\n");
tr("Vous pouvez gagner",mksize($max_download_user),1);
tr("Gagné",mksize($user_win),1);
tr("Perdu",mksize($user_lost),1);
tr("Ratio",$casino_ratio_user,1);
echo('</table>');
print("</td><td>");
print("<h1>Statistiques globales</h1>\n");
print("<table class=message  cellspacing=0 cellpadding=5>\n");
tr("Les joueurs peuvent gagner",mksize($max_download_global),1);
tr("Gagné",mksize($global_win),1);
tr("Perdu",mksize($global_lost),1);
tr("Ratio",$casino_ratio_global,1);
echo('</table>');
print("</td></tr>");
echo('</table>');

echo('<p><center><a href="casino_player.php"><b>????????????????????????? ???????????????</b></a></center></p>');

}
stdfoot();
?>
PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic OptionsPages: (7) « First ... 4 5 [6] 7  Reply to this topicStart new topicStart Poll

 



[ Script Execution time: 0.0729 ]   [ 12 queries used ]   [ GZIP Enabled ]