-
Posts
186 -
Joined
-
Last visited
Everything posted by Kryllster
-
I am trying to make an rpg another one I might add. I have a basic script that adds the right loot items and prices and descriptions. It has a post form to submit but when I do it only sells the first itme in the list and not the one that is checked with a radio button any help? <img src="images/inventory.jpg" alt="" /> <table width="100%" cellpadding="1" cellspacing="0" border="2"> <tr colspan="7"> <td>Slot</td><td>Item</td><td>Level<td>Power</td><td>Sell Price</td><td>Sell Item</td><td>Wear Item</td> <?php // include char files and loot files include "php/db/db_config.php"; // create variables from db and loot $username = $_SESSION['username']; $player_id = $account_info['player_id']; // select from loot db $result = mysqli_query($my_database,"SELECT * FROM inventory WHERE username = '$username'") or die (mysqli_error($my_database)); //$counter = 0; while ($row = mysqli_fetch_assoc($result)) { echo '<tr>'; echo '<td>'; //$counter++; //echo $counter; echo '</td>'; echo '<td>'; echo $row['item']; echo '</td>'; echo '<td>'; echo $row['level']; echo '</td>'; echo '<td>'; echo $row['power']; echo '</td>'; echo '<td>'; echo $row['sell_price']; $row['sell_price']; echo '</td>'; echo '<td>'; echo '<form action="index2.php?content=sell_item" method="post">'; echo '<input type="radio" name="id">'; echo '<input type="submit" value="Sell This Item">'; echo '</form>'; echo '</td>'; echo '<td>'; echo '<form action="loot/wear_item.php" method="post">'; echo '<input type="hidden" name="two">'; echo '<input type="submit" value="Wear This Item">'; echo '</form>'; echo '</td>'; echo '</tr>'; } ?> </table>
-
Sorry for the post I had a problem with the sql in the inventory table I figured it out right after this post sorry.
-
MySQL version 5.1.73-cll I can't seem to get the inventory table to insert the information I have stared in an array any help would be appreciated!! <?php $username = $_SESSION['username']; ini_set('display_errors',1); error_reporting(E_ALL); //include "php/db/db_config.php"; include "php/db/db_config.php"; include "php/db/item_connect.php"; $id = $items_id['id']; $player = $account_info['player_id']; //Update database $sql = mysqli_query($my_database,"INSERT INTO inventory ( player_id, username, id ) VALUES('$player', '$username', '$id')"); //echo values of item id echo "<div class=\"loot\">"; echo "<b>Required Level:" . $items_id['requ_level'] . "</b><br />"; echo "<b>Name:" . $items_id['name'] . "</b><br />"; echo "<b>Min Str:" . $items_id['min_str'] . "<br />"; echo "<b>Min Int:" . $items_id['min_int'] . "<br />"; echo "<b>Min Dex:" . $items_id['min_dex'] . "<br />"; echo "<b>Type:" . $items_id['type']. "<br />"; echo "<b>Min Physical Dmg:" . $items_id['min_dmg'] . "<br />"; echo "<b>Max Physical Dmg:" . $items_id['max_dmg'] . "<br />"; echo "<b>Min Magic Dmg:" . $items_id['mag_attk_min'] . "<br />"; echo "<b>Max Magic Dmg:" . $items_id['mag_attk_max'] . "<br />"; echo "<b>Phys Defense:" . $items_id['phy_def'] . "<br />"; echo "<b>Magical Defense:" . $items_id['mag_def'] . "<br />"; echo "</div>"; ?> I get no errors or notices and the info fields show up as being populated.
-
I have some code I used to have in mysql and now im trying to convert to mysqli and I cant seem to find out what the problem is. <?php $username = $_SESSION['username']; // Connect to server and select databse. include "db_connect.php"; include "db_config.php"; // items tables selection $sql = mysqli_query($my_database,"SELECT * FROM items_tbl WHERE level = '$account_info[player_level]' ORDER BY rand()"); //$result = mysqli_query($my_database,$sql); // Put info into array (This Works) while($item = mysqli_fetch_assoc($sql)){ //stats $items_id['itemid'] = $item['itemid']; $items_id['Level'] = $item['Level']; $items_id['name'] = $item['name']; $items_id['min_str'] = $item['min_str']; $items_id['min_int'] = $item['min_int']; $items_id['min_dex'] = $item['min_dex']; $items_id['type'] = $item['type']; $items_id['min_dmg'] = $item['min_dmg']; $items_id['max_dmg'] = $item['max_dmg']; $items_id['phys_defense'] = $item['phys_defense']; $items_id['mag_defense'] = $item['mag_defense']; } ?> here is the error im getting: Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given
-
I had my own way of doing this until I started worjing with a friend.He gave me a pice of code to use and I have no idead how to get it to work (he is way more advanced than me) here is the code I cant figure out what to do with it. <?php function logged_in(){ if (isset ($_SESSION['username'])){ $_SESSION['username'] == true; } } if(logged_in()) { echo "<div id=\"navi\">";include "content/website/header.php";"</div>"; echo "<div id=\"content\">";include "layout/game.php";"</div>"; echo "<div style=\"clear:both;\"></div>"; echo "<div id=\"footer\">";include "content/website/footer.php";"</div>"; } else { echo "<div id=\"navi\">"; include "content/website/main_header.php"; "</div>"; echo "<div id=\"content\">"; include "layout/content.php"; "</div>"; echo "<div style=\"clear:both;\"></div>"; echo "<div id=\"footer\">"; include "content/website/main_footer.php"; "</div>"; } ?> Anywy I basicaly have the main website where the else clause is and the site for my game in the logged in pard . What to do??
-
Ok thanks mac I didnt know that I did turn on all error reporting in the master php.ini and now I cant even log in. I have switched on the recommendadtion to a different structur for my sites and now it looks like im gonna have to redo all the code.
-
I am trying to make a session based quest sytem for a game im making. I have some code but im not sure why it isnt working. I get the basic info from a database but everytime I click on a link to fight a monster I get a blank page. <?php // connect to db include 'php/db/vanguard_db_config.php'; // Select data from database $sql = "SELECT * FROM assignments WHERE assignment_id='1'"; $result = mysql_query($sql); // Put info into array Hopefully while($entry = mysql_fetch_assoc($result)){ $id = $entry['assignment_id']; $assignname = $entry['assignment_name']; $numarrest = $entry['num_to_arrest']; $villianarrest = $entry['villian_to_arrest']; $num_arrested = $entry['num_arrested']; $completed = $entry['completed']; $reward = $entry['reward']; $stat = $villianarrest; // session assignment manipulation if(!isset($_SESSION['assignment_id'])) ($id = $_SESSION['assignment_id']){ $_SESSION['assignment_id'] = $id; } if(!isset($_SESSION['num_to_arrest'])){ $_SESSION['num_to_arrest'] = 10; } if(!isset($_SESSION['completed'])){ $_SESSION['completed'] = 1; } if( $_SESSION['num_to_arrest'] != 10){ $_SESSION['num_to_arrest'] + 1; } id($num_arrested == 10{ $sql = "UPDATE assignments SET // Update database with loot and level advance money = money + 20000; WHERE assignment_id = '$id'"; mysql_query($sql) or die (mysql_error()."<p>$sql</p>"); } if($num_arrested == 10){ echo "<h2>You Have Completed Your Assignment and received $20,000 Dollars!</h2>"; } } ?> Thanks for any input in advance!
-
Im not getting any error message if the file is in the pages directory I guess what Im looking for is an error message that says something to the effect that the file is unavailabe with a custom error message instead of what was posted earlier.
-
Sorry about that, Im just tired, Im trying to write something that is way over my head and Im sorry for taking up your time.
-
Yeah it does seem a little backwords I tried copying your code it didnt work for my site Im not sure what else to do from here Im gooleing my butt off trying to find an answer!
-
<?php // header include('pages/main_header.php'); $dir = 'pages/'; $files = scandir($dir); $page = (!isset($_GET['page'])) ? 'intro' : $_GET['page']; if (!in_array($_GET['page'], $files)){ require_once('pages/' . $page . ".php"); } else { echo "This page does not exist!!"; } //footer include('pages/main_footer.php'); ?>
-
Ok well it looks like I jusmped the gun I only tested default.php?page=test when I had a folder in the main directory called test. After I delelted that folder the same error messages pop up. =========================================================== Warning: require_once(pages/test.php): failed to open stream: No such file or directory in C:\xampp\htdocs\vang\default.php on line 8 Fatal error: require_once(): Failed opening required 'pages/test.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\vang\default.php on line 8 ============================================================= back to the drawing board
-
Works perfectly thanks so much I see the problem tho. I would maybe have gotten it prolly not like thatnks to all for your suggestions and the final solution.
-
here is the var_dump(); ================================ array(37) { [0]=> string(1) "." [1]=> string(2) ".." [2]=> string(9) "about.php" [3]=> string(11) "airport.php" [4]=> string(13) "amusement.php" [5]=> string(11) "brawler.php" [6]=> string( "chat.php" [7]=> string(10) "combat.php" [8]=> string(12) "congrats.php" [9]=> string(10) "create.php" [10]=> string(10) "defeat.php" [11]=> string(12) "downtown.php" [12]=> string(10) "footer.php" [13]=> string(10) "header.php" [14]=> string(12) "industry.php" [15]=> string(9) "intro.php" [16]=> string(13) "loggedout.php" [17]=> string(12) "magician.php" [18]=> string( "main.php" [19]=> string(15) "main_footer.php" [20]=> string(15) "main_header.php" [21]=> string(12) "maindrag.php" [22]=> string( "news.php" [23]=> string(7) "old.php" [24]=> string(15) "playerstats.php" [25]=> string(12) "recovery.php" [26]=> string(13) "safeplace.php" [27]=> string(10) "sewers.php" [28]=> string(9) "slums.php" [29]=> string(9) "stats.php" [30]=> string(11) "suburbs.php" [31]=> string(10) "tanker.php" [32]=> string(16) "technologist.php" [33]=> string(4) "test" [34]=> string(11) "victory.php" [35]=> string(16) "vilinterface.php" [36]=> string(13) "weaponeer.php" } ====================================== I dont know what exactly all that means but its reading the files in the directory.
-
I tried this but it didnt work and Im not sure about the custom error page ======================================================== <?php // header include('pages/main_header.php'); $dir = 'pages/'; $files = scandir($dir); $page = (!isset($_GET['page'])) ? 'intro' : $_GET['page']; if (!in_array($page, $files)){ require_once('pages/' . $_GET['page'] . ".php"); } else { echo "That Page Does Not Exist"; } //footer include('pages/main_footer.php'); ?> This didnt work!!
-
I have some code some of it mine some of it others and someone im sure has already thought of it but I am trying to make an index.php controller page. But what I can figure out is haow to displa a simple "This Page Does Not Exist" error and Im having no luck. The code I will show works except for the above mentioned. ============================================================== <?php // header include('pages/main_header.php'); $dir = 'pages'; $files = scandir($dir); $page = (isset($_GET['page'])) ? 'intro' : $_GET['page']; if (!in_array($page, $files)) { require_once('pages/' . $_GET['page'] . ".php"); } //footer include('pages/main_footer.php'); ?> Any tips or solutions would be appreciated.
-
<?php // mail going to the person who signed up for game $email_to = $_POST['email']; // self explanatory $email_subject = "Email Verification and Activation"; // needed help from emeri for this $returnlink = "http://ferentus.netai.net/php/verify.php?code=" . $activationkey; //send the message $email_message = "Welcome to The Ferentus Text Website, Please verify your email and activate your account by clicking the link.\n" . $returnlink; // action taken mail($email_to,$email_subject,$email_message); ?> ======================================== This is the way I had been using it is it even necessary to use it in a function??
-
Thanks for the reply. I am looking in the manual now altho it doesnt seem to help much I will also look at some online tutorials.
-
I have written some code which I am not trying to put in a function but I am new to functions so I am not sure what to do. It is an Email account activation script I know it works as it is now but I wanted to try my hand at making it a function. ========================= $activationkey = hash('adler32',rand()); function emailActivate($email_to,$email_subject,$returnlink,$email_message,$activationkey){ $email_to = $_POST['email']; $email_subject = "Email Verification and Activation"; $returnlink = "http://ferentus.netai.net/php/verify.php?code=" . $activationkey; $email_message = "Welcome to The Ferentus Text Website, Please verify your email and activate your account by clicking the link.\n" . $returnlink; mail($email_to,$email_subject,$email_message); } ?> ======================================== Im stuck as to how to use this or even if it is correct? Any comments would be appreciated!!
-
I did get rid of the nested forms! What else if anything can I do to shorten it?
-
Well if you mean finding where the problem is or was it was in my html form I had 6 nested forms when I closed them out the script worked fine. I would like to know how I could shorten the code. I understand how some things work I just know very little but if there is more about this script i can streamline id like to know. Thanks.
-
I figured out the problem it wasnt in the PHP it was in my html I forgot to close out the previous form so it is working fine now sorry to bother you.
-
The data is not being saved and I keep going to the warnamount page. I have a script before this and it works fine and its the same script. case 'water': $unit = 0 + $_POST['water']; $watercost = $unit * 2; $limit = 0 + 3; $allowed = 0 + 10; // check for money if they dont have it let them know else go with transaction if($row['decasols'] < '2'){ header("Location: main.php?page=warnmoney"); exit(); } if($unit > $limit){ header("Location: main.php?page=warnmax"); exit(); } if($row['water'] >= $allowed){ header("Location: main.php?page=warnamount"); exit(); } else{ // Update database $sql="UPDATE $tbl_name SET decasols = decasols - $watercost, water = water + $unit WHERE username='$username'"; mysql_query($sql) or die (mysql_error()."<p>$sql</p>"); header("Location: main.php?page=arrakeen"); exit(); } break; This code which is directly before the other works fine!??? I dont understand.
-
I have some code for a buying script which allows a user to buy food it is basically just like another script i have but does not work and I cant figure out why for the life of me. Here is the code. case 'food': $unit = 0 + $_POST['food']; $foodcost = $unit * 2; $limit = 0 + 5; $allowed = 0 + 10; // check for money if they dont have it let them know else go with transaction if($row['decasols'] < '2'){ header("Location: main.php?page=warnmoney"); exit(); } if($unit > $limit){ header("Location: main.php?page=warnmax"); exit(); } if($row['food'] >= $allowed){ header("Location: main.php?page=warnamount"); exit(); } else{ // update database $sql="UPDATE $tbl_name SET decasols = decasols - $foodcost, food = food + $unit WHERE username='$username'"; mysql_query($sql) or die (mysql_error()."<p>$sql</p>"); header("Location: main.php?page=arrakeen"); exit(); } break; Any Help would be appreciated Thanks in Advance!
-
I am wondering if this web site is secure maybe not for commercial use but overall is it secure? I would also like to know if the design is ok?? Thanks in Advance, http://dune.dyndns-web.com/