Jump to content

jcbones

Staff Alumni
  • Posts

    2,653
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by jcbones

  1. http://php.net/manual/en/function.highlight-string.php I believe that is the function you are looking for.
  2. Please try again, and put any code in code blocks.
  3. Just for fun: <?php $content = <<<'NOWDOC' <html> <head> <title>Form Test</title> NOWDOC; if(isset($_POST['Submit1'])) { $city = (!empty($_POST['City']) && strtolower($_POST['City']) == 'new york') ? 'Cool City!' : 'Try Another City'; } $content = <<<HEREDOC </head> <body> <FORM NAME ="City Searcher" METHOD ="POST" ACTION = ""> <INPUT TYPE = "TEXT" NAME = "City" VALUE = "City"> <INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Search"> </FORM> <br /><span style="color:red;font-size:200%">{$city}</span> </body> </html> HEREDOC; echo $content; ?> Only works in >= PHP5.3.0
  4. I see why you are having trouble. There is no possible way for you to know what the name of the input elements are. You should re-think you logic of how you are going to retrieve these fields. I would suggest something along the lines of: <?php if(isset($_POST['Add'])) { foreach($_POST['product'] as $key => $value) { if(!empty($value)) { echo 'Index: ' . $key . ' has a value:' . $value . "<br />\n"; } } } ?> <form action="#" method="post"> <input name="product[<?php echo $pid; ?>]" placeholder="Name" /> <input type="submit" name="Add" value="Submit Changes"> </form> This way you will know that you have a product line, and the pid is the index of that input element. If you add it to a loop, just increment the pid.
  5. What is wrong with it, is that you have not posted where $dataError['answer'] is coming from. Therefore, we cannot tell how it is populated. Also, if it is a dataError it should nor would ever in any possibility contain the same as SESSION['answer'] UNLESS you code your errors to the answer index of the SESSION array.
  6. Change: mysql_query($query); To: mysql_query($query) or trigger_error($query . ' has encountered an error.<br />' . mysql_error()); Make sure you have errors at max, and display errors on. Top of script (right after opening <?php tag). Add: error_reporting(E_ALL); ini_set('display_errors',1);
  7. Without providing a script and all of it's elements there is absolutely no way anyone could help you. The reason is, we would need to know how the form that submits the data is coded, and all of the data sanitation and validation that is going with it. We also need to see what you are trying to do, so that we could go along with the logic. You can say what it is doing, but a lot of times your code will be loaded on a test server for testing (when someone is being nice). However, in this instance, the form is being asked for, so the poster can see why you are getting a multi-dimensional array from it.
  8. Instead of: if(isset($_SESSION['answer']) && $dataError['answer'] == '') { Why can't you do: if(!empty($_POST['answer']) && $_POST['answer'] != $_SESSION['answer']) { //suggested by MasterACE14
  9. I was being stupid, and didn't put the argument in the function. if(mysql_num_rows($result) > 0) {
  10. file_get_contents() can use ssl connection. You can pass that in through the 3rd argument. http://www.php.net/manual/en/function.file-get-contents.php It will take a bit of reading for you to get it in there though. You will also have to provide a file location of your certificate. As well as use other functions. http://www.php.net/manual/en/function.stream-context-create.php http://www.php.net/manual/en/context.ssl.php
  11. That is valid syntax, if it doesn't work, it is because of the contents of a variable, or a table. Do NOT combine query functions, as you have no control of de-bugging when you do. $sql = "SELECT * FROM data WHERE `surname` = '$dc_sur' and `dob` = '$dc_dob'"; $result = mysql_query($sql) or trigger_error($sql . ' has an error.<br />' . mysql_error()); if(mysql_num_rows() > 0) { // Code inside if block if surname and date of birth is already there include "duplicate.php"; exit(); } Are you sure that the data exists in the table?
  12. jcbones

    form

    If value is NOT set, then the name is sent instead. <option value"female">Female</option> //valid, and female is sent. <option>Male</option> //valid, and Male is sent. Common mis-conception, and valid syntax that I see "corrected" many times. http://www.w3.org/MarkUp/html-spec/html-spec_8.html The problem here is the fact that you didn't provide a name for the select element. <select name="sex"> Without that, no index in the POST array will be present.
  13. Add de-bugging to your query call. mysql_query("INSERT INTO `user_pictures` VALUES ('$username', '$title', '$about', '$pic')") or trigger_error(mysql_error());
  14. This stands out for me. A variable is only as good as it's last defined value. Here you have it defined as an invalid string. If you echo'd the expiry variable, you would find it prints out. 2011201120112011-0808-1212 Instead of the expected. 2011-08-12. You did have it right in earlier codings. $expiry = date('Y-m-d',$timestamp);
  15. You will only get one row, unless you put the mysql_fetch function in a while loop.
  16. You could also use the mysql built in date function to do it as well. $get_shows = mysql_query("SELECT * FROM shows WHERE front_page_featured = '1' AND `date_field`>= CURDATE() ORDER BY position ASC"); http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html
  17. Then: $fullName = 'kyle cribbs' $name = explode(' ', $fullName); foreach($name as $value) { $search[] = "`name` LIKE '%$value%'"; } $sql = "SELECT * FROM `users` WHERE " . implode(' OR ', $search); //name LIKE '%kyle%' OR name LIKE '%cribbs%'
  18. Any of the first 4 links will help you.
  19. Notated what I fixed: Try this: <html> <body> <?php $mirror_list = array( 0 => array('2Shared','http://www.2shared.com/file/upMd2rqD/Dunno_Client.html','December 8th 2010') ); switch($query){ case "highscores": $grabskill = isset($_GET['skill']) ? trim(strtolower($_GET['skill'])) : null; $search_type = isset($_GET['type']) && $_GET['type'] == 1 ? 1 : 0; $user_search = empty($_GET['user']) ? null : ((strlen($_GET['user']) <= 20 && $search_type == 0 || strlen($_GET['user']) <= 11 & $search_type == 1) ? $_GET['user']: null); echo "<form method='get' action=''><input type='hidden' name='query' value='highscores' /><input type='hidden' name='type' value='1' /><div class='table'><div class='header'><img src='infrastructure/content/images/Character Search.png'></div></br></br><div class='content'><table><tr><td style='width:30%;'><font face=Times New Roman color=#FFFFFF>Enter character name:</font></td><td style='width:50%;text-align:center;'><input type='text' name='user' maxlength='11' value='" . (($search_type == 1 && isset($user_search)) ? $user_search : null) . "' /></td><td style='text-align:right;width:20%;'><input type='submit' value='Search' /></td></tr></table></div></div></form>"; if(isset($user_search)){ $queryLine = ($search_type == 1) ? $db->query("SELECT rsca2_players.owner, rsca2_players.combat, rsca2_players.username, rsca2_players.creation_date, rsca2_players.login_date, rsca2_experience.*, users.username AS 'account_name' FROM rsca2_players JOIN users ON rsca2_players.owner = users.id JOIN rsca2_experience ON rsca2_players.user = rsca2_experience.user WHERE rsca2_players.username = '" . $db->escape($user_search) . "' LIMIT 0 , 1") : $db->query("SELECT rsca2_players.owner, rsca2_players.combat, rsca2_players.username, rsca2_players.creation_date, rsca2_players.login_date, rsca2_experience.*, users.username AS 'account_name' FROM rsca2_players JOIN users ON rsca2_players.owner = users.id JOIN rsca2_experience ON rsca2_players.user = rsca2_experience.user WHERE rsca2_players.user = '" . $db->escape($user_search) . "' LIMIT 0 , 1"); $userdata = $db->fetch_assoc($queryLine); if(isset($userdata['id'])){ echo "<div class='table'><div class='header'>" . ucfirst($userdata['username']) . "'s Account Info</div><div class='content'><table><tr><td style='width:50%;'>Character Name</td><td>" . ucfirst($userdata['username']) . "</td></tr><tr><td style='width:50%;'>Account Name</td><td><a href='" . PUN_ROOT . "profile.php?id=" . $userdata['owner'] . "'>" . $userdata['account_name'] . "</a></td></tr><tr><td style='width:50%;'>Combat</td><td>" . $userdata['combat'] . "</td></tr><tr><td>Character Registered</td><td>" . date("M d Y", $userdata['creation_date']) . "</td></tr><tr><td>Last Login</td><td>" . date("M d Y", $userdata['login_date']) . "</td></tr></table></div></div>"; echo "<div class='table'><div class='header'>" . ucfirst($userdata['username']) . "'s Skill Sheet</div><div class='content'><a style='display:block;text-align:right;' href='?query=highscores'>Go back to highscores?</a><br />"; if($userdata['highscoreopt'] == 1){ echo "This user has chose to hide their skills."; } else { echo "<table><tr><td style='width:50%;'>Skill</td><td style='width:25%;'>Level</td><td style='width:25%;'>Experience</td></tr>"; for($i=0; $i < count($skills); $i++){ echo"<tr><td><a href='?query=highscores&skill=" . $skills[$i] . "'><img src='" . $web_data['b_img'] . "highscores/" . $skills[$i] . ".png' alt='X' /> " . ucfirst($skills[$i]) . "</a></td><td>" . experience_to_level($userdata['exp_' . $skills[$i]]) . "</td><td>" . number_format($userdata['exp_' . $skills[$i]]) . "</td></tr>"; } echo "</table>"; } echo"</div></div>"; } else { echo createTable("This user does not exist. <a href='?query=highscores'>Go back to highscores?</a>"); } } else { echo "<div class='table'><div class='header'><img src='infrastructure/content/images/Highscores2.png'></div></br></br><div class='content'><table>"; for($i = 1; $i < count($skills); $i++){ echo (($i == 1) ? "\n<tr>\n" : null) . "<td><a href='?query=highscores&skill=" . $skills[($i - 1)] . "'><img src='" . $web_data['b_img'] . "highscores/" . $skills[($i - 1)] . ".png' alt='x' />" . ucfirst($skills[($i - 1)]) . "</a></td>\n" . (($i > 0 && $i % 4 == 0) ? "\n</tr>\n<tr>\n" : null); } echo "\n<td><a href='?query=highscores&skill=skill_total'> Skill Total</a></td><td><a href='?query=highscores&skill=combat'> Combat</a></td><td> </td></tr></table></div></div>\n\n"; if(in_array($grabskill, $skills) || $grabskill == 'combat' || $grabskill == 'skill_total'){ (int)$startRow = isset($_GET['startrow']) && $_GET['startrow'] > 0 && $_GET['startrow'] % 20 == 0 ? $_GET['startrow'] : 0; $HS_QueryLine = ($grabskill == 'skill_total' ? "SELECT skill_total,user,username FROM rsca2_players ORDER BY skill_total DESC" : ($grabskill == 'combat' ? "SELECT username,user,combat FROM rsca2_players ORDER BY combat DESC" : "SELECT DISTINCT(rsca2_experience.user), rsca2_experience.highscoreopt, rsca2_experience.exp_" . $grabskill . ", rsca2_players.username FROM rsca2_experience JOIN rsca2_players ON rsca2_experience.user = rsca2_players.user WHERE rsca2_experience.highscoreopt = 0 AND rsca2_experience.exp_" . $grabskill . " > 0 ORDER BY rsca2_experience.exp_" . $grabskill . " DESC")); $generateHSList = $db->query($HS_QueryLine . " LIMIT " . $startRow . ", 20"); echo "<div class='table'><div class='header'><table><tr><td style='width:70%;text-align:left;'>Skill Table for " . str_replace("_", " ", ucfirst($grabskill)) . "</td><td style='width:30%;text-align:right;'><a href='?query=highscores'>Close</a></td></tr></table></div><div class='content'>"; if($db->num_rows($generateHSList) == 0){ echo "No results found for this particular skill."; } else { $i = $startRow + 1; $getTotalRows = $db->num_rows($db->query($HS_QueryLine)); $nextUp = (($startRow - 20) < 0) ? 0 : $startRow - 20; $nextDown = (($startRow + 20) > $getTotalRows) ? 0 : $startRow + 20; echo "<table><tr><td style='width:5%;'> </td><td style='width:55%;'>Username</td>" . ($grabskill == 'skill_total' ? "<td style='width:20%;'>Skill total</td><td> </td>" : ($grabskill == 'combat' ? "<td style='width:20%;'>Combat</td><td> </td>" : "<td style='width:20%;'>Level</td><td style='width:20%;'>Experience</td>")) . "</tr><tr><td colspan='4' style='height:22px;text-align:right;'>" . (($nextUp == 0 && $nextDown == 20 || $nextUp == 0 && $nextDown == 0) ? " " : "<a href='?query=highscores&skill=" . $grabskill . "&startrow=" . $nextUp . "'><img src='" . $web_data['b_img'] . "/arrow_up.png' alt='^' /></a>") . "</td></tr>"; while($r = $db->fetch_assoc($generateHSList)){ echo "<tr><td>" . (($i <= 5) ? "<span style='font-weight:bold;'>" . $i . "</span>" : $i) . "</td><td><a href='?query=highscores&user=" . $r['user'] . "'>" . ucfirst($r['username']) . "</a></td> " . ($grabskill == 'skill_total' ? "<td>" . number_format($r['skill_total']) . "</td><td> </td>" : ($grabskill == 'combat' ? "<td>" . $r['combat'] . "</td><td> </td>" : "<td>" . experience_to_level($r['exp_' . $grabskill]) . "</td><td>" . number_format($r['exp_' . $grabskill]) . "</td>")) . "</tr>"; $i ++; } echo (($getTotalRows > 20) ? "<tr><td colspan='4' style='text-align:right;'><a href='?query=highscores&skill=" . $grabskill . "&startrow=" . $nextDown . "'><img src='" . $web_data['b_img'] . "/arrow_down.png' alt='V' /></a></td></tr>" : null) . "</table>"; } echo "</div></div>"; } } break; case "players_online": $getMembers = $db->query("SELECT * FROM rsca2_players WHERE loggedin = 1 ORDER BY group_id DESC"); $countMembers = $db->num_rows($getMembers); echo "<div class='table'><div class='header'>Players Online (" . $countMembers . ")</div><div class='content'>"; if($countMembers > 0){ $i = 0; while($doQuery = $db->fetch_assoc($getMembers)){ switch($doQuery['group_id']){ case 3: echo "<img src='" . $web_data['b_img'] . "/mod/pmd.png' alt='[PMod]' />"; break; case 2: echo "<img src='" . $web_data['b_img'] . "/mod/mod.png' alt='[Mod]' />"; break; case 1: echo "<img src='" . $web_data['b_img'] . "/mod/adm.png' alt='[admin]' />"; break; default: break; } echo "<a href='?query=highscores&lookup=" . $doQuery['user'] . "'>" . $doQuery['username'] . "</a>"; if(($i + 1) == $countMembers){} else { echo ", "; } $i++; } } else { echo "There is currently no registered users logged in game."; } echo "</div></div>"; break; case "cms": if($pun_user['is_guest']){ echo $mustBeLoggedIn; } else { $totalchars = $db->num_rows($db->query("SELECT * FROM rsca2_players WHERE owner = '" . $pun_user['id'] . "'")); $switchAct = isset($_GET['act']) ? strtolower(trim($_GET['act'])) : null; $cmsPre = "<div class='table'><div class='header'>CMS Response</div><div class='content'>"; $cmsSuf = "</div></div>"; echo "<div id='characterMS'> <div class='table'> <div class='header'><img src='infrastructure/content/images/Character Management System.png'></div> <div class='content'> </br> </br> </br> <center><font size=4 face=Times New Roman color=#650c0c>Y</font><font size=3 face=Times New Roman color=#FFFFFF>ou are limited to <font size=3 face=Times New Roman color=#650c0c>10</font> characters per forum account.</font></center> <center><font size=4 face=Times New Roman color=#650c0c>Y</font><font size=3 face=Times New Roman color=#FFFFFF>ou will be unable to multi-log with 2 characters on the same forum account.</font></center>"; if(empty($pun_user['del_pin']) && $switchAct != 'set_pin'){ echo "<center><font size=4 face=Times New Roman color=#650c0c>Y</font><font size=3 face=Times New Roman color=#FFFFFF>ou have not yet set your character deletion pin, would like to set one</font> <a href='?query=cms&act=set_pin'>now</a>?</center>"; } if($switchAct != 'addnew' && $totalchars < 10){ echo " <br /><br /><center><font size=4 face=Times New Roman color=#650c0c>C</font><font size=3 face=Times New Roman color=#FFFFFF>lick</font> <a href='?query=cms&act=addnew'>here</a><font size=3 face=Times New Roman color=#FFFFFF> if you wish to add a new character.</font> "; } if($totalchars >= 10){ echo "<br /><br />Sorry but you currently have 10 characters and can not add more. You must either delete one or make a new forum account."; } echo "</div></div>"; switch($switchAct){ case "set_pin": if(!empty($pun_user['del_pin'])){ echo createTable("You have already set a PIN."); } else { if(isset($_POST['set_pin'])){ $pin1 = isset($_POST['pin_1']) ? (is_numeric($_POST['pin_1']) ? $_POST['pin_1'] : null) : null; $pin2 = isset($_POST['pin_2']) ? (is_numeric($_POST['pin_2']) ? $_POST['pin_2'] : null) : null; if($pin1 == null || $pin2 == null){ echo createTable("You need to fill in both pin inputs, and ensure that the pin you entered is numeric."); } else if ( strlen($pin1) != 4 || strlen($pin2) != 4){ echo createTable("Please ensure that your pin is 4 characters in length."); } else if ($pin1 != $pin2){ echo createTable("Please ensure that your pins match eachother."); } else { $set_pin = $db->query("UPDATE users SET del_pin = '" . $pin1 . "' WHERE id = '" . $pun_user['id'] . "'"); echo createTable("You have successfully set your character management pin. <a href='?query=cms'>Refreshing...</a><meta http-equiv='refresh' content='1;url=?query=cms' />", "Success"); } } echo " <form method='post' action='?query=cms&act=set_pin'> <div class='table'> <div class='header'><img src='infrastructure/content/images/Set Deletion Pin.png'></div> <div class='content'> <table> <tr> <td style='width:20%;'>Write Pin</td> <td style='width:15%;'><input type='password' size='4' maxlength='4' name='pin_1' value='" . (isset($_POST['pin_1']) ? $_POST['pin_1'] : null) . "' /></td> <td style='width:65%;vertical-align:top;' rowspan='3'> If you are going to set a character deletion pin, please ensure that you can REMEMBER it, as this will become always required in order to delete characters. </td> </tr> <tr> <td>Confirm Pin</td> <td><input type='password' size='4' maxlength='4' name='pin_2' value='" . (isset($_POST['pin_2']) ? $_POST['pin_2'] : null) . "' /></td> </tr> <tr> <td> <input type='submit' name='set_pin' value='Set My Pin' /> </td> <td> <a href='?query=cms'>Cancel</a> </td> </tr> </table> </div> </div> </form> "; } break; case "opt": $cleanChar = (is_numeric($_GET['char']) && $_GET['char'] > 0) ? trim($_GET['char']) : null; if(isset($cleanChar)){ $findInfo = $db->fetch_assoc($db->query("SELECT * FROM rsca2_players WHERE user = '" . $db->escape($cleanChar) . "'")); if($findInfo['owner'] == $pun_user['id']){ $expSelect = $db->fetch_assoc($db->query("SELECT * FROM rsca2_experience WHERE user = '" . $findInfo['user'] . "'")); if($expSelect['highscoreopt'] == 0){ $db->query("UPDATE rsca2_experience SET highscoreopt = '1' WHERE user = '" . $db->escape($cleanChar) . "'") or die(); #echo "Setting to hide"; } else { #echo "Setting to show"; $db->query("UPDATE rsca2_experience SET highscoreopt = '0' WHERE user = '" . $db->escape($cleanChar) . "'") or die(); } } } break; case "deletecharacter": $grab_char_id = isset($_GET['char']) ? $_GET['char'] : null; if(is_numeric($grab_char_id)){ $checkdata = $db->fetch_assoc($db->query("SELECT * FROM rsca2_players WHERE user = '" . $db->escape($grab_char_id) . "'")); if($checkdata['owner'] == $pun_user['id']){ if(isset($_POST['deletechar'])){ if(!empty($pun_user['del_pin']) && $_POST['deletion_pin'] != $pun_user['del_pin']){ echo createTable("The pin you entered was incorrect... <meta http-equiv='refresh' content='1;url=?query=cms'><a href='?query=cms'>refreshing momentarily</a>."); return; } $db->query("DELETE FROM rsca2_players WHERE user = '" . $db->escape($grab_char_id) . "'"); $db->query("DELETE FROM rsca2_curstats WHERE user = '" . $db->escape($grab_char_id) . "'"); $db->query("DELETE FROM rsca2_experience WHERE user = '" . $db->escape($grab_char_id) . "'"); $db->query("DELETE FROM rsca2_invitems WHERE user = '" . $db->escape($grab_char_id). "'"); $db->query("DELETE FROM rsca2_logins WHERE user = '" . $db->escape($grab_char_id) . "'"); #echo $cmsPre . "<meta http-equiv='refresh' content='1;url=?query=cms'>Your character has been successfully deleted, <a href='?query=cms'>refreshing momentarily</a>." . $cmsSuf; } else { echo " <form method='post'> <div class='table'><div class='header'>Delete confirmation for '".$checkdata['username']."'</div> <div class='content'> Are you sure you wish to delete this character? This action is totally irreversible! <br /> <table> "; if(!empty($pun_user['del_pin'])){ echo " <tr> <td style='width:50%;'> Enter Deletion Pin: </td> <td style='width:50%;text-align:right;'> <input type='password' name='deletion_pin' value='' size='4' maxlength='4' /> </td> </tr> "; } echo" <tr> <td style='width:50%;'> <input type='submit' value='Delete Character' name='deletechar' /> </td> <td style='text-align:right;'> <a href='?query=cms'>Cancel</a> </td> </tr> </table> </div> </div> </form> "; } } else { echo $cmsPre . "This is not your character." . $cmsSuf; } } else { echo $cmsPre . "Invalid Character ID." . $cmsSuf; } break; default: break; } echo " <div class='table'> <div class='header'><img src='infrastructure/content/images/My Existing Characters.png'></div> <div class='content'>"; $fetchCharacters = $db->query("SELECT * FROM rsca2_players WHERE owner = '" . $pun_user['id'] . "'"); if($db->num_rows($fetchCharacters) > 0){ echo " <table id='cmsTable' style='width:100%;'> <tr id='cmsHeaders'> <br></br> <td style='width:35%;'><font size=5 face=Times New Roman color=#FFFFFF>Character</font></td> <td style='width:20%;text-align:center;'><font size=5 face=Times New Roman color=#FFFFFF>Password</font></td> <td style='width:35%;text-align:center;'><font size=5 face=Times New Roman color=#FFFFFF>Highscore Opt</font></td> <td style='width:10%;text-align:right;'><font size=5 face=Times New Roman color=#FFFFFF>Delete</font></td> </tr> "; while($r = $db->fetch_assoc($fetchCharacters)){ $optCheck = $db->fetch_assoc($db->query("SELECT highscoreopt FROM rsca2_experience WHERE user = '" . $r['user'] . "'")); echo "<tr><td><a href='?query=highscores&lookup=" . $r['username'] . "&s_type=1'>" . $r['username'] . "</a></td><td style='text-align:center;'><a href='?query=cms&act=changepass&char=".$r['user']."'>Change</a></td><td style='text-align:center;'>" . (($optCheck['highscoreopt'] == 0) ? "<a href='?query=cms&char=" . $r['user'] . "&act=opt'>Hide</a>" : "<a href='?query=cms&act=opt&char=" . $r['user'] . "'>Show</a>") . "</td><td style='text-align:right;'><a href='?query=cms&act=deletecharacter&char=".$r['user']."'>X</a></td></tr>"; } echo " </table> "; } else { echo "You have not yet <a href='?query=cms&act=addnew'>added a character</a> to this account."; } echo " </div></div></div> "; } break; case "login_page": require('quickLogin.php'); break; case "rules": echo "<div class='table'><div class='header'><img src='infrastructure/content/images/Rules.png'></div><div class='content'>"; $file = array_map('rtrim',file('infrastructure/content/rawdata/rules2.txt')); for($i=0;$i<count($file);$i++){ echo str_replace("\$SERVER_NAME\$", $web_primary_name, $file[$i]) . "<br />"; } echo "</div></div>"; break; case "combat_calculator": if(isset($_POST['calccomb']) || isset($_POST['calchits'])){ $attack = isset($_POST['attack']) && is_numeric($_POST['attack']) && $_POST['attack'] > 0 && strlen($_POST['attack']) <= 2 ? $_POST['attack'] : null; $defense = isset($_POST['defense']) && is_numeric($_POST['defense']) && $_POST['defense'] > 0 && strlen($_POST['defense']) <= 2 ? $_POST['defense'] : null; $strength = isset($_POST['strength']) && is_numeric($_POST['strength']) && $_POST['strength'] > 0 && strlen($_POST['strength']) <= 2 ? $_POST['strength'] : null; $hits = isset($_POST['hits']) && is_numeric($_POST['hits']) && $_POST['hits'] > 0 && strlen($_POST['hits']) <= 2 ? $_POST['hits'] : null; $ranged = isset($_POST['ranged']) && is_numeric($_POST['ranged']) && $_POST['ranged'] > 0 && strlen($_POST['ranged']) <= 2 ? $_POST['ranged'] : null; $magic = isset($_POST['magic']) && is_numeric($_POST['magic']) && $_POST['magic'] > 0 && strlen($_POST['magic']) <= 2 ? $_POST['magic'] : null; $prayer = isset($_POST['prayer']) && is_numeric($_POST['prayer']) && $_POST['prayer'] > 0 && strlen($_POST['prayer']) <= 2 ? $_POST['prayer'] : null; /* CALC HITS */ $totalexp = ($exps[($attack - 2)] + $exps[($defense - 2)] + $exps[($strength - 2)]); $divideexp = floor($totalexp / 3) + 1200; $convertexp = experience_to_level($divideexp); $hplvl = $convertexp; /* CALC COMB */ if(!isset($_POST['calchits'])){ echo "<div class='table'><div class='header'><img src='infrastructure/content/images/Calculated Results.png'></div></br></br><div class='content'>"; if($attack == null || $defense == null || $strength == null || $hits == null || $ranged == null || $magic == null || $prayer == null){ echo "You either left a field blank or attempted to add bad data."; } else { $calcatkdefstr = (($attack + $defense + $strength + $hits) * .25); $calcmagicprayer = ($magic + $prayer) * 0.125; if(($attack + $strength) < ($ranged * 1.5)){ $defhits = ($defense + $hits) * 0.25; $fixrange = $ranged * 0.375; $newcb = $defhits + $fixrange + $calcmagicprayer; $base = 0; } else { $base = 1; $newcb = $calcatkdefstr + $calcmagicprayer; } $nextcb = floor(($newcb) + 1) - $newcb; $nextFightLevel = (floor(($nextcb) / 0.25)) - 1; $nextPMLevel = (floor(($nextcb) / 0.125)) - 1; $nextRangeLevel = (floor(($nextcb) / 0.375)); $atkDefAddTo = floor($ranged * 1.5); $nextFightLevel = $nextFightLevel < 0 ? 0 : $nextFightLevel; $nextPMLevel = $nextPMLevel < 0 ? 0 : $nextPMLevel; $nextRangeLevel = $nextRangeLevel < 0 ? 0 : $nextRangeLevel; echo " <table> <tr> <td style='width:40%;'>Combat Level</td> <td style='width:60%;'><span class='highlighter'>" . $newcb . "</span></td> </tr> <tr> <td style='width:40%;'>Character Base</td> <td style='width:60%;'>" . ($base == 0 ? "Ranger" : "Fighter") . "</td> </tr> ";if($hits < 10 || $newcb < 3.5){ echo "<tr><td valign='top'>Extra Notes</td><td>Administrative character. <br />[ Detected < 10 hp || cblvl < 3.5]</td></tr>"; } if($base == 0){ echo " <tr> <td valign='top'>You can max out with:</td> <td>" . $nextRangeLevel . " more ranged level(s).<br />" . $nextFightLevel . " more defense or hits level(s).<br /> " . $nextPMLevel . " more magic or prayer level(s). <br /><br />Because you are primarily a ranger, if you DO NOT raise your ranged level, your attack and strength will have NO effect on your combat level until they add to " . $atkDefAddTo . " </td> </tr> "; } else { echo " <tr> <td valign='top'>You can max out with:</td> <td>" . $nextFightLevel . " more attack, defense, or strength level(s). <br />" . $nextPMLevel . " more magic or prayer level(s).</td> </tr> "; } echo " </table> "; } echo "</div></div>"; } } echo " <form method='post'><div class='table'><div class='header'><img src='infrastructure/content/images/Combat Calculator2.png'></div></br></br><div class='content'> <input type='hidden' name='query' value='combat_calculator' /> <table style='width:75%;margin:auto;'> <tr> <td style='width:50%;'><font color=#FFFFFF>Attack</font></td> <td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['attack']) && !isset($_POST['clearit']) ? $_POST['attack'] : 1) . "' name='attack' /></td> </tr> <tr> <td style='width:50%;'><font color=#FFFFFF>Defense</font></td> <td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['defense']) && !isset($_POST['clearit']) ? $_POST['defense'] : 1) . "' name='defense' /></td> </tr> <tr> <td style='width:50%;'><font color=#FFFFFF>Strength</font></td> <td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['strength']) && !isset($_POST['clearit']) ? $_POST['strength'] : 1) . "' name='strength' /></td> </tr> <tr> <td style='width:50%;'><font color=#FFFFFF>Hits</font></td> <td style='width:50%;'> <table> <tr> <td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['hits']) && !isset($_POST['clearit']) ? ((isset($_POST['calchits'])) ? $hplvl : $_POST['hits']) : 10) . "' name='hits' /></td> <td style='width:50%;'><input type='submit' name='calchits' value='Calc. Hits' /></td> </tr> </table> </td> </tr> <tr> <td style='width:50%;'><font color=#FFFFFF>Ranged</font></td> <td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['ranged']) && !isset($_POST['clearit']) ? $_POST['ranged'] : 1) . "' name='ranged' /></td> </tr> <tr> <td style='width:50%;'><font color=#FFFFFF>Prayer</font></td> <td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['prayer']) && !isset($_POST['clearit']) ? $_POST['prayer'] : 1) . "' name='prayer' /></td> </tr> <tr> <td style='width:50%;'><font color=#FFFFFF>Magic</font></td> <td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['magic']) && !isset($_POST['clearit']) ? $_POST['magic'] : 1) . "' name='magic' /></td> </tr> <tr> <td><input type='submit' name='clearit' value='Set to Defaults' /></td> <td><input type='submit' name='calccomb' value='Calculate Combat' /></td> </tr> </table>"; echo "</div></div></form>"; break; case "item_id_list": echo "<div class='table' style='overflow:auto;height:600px;'><div class='header'><font size=5 color=#650c0c><u>Item ID List</u></font></div><div class='content'>"; $file = array_map('rtrim',file('infrastructure/content/rawdata/item.txt')); for($i=0;$i<count($file);$i++){ echo $file[$i] . "<br />"; } echo "</div></div>"; break; case "stat_reduction": echo createTable("Coming Soon" , "Stat Reduction"); break; case "npc_drops": mysql_connect('localhost', 'xxx', 'xxx'); //your credentials //missing a single quote] *JCBONES mysql_select_db('monster'); //you credentials //Determine the selected monster $selectedMonster = (isset($_POST['monster'])) ? trim($_POST['monster']) : false; //Variable to hold the output of the seelcted monster $monsterOutput = ''; //If a monster was selected get the data if($selectedMonster) { $id = mysql_real_escape_string($selectedMonster); $query = "SELECT * FROM monsters WHERE id = {$id}"; $result = mysql_query($query) or die(mysql_error()); if(mysql_num_rows($result)==0) { $monsterOutput = "Monster not found."; } else { $monster = mysql_fetch_assoc($result); //Create output to display the monster data $monsterOutput .= "<table border='0'>"; $monsterOutput .= " <tr>\n"; $monsterOutput .= " <th><font color=#FFFFFF>Name:</font><th><td><font color=#FFFFFF>{$monster['name']}</font></td>\n"; $monsterOutput .= " <th><font color=#FFFFFF>Hit Points:</font><th><td><font color=#FFFFFF>{$monster['h_points']}</font></td>\n"; $monsterOutput .= " <th><font color=#FFFFFF>Attack:</font><th><td><font color=#FFFFFF>{$monster['attack']}</font></td>\n"; $monsterOutput .= " <th><font color=#FFFFFF>Stamina:</font><th><td><font color=#FFFFFF>{$monster['stamina']}</font></td>\n"; $monsterOutput .= " </tr>"; $monsterOutput .= "</table>"; } } //Run query to get list of ALL monster names/IDs to build select list $query = "SELECT id, name FROM monsters ORDER by name"; $result = mysql_query($query) or die(mysql_error()); //Process results into options list $monsterOptions = ''; while($row = mysql_fetch_assoc($result)) { $selected = ($row['id']===$selectedMonster) ? ' selected="selected"' : ''; $monsterOptions .= "<option value=\"{$row['id']}\"{$selected}>{$row['name']}<option>"; } //closed PHP: JCBONES ?> <form name="menuform" method="post"> <!--Form not properly created JCBONES--> <table> <tr> <td>Monster Database</td> </tr> <tr> <td><center><font color=#FFFFFF>Select a monster from the list: </font></center></td> <td> <select name="monster"> <?php echo $monsterOptions; ?> </select> <button type="submit">Submit</button> </td> </tr> </table> </form> </body> </html> <?php echo $monsterOutput; ?> </body> <?php //reopened PHP. JCBONES break; default: echo" <div class='table'> <div class='header'> <img src='infrastructure/content/images/newsandannouncements.png'> </div> </div> "; require 'forum/include/parser.php'; $contentGrabThis = $db->query("SELECT * FROM topics WHERE forum_id = " . $webAnnounceId . " ORDER BY posted DESC LIMIT 0 , " . $webAnnounceLimit); if($db->num_rows($contentGrabThis) > 0){ while($r = $db->fetch_assoc($contentGrabThis)){ echo " <div class='table'> <div class='header' style='text-align:center !important;'> <table> <tr> <td class='td_header'> <a href='" . PUN_ROOT . "viewtopic.php?id=" . $r['id'] . "'><font size=5 color=#650c0c>" . $r['subject'] ."</font></a> </td> </tr> </table> </div> </br> <div class='content'> "; $countTotal = ($db->num_rows($db->query("SELECT id FROM posts WHERE topic_id = '" . $r['id'] . "'"))) - 1; $pullPostInfo = $db->fetch_assoc($db->query("SELECT poster_id,poster,message,hide_smilies FROM posts WHERE topic_id = '" . $r['id'] . "' ORDER BY posted ASC LIMIT 0 , 1")); echo filter_subject(parse_message($pullPostInfo['message'], $pullPostInfo['hide_smilies'])); echo" </div> <div class='content' style='text-align:right;'> <td class='td_header' style='text-align:left;'><font color=#FFFFFF>" . date("M d Y" , $r['posted']) . "</td> Added by <a href='" . PUN_ROOT . "profile.php?id=" . $pullPostInfo['poster_id'] . "'><font color=#800000>" . $r['poster'] ."</font></a> • <a href='" . PUN_ROOT . "viewtopic.php?id=" . $r['id'] . "'><font color=#800000>" . $countTotal . "</font></a> comment" . (($countTotal == 1) ? null : "s") . "</font> </div> </div> "; } } else { echo createTable("No news and update content was pulled from the forum. Please make sure \$webAnnounceId has been set in ->infrastructure/generalSettings.php to the appropriate news & announcements board ID AND that you have posted at least ONE announcement in said board. <br /><br />ALSO, ensure you strictly limit the board topic creation to admins, or you run the risk of letting noobs post announcements on the front page."); } break; } ?> </body> </html>
  20. I usually let my columns have null values, unless I define a default value.
  21. Your id field should be set to 'Primary Key' and 'Auto_increment'.
  22. He does, through the bindParam() function inside of the PDO class.
  23. I don't see any database interaction in your script. You build the query, but never send it to the database. Perhaps you left some of the script out, because Dreamweaver usually writes that in for you.
  24. I am astonished there is not one mention of programmers notepad. While not my favorite editor, it offers things that notepad++ doesn't, and allows for quite a bit of customization. http://www.pnotepad.org/
  25. Post the full file, we cannot fix parse errors with part of a file.
×
×
  • 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.