Jump to content

grlayouts

Members
  • Posts

    342
  • Joined

  • Last visited

Everything posted by grlayouts

  1. Got ya, It now inserts, but I get no success or failure message..
  2. If anyone could help, I'm not getting an error message and I've tried changing the code around a few times and outputting errors. The database does not update and i'm getting no error message output on submit, I assume i'm missing something? <?php session_start(); include_once 'dbconnect.php'; if (!isset($_SESSION['userSession'])) { header("Location: index.php"); } $query = $DBcon->query("SELECT * FROM tbl_users WHERE user_id=".$_SESSION['userSession']); $userRow=$query->fetch_array(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Welcome - <?php echo $userRow['email']; ?></title> <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen"> <link href="bootstrap/css/bootstrap-theme.min.css" rel="stylesheet" media="screen"> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <?php include_once 'header.php'; ?> <html> <head></head> <body> <h1>Send Message:</h1> <form action='message.php' method='POST'> <table> <tbody> <tr> <td>To: </td><td><input type='text' name='to' /></td> </tr> <tr> <td>From: </td><td><input type='text' name='from' /></td> </tr> <tr> <td>Message: </td><td><input type='text' name='message' /></td> </tr> <tr> <td></td><td><input type='submit' value='Create Task' name='sendMessage' /></td> </tr> </tbody> </table> </form> </body> </html> <?php if (isSet($_POST['sendMessage'])) { if (isSet($_POST['to']) && $_POST['to'] != '' && isSet($_POST['from']) && $_POST['from'] != '' && isSet($_POST['message']) && $_POST['message'] != '') { $to = $_POST['to']; $from = $userRow['email']; $message = $_POST['message']; $q = "INSERT INTO tbl_messages(id,message,to,from) VALUES('', '$message', '$to', '$from')"; if ($DBcon->query($q)) { $msg = "<div class='alert alert-success'> <span class='glyphicon glyphicon-info-sign'></span> Message Sent ! </div>"; }else { $msg = "<div class='alert alert-danger'> <span class='glyphicon glyphicon-info-sign'></span> Message not Sent! ! </div>"; } } } $DBcon->close();?> <?php php include_once 'footer.php'; ?> </html>
  3. Hi, I really need to find a way to print the code below in php. <script> $(document).ready(function() { $.sticky('The page has loaded!'); }); </script> i tried print"<script> $(document).ready(function() { $.sticky('The page has loaded!'); });"; </script> any help would be great.
  4. Hey guys, having a small problem which is probably so simple but my login isnt working it always comes back invalid login. I've posted both the login and index form below. anyone see the problem? <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="login.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Member Login </strong></td> </tr> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="myusername" type="text" id="user"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="mypassword" type="pass" id="pass"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Login"></td> </tr> </table> </td> </form> </tr> </table> <?php $host="localhost"; // Host name $username="thief"; // Mysql username $password="#####"; // Mysql password $db_name="thief_game"; // Database name $tbl_name="players"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $user=$_POST['user']; $pass=$_POST['pass']; // To protect MySQL injection (more detail about MySQL injection) $user = stripslashes($user); $pass = stripslashes($pass); $user = mysql_real_escape_string($user); $pass = mysql_real_escape_string($pass); $stat = mysql_fetch_array(mysql_query("select * from players where user='$user' and pass='$pass'")); if (empty ($stat[id])) { print "Invalid login."; } ?>
  5. thanks PFMaBiSmAd and cunoodle2, litebearer im not really that good with php to understand any of the code you provided, but thanks for trying to help..
  6. i have a cell in my database like Stats 100-10-3 and i want to update that with my code $details = 100 . '-' . 10 . '-' . 3; $sql = "UPDATE usertable SET uSkillsMax=$details"; but my database updates instead of 100-10-3 it says 87? which is doing the math? any way to fix this?
  7. SOLVED!!! LYLEYBOY THANK YOU SOO MUCH FOR YOUR HELP!!
  8. if i remove the statement should i get a fight list?
  9. new if statement reamined the same..
  10. if i remove the problem code that jumps the incorrect result the error i get it Fight Its time for action! Fight with rival thieves and grab their cash. You will require 1 strength for each fight and you will gain some cash and exp if you win the fight. However you will just earn some exp if you loose!! Each fight will decrease your health so keep an eye on health level because if your health goes below zero you will die and loose everything... 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 '' at line 1 IN SELECT * FROM `usertable` WHERE `userid`= postfight php <?php include '../header.php'; if( $_POST[action] == 'dofight' ) { $player = Player::getById($_POST[user]); if( $player->stamina <= 0 ) { $str = '<div class=noticeBox><P class=failP>Failure!</P><H2>You are not strong enough to fight against <fb:name uid="'.$_POST[opid].'" linked=false />! Try back later...</H2></div>'; } else if( $player->health < 20 ) { $str = '<div class=noticeBox><P class=failP>Failure!</P><H2>You are too weak to fight <fb:name uid="'.$_POST[opid].'" linked=false />! Try back later...</H2></div>'; } else { $str = do_fight( $_POST[user], $_POST[opid] ); } } include '../statusbar.php'; echo '<div id=contentBox>'; // Show Fight Result if( !empty($_GET[action]) AND $_GET[action]=='attack' ) { echo $str; } if( $_POST[action] == 'dofight' ) { echo $str; } // Fight Lists echo '<P class=pageheader>Fight</P>'; echo '<P>Its time for action! Fight with rival thieves and grab their cash. You will require 1 strength for each fight and you will gain some cash and exp if you win the fight. However you will just earn some exp if you loose!! Each fight will decrease your health so keep an eye on health level because if your health goes below zero you will die and loose everything...</P>'; $res = query("SELECT COUNT(*) FROM `usertable` WHERE `userid`!=$user"); list($total) = mysql_fetch_array($res); if( $total>0 ) { $res = query("SELECT * FROM `usertable` WHERE `userid`!=$user LIMIT 0,20"); echo '<center>'; echo '<table class="itemTable">'; while( $row = mysql_fetch_array($res) ) { $viewplayer = Player::getById($row[userid]); echo '<tr>'; echo '<td width=120px>'; echo '<P><B>Level:</B> '.$viewplayer->level.', '.get_level_title($player->level).'</P>'; echo '</td>'; echo '<td width=120px>'; echo '<P><B>Crew:</B> '.$viewplayer->crew.'</P>'; echo '</td>'; echo '<td width=300px>'; if( $viewplayer->health > 20 ) { echo '<form id="FightForm'.$row[userid].'" method="POST" class="itemForm">'; echo '<input type=hidden name=user value="'.$user.'">'; echo '<input type=hidden name=opid value="'.$row[userid].'">'; echo '<input type=hidden name=action value="dofight">'; echo '<P><input type=button onclick="do_submit(\'FightForm'.$row[userid].'\',\'http://www.bofs.us/thief/fight/post_fight.php\', \'actionDiv\'); return false;" value="Fight Now" class="submitButton" /></P>'; echo '</form>'; } else { echo '<P class=titleP>Too Weak To Fight</P>'; } echo '</td>'; echo '</tr>'; } echo '</table>'; echo '</center>'; } else { echo '<div class=noticeBox><h2>Sorry! No available member found!</h2></div>'; } echo '</div>'; // end of contentBox ?>
  11. the app is facebook based so i cannot see what the address bar would say, but surely It would still show the results from the db and users?
  12. seems exactly the same, no output from that echo..
  13. incase it matters, this is the fightinc <?php //==================================== // Do Fight //==================================== function do_fight( $u, $op ) { global $facebook; global $appCanvasUrl; global $appCallbackUrl; global $appTitle; $player1 = Player::getById($u); $player2 = Player::getById($op); // ================================================================================ // The User Part // ================================================================================ $userTotalAttPwr = 0; $userTotalDefPwr = 0; // ======================================== // Search and Count User Attack Weapons // ======================================== $res = query("SELECT COUNT(*) FROM `items_log` WHERE `userid`=$u AND (`itemType`=1 OR `itemType`=4 OR `itemType`=5)"); list($total) = mysql_fetch_array($res); if( $total>0 ) { $res = query("SELECT * FROM `items_log` WHERE `userid`=$u AND (`itemType`=1 OR `itemType`=4 OR `itemType`=5)"); while( $row = mysql_fetch_array($res) ) { $userTotalWep += $row[itemAmount]; } } if( $userTotalWep > 0 ) { if( $userTotalWep >= $player1->crew ) $userWepUse = $player1->crew; else $userWepUse = $userTotalWep; } else $userWepUse = 0; // ======================================== // Collect and Sort Attack Weapon Power // ======================================== if( $userTotalWep > 0 ) { $res = query("SELECT * FROM `items_log` WHERE `userid`=$u AND (`itemType`=1 OR `itemType`=4 OR `itemType`=5)"); $rows = 0; while( $row = mysql_fetch_array($res) ) { $item = Item::getById($row[itemId]); $userWepArray[$rows][id] = $item->id; $userWepArray[$rows][img] = $item->image; $userWepArray[$rows][att] = $item->att; $userWepArray[$rows][def] = $item->def; $rows++; if( $row[itemAmount] > 1 ) { for($i=0; $i<($row[itemAmount]-1); $i++ ) { $userWepArray[$rows][id] = $item->id; $userWepArray[$rows][img] = $item->image; $userWepArray[$rows][att] = $item->att; $userWepArray[$rows][def] = $item->def; $rows++; } } } // Sort The Array for( $j=0; $j<$userTotalWep; $j++ ) { for( $i=0; $i<($userTotalWep-1); $i++ ) { if( $userWepArray[$i][att] < $userWepArray[$i+1][att] ) { $tempArray = $userWepArray[$i]; $userWepArray[$i] = $userWepArray[$i+1]; $userWepArray[$i+1] = $tempArray; } } } $userWepArray = array_slice($userWepArray,0,$userWepUse); for( $i=0; $i<$userWepUse; $i++ ) { $userTotalAttPwr += $userWepArray[$i][att]; $userTotalDefPwr += $userWepArray[$i][def]; } } // ======================================== // Search and Count User Defense Weapons // ======================================== $res = query("SELECT COUNT(*) FROM `items_log` WHERE `userid`=$u AND `itemType`=2"); list($total) = mysql_fetch_array($res); if( $total>0 ) { $res = query("SELECT * FROM `items_log` WHERE `userid`=$u AND `itemType`=2"); while( $row = mysql_fetch_array($res) ) { $userTotalDef += $row[itemAmount]; } } if( $userTotalDef > 0 ) { if( $userTotalDef >= $player1->crew ) $userDefUse = $player1->crew; else $userDefUse = $userTotalDef; } else $userDefUse = 0; // ======================================== // Collect and Sort Defense Weapon Power // ======================================== if( $userTotalDef > 0 ) { $res = query("SELECT * FROM `items_log` WHERE `userid`=$u AND `itemType`=2"); $rows = 0; while( $row = mysql_fetch_array($res) ) { $item = Item::getById($row[itemId]); $userDefArray[$rows][id] = $item->id; $userDefArray[$rows][img] = $item->image; $userDefArray[$rows][att] = $item->att; $userDefArray[$rows][def] = $item->def; $rows++; if( $row[itemAmount] > 1 ) { for($i=0; $i<($row[itemAmount]-1); $i++ ) { $userDefArray[$rows][id] = $item->id; $userDefArray[$rows][img] = $item->image; $userDefArray[$rows][att] = $item->att; $userDefArray[$rows][def] = $item->def; $rows++; } } } // Sort The Array for( $j=0; $j<$userTotalDef; $j++ ) { for( $i=0; $i<($userTotalDef-1); $i++ ) { if( $userDefArray[$i][att] < $userDefArray[$i+1][att] ) { $tempArray = $userDefArray[$i]; $userDefArray[$i] = $userDefArray[$i+1]; $userDefArray[$i+1] = $tempArray; } } } $userDefArray = array_slice($userDefArray,0,$userDefUse); for( $i=0; $i<$userDefUse; $i++ ) { $userTotalAttPwr += $userDefArray[$i][att]; $userTotalDefPwr += $userDefArray[$i][def]; } } // ================================================================================ // Now The Opponents Part // ================================================================================ $opTotalAttPwr = 0; $opTotalDefPwr = 0; // ======================================== // Search and Count Opponents Attack Weapons // ======================================== $res = query("SELECT COUNT(*) FROM `items_log` WHERE `userid`=$op AND (`itemType`=1 OR `itemType`=4 OR `itemType`=5)"); list($total) = mysql_fetch_array($res); if( $total>0 ) { $res = query("SELECT * FROM `items_log` WHERE `userid`=$op AND (`itemType`=1 OR `itemType`=4 OR `itemType`=5)"); while( $row = mysql_fetch_array($res) ) { $opTotalWep += $row[itemAmount]; } } if( $opTotalWep > 0 ) { if( $opTotalWep >= $player2->crew ) $opWepUse = $player2->crew; else $opWepUse = $opTotalWep; } else $opWepUse = 0; // ======================================== // Collect and Sort Attack Weapon Power // ======================================== if( $opTotalWep > 0 ) { $res = query("SELECT * FROM `items_log` WHERE `userid`=$op AND (`itemType`=1 OR `itemType`=4 OR `itemType`=5)"); $rows = 0; while( $row = mysql_fetch_array($res) ) { $item = Item::getById($row[itemId]); $opWepArray[$rows][id] = $item->id; $opWepArray[$rows][img] = $item->image; $opWepArray[$rows][att] = $item->att; $opWepArray[$rows][def] = $item->def; $rows++; if( $row[itemAmount] > 1 ) { for($i=0; $i<($row[itemAmount]-1); $i++ ) { $opWepArray[$rows][id] = $item->id; $opWepArray[$rows][img] = $item->image; $opWepArray[$rows][att] = $item->att; $opWepArray[$rows][def] = $item->def; $rows++; } } } // Sort The Array for( $j=0; $j<$opTotalWep; $j++ ) { for( $i=0; $i<($opTotalWep-1); $i++ ) { if( $opWepArray[$i][att] < $opWepArray[$i+1][att] ) { $tempArray = $opWepArray[$i]; $opWepArray[$i] = $opWepArray[$i+1]; $opWepArray[$i+1] = $tempArray; } } } $opWepArray = array_slice($opWepArray,0,$opWepUse); for( $i=0; $i<$opWepUse; $i++ ) { $opTotalAttPwr += $opWepArray[$i][att]; $opTotalDefPwr += $opWepArray[$i][def]; } } // ======================================== // Search and Count User Defense Weapons // ======================================== $res = query("SELECT COUNT(*) FROM `items_log` WHERE `userid`=$op AND `itemType`=2"); list($total) = mysql_fetch_array($res); if( $total>0 ) { $res = query("SELECT * FROM `items_log` WHERE `userid`=$op AND `itemType`=2"); while( $row = mysql_fetch_array($res) ) { $opTotalDef += $row[itemAmount]; } } if( $opTotalDef > 0 ) { if( $opTotalDef >= $player2->crew ) $opDefUse = $player2->crew; else $opDefUse = $opTotalDef; } else $opDefUse = 0; // ======================================== // Collect and Sort Defense Weapon Power // ======================================== if( $opTotalDef > 0 ) { $res = query("SELECT * FROM `items_log` WHERE `userid`=$op AND `itemType`=2"); $rows = 0; while( $row = mysql_fetch_array($res) ) { $item = Item::getById($row[itemId]); $opDefArray[$rows][id] = $item->id; $opDefArray[$rows][img] = $item->image; $opDefArray[$rows][att] = $item->att; $opDefArray[$rows][def] = $item->def; $rows++; if( $row[itemAmount] > 1 ) { for($i=0; $i<($row[itemAmount]-1); $i++ ) { $opDefArray[$rows][id] = $item->id; $opDefArray[$rows][img] = $item->image; $opDefArray[$rows][att] = $item->att; $opDefArray[$rows][def] = $item->def; $rows++; } } } // Sort The Array for( $j=0; $j<$opTotalDef; $j++ ) { for( $i=0; $i<($opTotalDef-1); $i++ ) { if( $opDefArray[$i][att] < $opDefArray[$i+1][att] ) { $tempArray = $opDefArray[$i]; $opDefArray[$i] = $opDefArray[$i+1]; $opDefArray[$i+1] = $tempArray; } } } $opDefArray = array_slice($opDefArray,0,$opDefUse); for( $i=0; $i<$userDefUse; $i++ ) { $opTotalAttPwr += $opDefArray[$i][att]; $opTotalDefPwr += $opDefArray[$i][def]; } } // ================================================================================ // Power Comparison // ================================================================================ $userTotalAttPwr += $player1->attack; $userTotalDefPwr += $player1->defense; $opTotalAttPwr += $player2->attack; $opTotalDefPwr += $player2->defense; $userPoint = ($userTotalAttPwr - $opTotalDefPwr); $oponentPoint = ($opTotalAttPwr - $userTotalDefPwr); if( $userPoint > $oponentPoint ) { $str = '<div class=noticeBox><P class=successP>You Won!</P>'; if( $player2->cash > 0 ) $userCashEarn = rand(1,$player2->cash); else $userCashEarn = 0; $userExpEarn = rand(1,5); $userHealthLoss = rand(5,10); $oponentExpEarn = rand(1,5); $oponentHealthLoss = rand(5,10); $player1->cash += $userCashEarn; $player1->exp += $userExpEarn; $player1->stamina -= 1; $player1->health -= $userHealthLoss; $player1->win += 1; $player2->cash -= $userCashEarn; $player2->exp += $oponentExpEarn; $player2->health -= $oponentHealthLoss; $player2->lose += 1; $player1->save(); $player2->save(); // Stream Publish $message = 'won a fight at '.$appTitle.' and received $'.number_format($userCashEarn,0).' and '.$userExpEarn.' exp!'; $caption = 'Are you strong enough to fight?'; $desc = 'Join Whos The Thief, Become the master thief and show your tactics...'; $picture = $appCallbackUrl.'images/logo.png'; publishMyStream($message, $appTitle, $caption, $appCanvasUrl, $desc, $picture ); $logText = 'You won a fight against <fb:name uid='.$op.' useyou=false linked=false />. You earned <B>$'.number_format($userCashEarn,0).' cash</B> and '.$userExpEarn.' exp!'; add_news( $logText, $u ); $logText = 'You lost a fight against <fb:name uid='.$u.' useyou=false linked=false />. You lost <B>$'.number_format($userCashEarn,0).' cash</B> and earned <B>'.$oponentExpEarn.' exp</B>!'; add_news( $logText, $op ); } else { $str = '<div class=noticeBox><P class=failP>You Lost!</P>'; if( $player1->cash > 0 ) $oponentCashEarn = rand(1,$player1->cash); else $oponentCashEarn = 0; $userExpEarn = rand(1,5); $userHealthLoss = rand(5,10); $oponentExpEarn = rand(1,5); $oponentHealthLoss = rand(5,10); $player1->cash -= $oponentCashEarn; $player1->exp += $userExpEarn; $player1->stamina -= 1; $player1->health -= $userHealthLoss; $player1->lose += 1; $player2->cash += $oponentCashEarn; $player2->exp += $oponentExpEarn; $player2->health -= $oponentHealthLoss; $player2->win += 1; $player1->save(); $player2->save(); // Stream Publish $message = 'lost a fight at '.$appTitle.' and lost $'.number_format($oponentCashEarn,0).'!'; $caption = 'Are you strong enough to fight?'; $desc = 'Join Whos The Thief, Become the master thief and show your tactics...'; $picture = $appCallbackUrl.'images/logo.png'; publishMyStream($message, $appTitle, $caption, $appCanvasUrl, $desc, $picture ); $logText = 'You lost a fight against <fb:name uid='.$op.' useyou=false linked=false />. You lost <B>$'.number_format($oponentCashEarn,0).' cash</B> and earned <B>'.$userExpEarn.' exp</B>!'; add_news( $logText, $u ); $logText = 'You won a fight against <fb:name uid='.$u.' useyou=false linked=false />. You earned <B>$'.number_format($oponentCashEarn,0).' cash</B> and <B>'.$oponentExpEarn.' exp</B>!'; add_news( $logText, $op ); } $str .= '<table class="fightTable">'; $str .= '<tr>'; $str .= '<td width=50% valign=top>'; $str .= '<table class="fightTable">'; $str .= '<tr>'; $str .= '<td width=60px><P><fb:profile-pic uid='.$u.' size=square linked=false /></P></td>'; $str .= '<td>'; $str .= '<P class=titleP><fb:name uid='.$u.' linked=false /></P>'; if( $player1->charname != "" ) $str .= '<P>'.$player1->charname.'</P>'; $str .= '<P>Crew: '.$player1->crew.'</P>'; $str .= '</td>'; $str .= '</tr>'; $str .= '</table>'; $str .= '<td width=50% valign=top>'; $str .= '<table class="fightTable">'; $str .= '<tr>'; $str .= '<td>'; $str .= '<P class=rightTitleP><fb:name uid='.$op.' linked=false /></P>'; if( $player2->charname != "" ) $str .= '<P class=rightP>'.$player2->charname.'</P>'; $str .= '<P class=rightP>Crew: '.$player2->crew.'</P>'; $str .= '</td>'; $str .= '<td width=60px><P><fb:profile-pic uid='.$op.' size=square linked=false /></P></td>'; $str .= '</tr>'; $str .= '</table>'; $str .= '</td>'; $str .= '</tr>'; $str .= '<tr>'; $str .= '<td width=50% valign=top>'; $str .= '<table class="fightTable">'; $str .= '<tr><td colspan=5><P class=titleP>Offensive Items</P></td></tr>'; $str .= '<tr>'; if( $userWepUse>0 ) { for( $i=0; $i<$userWepUse; $i++ ) { $item = Item::getById($userWepArray[$i][id]); $str .= '<td><img src="'.$appCallbackUrl.'images/items/'.$item->image.'" class="imgbox" width=50 height=50>'; $totalUse = 1; for( $j=$i; $j<$userWepUse; $j++ ) { if( $userWepArray[$i][id] == $userWepArray[$i+1][id] ) { $totalUse++; $i++; } } $str .= '<P>X'.$totalUse.'</P></td>'; } } else { $str .= '<td colspan=5><P>You had no offensive item and faught with empty hands!</P></td>'; } $str .= '</tr>'; $str .= '<tr><td colspan=5><P class=titleP>Defensive Items</P></td></tr>'; $str .= '<tr>'; if( $userDefUse>0 ) { for( $i=0; $i<$userDefUse; $i++ ) { $item = Item::getById($userDefArray[$i][id]); $str .= '<td><img src="'.$appCallbackUrl.'images/items/'.$item->image.'" class="imgbox" width=50 height=50>'; $totalUse = 1; for( $j=$i; $j<$userDefUse; $j++ ) { if( $userDefArray[$i][id] == $userDefArray[$i+1][id] ) { $totalUse++; $i++; } } $str .= '<P>X'.$totalUse.'</P></td>'; } } else { $str .= '<td colspan=5><P>You had no defensive item and faught with empty hands!</P></td>'; } $str .= '</tr>'; $str .= '</table>'; $str .= '</td>'; $str .= '<td valign=top align=right>'; $str .= '<table class="fightTable">'; $str .= '<tr><td colspan=5><P class=rightTitleP>Offensive Items</P></td></tr>'; $str .= '<tr>'; if( $opWepUse>0 ) { for( $i=0; $i<$opWepUse; $i++ ) { $item = Item::getById($opWepArray[$i][id]); $str .= '<td align=right><img src="'.$appCallbackUrl.'images/items/'.$item->image.'" class="imgbox" width=50 height=50>'; $totalUse = 1; for( $j=$i; $j<$opWepUse; $j++ ) { if( $opWepArray[$i][id] == $opWepArray[$i+1][id] ) { $totalUse++; $i++; } } $str .= '<P>X'.$totalUse.'</P></td>'; } } else { $str .= '<td colspan=5><P class=rightP><fb:name uid="'.$op.'" firstnameonly=true linked=false /> had no offensive item and faught with empty hands!</P></td>'; } $str .= '</tr>'; $str .= '<tr><td colspan=5><P class=rightTitleP>Defensive Items</P></td></tr>'; $str .= '<tr>'; if( $opDefUse>0 ) { for( $i=0; $i<$opDefUse; $i++ ) { $item = Item::getById($opDefArray[$i][id]); $str .= '<td align=right><img src="'.$appCallbackUrl.'images/items/'.$item->image.'" class="imgbox" width=50 height=50>'; $totalUse = 1; for( $j=$i; $j<$opDefUse; $j++ ) { if( $opDefArray[$i][id] == $opDefArray[$i+1][id] ) { $totalUse++; $i++; } } $str .= '<P>X'.$totalUse.'</P></td>'; } } else { $str .= '<td colspan=5><P class=rightP><fb:name uid="'.$op.'" firstnameonly=true linked=false /> had no defensive item and faught with empty hands!</P></td>'; } $str .= '</tr>'; $str .= '</table>'; $str .= '</td>'; $str .= '</tr>'; $str .= '<tr>'; $str .= '<td>'; $str .= '<BR><P class=successP><font size=4>Rewards!</font></P>'; if( $userPoint > $oponentPoint ) { $str .= '<P class=titleP>+ $'.number_format($userCashEarn,0).'</P>'; $str .= '<P class=titleP>+ '.number_format($userExpEarn,0).' exp</P>'; } else { $str .= '<P class=titleP>- $'.number_format($oponentCashEarn,0).'</P>'; $str .= '<P class=titleP>+ '.number_format($userExpEarn,0).' exp</P>'; } $str .= '</td>'; $str .= '<td>'; $str .= '<form id="DoFightForm" method="POST" class="itemForm">'; $str .= '<input type=hidden name=user value="'.$u.'">'; $str .= '<input type=hidden name=opid value="'.$op.'">'; $str .= '<input type=hidden name=action value="dofight">'; $str .= ' <input type=button onclick="do_submit(\'DoFightForm\',\'http://www.bofs.us/thief/fight/post_fight.php\', \'actionDiv\'); return false;" value="Fight Again" class="submitButton" /></P>'; $str .= '</form>'; $str .= '</td>'; $str .= '</tr>'; $str .= '</table>'; $str .= '</div>'; return $str; } ?>
  14. tried echoing it and it's not bringing up anything at all.. echo $_GET["action"]=='attack'; db uid userid uCash uBankCash uPoint uSkillsMax uSkills uAttr uCharName uCharType uStat 1 100000917825988 2990 0 0 100-10-3 100-10-3-10-10 1-32-1-10 1 8-0-0-0-0 6 100000180079544 570 0 0 100-10-3 100-10-3-10-10 1-2-1-10 1 1-0-0-0-0
  15. i have a game script and it's always bringing back the same result and i cant see why.. all i get when the script it ran is [/code]echo '<div class=noticeBox><h2>Sorry! No available member found![/code] the code is below and can provide the functions and db if needed, but cant see what's wrong. <?php include '../header.php'; echo '<div id=AjaxSubDiv>'; echo '<div id="actionDiv">'; include '../statusbar.php'; echo '<div id=contentBox>'; // Show Fight Result if( !empty($_GET[action]) AND $_GET[action]=='attack' ) { echo $str; // Fight Lists echo '<P class=pageheader>Fight</P>'; echo '<P>Its time for action! Fight with rival thieves and grab their cash. You will require 1 strength for each fight and you will gain some cash and exp if you win the fight. However you will just earn some exp if you loose!! Each fight will decrease your health so keep an eye on health level because if your health goes below zero you will die and loose everything...</P>'; $res = query("SELECT COUNT(*) FROM `usertable` WHERE `userid`!=$user"); list($total) = mysql_fetch_array($res); if( $total>0 ) { $res = query("SELECT * FROM `usertable` WHERE `userid`!=$user LIMIT 0,20"); $viewplayer = Player::getById($row[userid]); echo '<tr>'; echo '<td width=120px>'; echo '<P class=titleP><a href="#" onclick="load_menu_val(\'AjaxSubDiv\', \'profile\', '.$row[userid].');return false;"><fb:profile-pic uid="'.$row[userid].'" size="square" linked="false" width="75px" class="userImg" /></a></P>'; echo '<P class=titleP><a href="#" onclick="load_menu_val(\'AjaxSubDiv\', \'profile\', '.$row[userid].');return false;"><fb:name uid="'.$row[userid].'" linked="false" /></a></P>'; echo '</td>'; echo '<td width=120px>'; echo '<P><B>Level:</B> '.$viewplayer->level.', '.get_level_title($player->level).'</P>'; echo '</td>'; echo '<td width=120px>'; echo '<P><B>Crew:</B> '.$viewplayer->crew.'</P>'; echo '</td>'; echo '<td width=300px>'; if( $viewplayer->health > 20 ) { echo '<form id="FightForm'.$row[userid].'" method="POST" class="itemForm">'; echo '<input type=hidden name=user value="'.$user.'">'; echo '<input type=hidden name=opid value="'.$row[userid].'">'; echo '<input type=hidden name=action value="dofight">'; echo '<P><input type=button onclick="do_submit(\'FightForm'.$row[userid].'\',\'http://www.bofs.us/thief/thiefmaster/fight/post_fight.php\', \'actionDiv\'); return false;" value="Fight Now" class="submitButton" /></P>'; echo '</form>'; } else { echo '<P class=titleP>Too Weak To Fight</P>'; } echo '</td>'; echo '</tr>'; } echo '</table>'; echo '</center>'; } else { echo '<div class=noticeBox><h2>Sorry! No available member found!</h2></div>'; print"$res"; } echo '</div>'; // end of contentBox echo '</div>'; // end of actiondiv echo '</div>'; // end of AjaxSubDiv ?>
  16. tried that and the same 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 '' at line 1 IN SELECT * FROM `usertable` WHERE `userid`=
  17. also sorry the query function query($q) { global $conn; $result = mysql_query($q, $conn); } return $result;
  18. Hey guys, i'm sure this is simple i have a script that always brings back the same error and I beleive it's going to be the php version im on the code is function check_user( $u ) { $res = query("SELECT COUNT(*) FROM `usertable` WHERE `userid`=$u"); list($total_rows) = mysql_fetch_array($res) or die (mysql_error()); if( $total_rows > 0 ) return true; else return false; } the error is Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/bofs/public_html/thief/inc/userinc.php on line 10 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 '' at line 1 any idea's
  19. still the same after a few days anyone?
  20. Tried a few things and still no joy with the above, so here's a copy of the database too id band parent time post author 2 0 0 1289311197 Hey johhny b, welcome! 1
  21. Below is a peice of code for my in game chat system and it works okay, but i would like a few things and i'm not sure of how to go about it. 1. the most recent post to be on top i beleive i might be able to do that with the time stamp i have. 2. when people post a comment for the line spaces to show up? (simple but im not sure how) 3. when it's a set user ie = playerx the font colour to be different. if anyone could help i'd be thankful. <?php if ($sc == "") { diver ('Battle Of Species Global Game Talk'); $sql3 = "UPDATE users SET gamechat=0 where id=$userid"; mysql_query($sql3); echo '<center><BR>[<a href="index.php?cmd=chat&sc=chatadd">Add Post</a>]</center><BR><BR>'; $sql = "SELECT id FROM comm2 WHERE parent=0 ORDER BY `time` DESC"; $r = mysql_query($sql); while ($row = mysql_fetch_row($r)) { echo '<table border="0"><tr><td>'; showMessage($row[0], 0,$b); echo '</td></tr></table><BR><BR>'; } }else if ($sc =="chatadd") { diver ('Enter Your Post Below'); echo '<center>'; echo '<form method="post" action="index.php?cmd=chat&sc=chatadd2">'; echo '<input type="hidden" name="inPar" value="'.$inPar.'">'; echo '<textarea rows="10" cols="45" name="inText" style="'.$boxStyle.'"></textarea><BR><BR><input type="submit" value="Post">'; echo '</form></center>'; }else if ($sc == "chatadd2") { diver ("Message Posted"); $inText = clean($inText); $sql = sprintf("INSERT INTO comm2 (author,parent,time,post) VALUES ('%s','%s','".time()."','%s')", mysql_real_escape_string($userid), mysql_real_escape_string($inPar), mysql_real_escape_string($inText)); mysql_query($sql); $sql2 = "UPDATE users SET gamechat=1"; mysql_query($sql2); echo '<BR><BR><center>You message has been posted!<BR>[<a href="index.php?cmd=chat">Back to Game Chat</a>]'; } function showMessage($m, $l, $b) { global $prefDate; echo '<table border="0" style="font-famile: Verdana; font-size: 12px" cellpadding="4"><tr>'; for ($i = 0; $i < $l; $i++) { echo '<td> </td>'; } echo '<td>'; $sql = "SELECT `post`,`author`,`id`,`time` FROM `comm2` WHERE `id`='{$m}'"; $r = mysql_query($sql); $row = mysql_fetch_row($r); $row[0] = '<B>'.getvalue($row[1],'handle').'</B><BR>'. $row[0]; $row[0] .= '<BR>[<a href="index.php?cmd=chat&sc=chatadd&inPar='.$row[2].'">Reply</a>] [Posted: '. date($prefDate,$row[3]) .']'; echo str_replace(' ','<BR>',$row[0]); echo '</td></tr></table>'; $sql = "SELECT id FROM comm2 WHERE parent={$m} ORDER BY time DESC"; $r = mysql_query($sql); while ($row = mysql_fetch_row($r)) { showMessage($row[0], $l + 1, $b); } } [code]
  22. is this statement right? it doesnt seem to work. $sql = "SELECT id FROM units WHERE class=".getUnitClass($i);
  23. Working on it all day now and still no further forward it's only the 3rd team that doesnt show any percent at all and i don't see what im missing. i've attached the whole build file <?php if ($sc == "") { echo gloss("title", $teamid) .', Welcome to your <B>' . gloss("barracks",$teamid) . '</B>! This is where you control how much of each type of unit your army produces per turn spent.'; echo '<BR><BR>'; diver ("Construct Unit Buildings"); echo ' You may build several structures, each structure will then produce certain units of that class every time you spend a turn. To learn what type of units each structure produces and how much, scroll to the building output rate section below. The cost for constructing buildings is <B>1 turn per building</B>.'; $sql = "SELECT id,building,name FROM classes WHERE team={$teamid}"; $r = mysql_query($sql) or die (mysql_error()); echo '<form method="post" action="index.php?cmd=build&sc=do">'; echo '<center><table border="0" width="400" bordercolorlight="#808080" bordercolordark="#808080" style="border-collapse: collapse; font-family: Verdana; font-size: 12px" cellspacing="2" cellpadding="2">'; echo '<tr><td bgcolor="#C0C0C0" align="center"><font face="Verdana" color="#000000" size="2"><b>Building</b></font></td><td bgcolor="#C0C0C0" align="center"><font face="Verdana" color="#000000" size="2"><b>You Have</b></font></td><td bgcolor="#C0C0C0" align="center"><b><font face="Verdana" color="#000000" size="2">Build Amount</font></b></td></tr>'; while ($row = mysql_fetch_row($r)) { echo '<tr><td><font color="#FFFFFF"><B>'.$row[1].'</B><BR><font size="1">Produces: <B>'.$row[2].'</B></font></font></td>'; echo '<td align="center">'.number_format(getBuildCount($userid,$row[0])).'</td>'; echo '<td align="center"><input type="text" name="a'.$row[0].'" size="10" style="'.$boxStyle.'" value="0"></td></tr>'; } echo '<tr><td colspan="3" align=center><input type="submit" value="Construct"></td></tr>'; echo '</table></center></form>'; diver ("Building Output Rates"); echo "From here, you can control how much of each type of unit your buildings make, each building must add up to 100% output.<BR>"; $sql = "SELECT id,building FROM classes WHERE team={$teamid}"; $r = mysql_query($sql) or die (mysql_error()); echo '<center>'; while ($row = mysql_fetch_row($r)) { echo '<form method="post" action="index.php?cmd=build&sc=rate&bid='.$row[0].'">'; echo '<table border="0" width="300" bordercolorlight="#808080" bordercolordark="#808080" style="border-collapse: collapse; font-family: Verdana; font-size: 12px" cellspacing="2" cellpadding="2">'; echo '<tr><td bgcolor="#C0C0C0" align="center"><font face="Verdana" color="#000000" size="2"><b>'.$row[1].' units</b></font></td><td bgcolor="#C0C0C0" align="center"><font face="Verdana" color="#000000" size="2"><b>Output Rate</b></font></td></tr>'; $sql = "SELECT id,name FROM units WHERE class={$row[0]} AND visible=1"; $r2 = mysql_query($sql) or die (mysql_error()); while ($row2 = mysql_fetch_row($r2)) { echo '<tr><td align="center">'.$row2[1].'</td><td align="center"><input text="text" size="5" style="'.$boxStyle.'" name="a'.$row2[0].'" value='.getRate($userid,$row2[0]).'>%</td></tr>'; } echo '<tr><td colspan="2" align="center"><input type="submit" value="Set Rates for '.$row[1].'"></td></tr>'; echo '</table></form>'; } echo '</center>'; }else if ($sc == "do") { $sql = "SELECT id FROM classes WHERE team={$teamid}"; $r = mysql_query($sql) or die (mysql_error()); $tot = 0; while ($row = mysql_fetch_row($r)) { $cur = 'a' . $row[0]; $$cur = round($$cur); $$cur += 0; $$cur = max(0,$$cur); $pass[$row[0]] = $$cur; $tot += $$cur; } if ($tot > getValue($userid, turns)) { echo '<center><B>You do not have enough turns to construct these buildings.</B><BR>[<a href="index.php?cmd=build">Back to '.gloss('barracks', $teamid).'</a>]'; }else { echo '<center><B>Buildings constructed</b><BR>[<a href="index.php?cmd=build">Back to '.gloss('barracks', $teamid).'</a>]<BR>'; spendTurns($userid, $tot, $teamid, $pass); $sql = "SELECT id FROM classes WHERE team={$teamid}"; $r = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_row($r)) { $cur = 'a' . $row[0]; makeBuildings($userid, $row[0], $$cur); } } }else if ($sc == "rate") { $sql = "SELECT id FROM units WHERE class={$bid}"; $r = mysql_query($sql) or die (mysql_error()); $tot = 0; while ($row = mysql_fetch_row($r)) { $cur = 'a' . $row[0]; $$cur = max(0,$$cur); $tot += $$cur; } if ($tot != 100) { echo '<center><B>Output rates do not add up to 100%.</B><BR>[<a href="index.php?cmd=build">Back to '.gloss('barracks', $teamid).'</a>]'; }else { echo '<center><B>Output rates have been set!</B><BR>[<a href="index.php?cmd=build">Back to '.gloss('barracks', $teamid).'</a>]'; $sql = "SELECT id FROM units WHERE class={$bid}"; $r = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_row($r)) { $cur = 'a' . $row[0]; setRate($userid, $row[0], $$cur); } } } ?> [code]
  24. doesn't really matter, it's easier to make the php script then echo the html eg echo'<html>'; echo'<head>';
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.