Jump to content

gaogier

Members
  • Posts

    84
  • Joined

  • Last visited

Everything posted by gaogier

  1. That gives this error Warning: require_once(./initdata.php) [function.require-once]: failed to open stream: No such file or directory in/disk3/gaogier/public_html/community/ssi.php on line 79 Fatal error: require_once() [function.require]: Failed opening required './initdata.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /disk3/gaogier/public_html/community/ssi.php on line 79
  2. the file is there though, http://runehints.com/community/ssi.php?a=newsnew&show=9&f=2,99 If I make the line <?php include("http://runehints.com/community/ssi.php?a=newsnew&show=9&f=2,99"); ?> I get no errors no news
  3. First lets deal with the news warning found here, http://runehints.com/ Here is my php code <div id="contenttitle">RuneHints News<?php include("includes/newsfeed.php"); ?></div> <?php include("community/ssi.php?a=newsnew&show=9&f=2,99"); ?>
  4. Why do I get the following error? and How to fix? Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in/home/gaogier/public_html/pages/monsters.php on line 217 Here is my code http://pastebin.com/vrEamahn If i add the or die part, I get this message. 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 What do I do?
  5. Thank you, I am not going to PM you the code don't worry. I am however not designing a game, its a calculator so players of an existing game knows what levels they need to level up to gain combat levels - an combat calc. I am very bad/new to php and never progressed pass basic skills. I sort of know what I am doing, but also don't have a clue - I am making it up as I go along. I know this is a forum, the only problem is it takes programmers a while to read posts, hence things take a while to get done, I just wanted to see if anyone wanted to help me speed this up. I am comfortable to do this myself, but just need a guide. I am happy to do this here.
  6. I am glad. function combatLevel($attack, $defence, $strength, $hp, $prayer, $ranged, $magic, $summoning) {$base = ($defence + $hp + floor($prayer / 2) + floor($summoning / 2)) * 0.25; $melee = ($attack + $strength) * 0.325;$ranger = floor($ranged * 1.5) * 0.325;$mage = floor($magic * 1.5) * 0.325; return $base + max($melee, $ranger, $mage);} function combatLevelF2p($attack, $defence, $strength, $hp, $prayer, $ranged, $magic) {$base = ($defence + $hp + floor($prayer / 2)) * 0.25; $melee = ($attack + $strength) * 0.325;$ranger = floor($ranged * 1.5) * 0.325;$mage = floor($magic * 1.5) * 0.325; return $base + max($melee, $ranger, $mage);} The new formula is simpler now. Its just Defence + highest level out of Strength, Ranged, Magic, Attack and Summoning. So, would this work, if not why? function combatLevel($attack, $defence, $strength, $hp, $ranged, $magic, $summoning) {$base = ($defence + 2); return intval($base + max($attack, $strength, $ranged, $magic, $summoning));
  7. If your willing to help me sort things out like calculators for a game, or generate a hiscore lookup (a future project), please can you either help me here, or help me via msn, skype, AOL messenger or other device. I can't pay for your advise, but I am a complete novice and this is the only way I will learn. If you post here, I will send you my code via a PM if thats possible. Basically, I need to recalculate, using a different formula, which I think I would just need to change the order of things but I am not sure.
  8. I commented out the connect and poll now works for some unknown reason.
  9. The same file connect to the same database for everything on the site. which all works.
  10. Hello I am looking to redesign an old poll system what approved to work effeciantly, however I now need to get the poll to work on my new site. I am getting these errors. Warning: mysql_query() [function.mysql-query]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/gaogier/public_html/includes/polls.php on line 4 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/gaogier/public_html/includes/polls.php on line 4 Warning: mysql_query() [function.mysql-query]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/gaogier/public_html/includes/polls.php on line 52 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/gaogier/public_html/includes/polls.php on line 52 Code is on pastebin - 24 hours. http://pastebin.com/1u19Xwwk Now here is where my files are located includes/connect.php includes/polls.php pages/ - my pages.php - displayed as a new folder almost using mod rewrite. tpl/sidebar.tpl - where my poll will be displayed using php - include.
  11. Hello First of all, my code is old, modified etc, I know. I can't afford for someone to reprogram it from scratch. So, with your help I think a novice like me can progress the script into the next stage. http://pastebin.com/580vaMFa Current code - http://pastebin.com/580vaMFa Current url http://runehints.com/calculators - use gaogier Test page - not set up yet. What I need this to work and look like, http://runehints.com/images/calclayout.png If your username can't be found for that skill, RuneScape Name should become Current Exp What should I do first shortern the URL? Make the script from 3 pages to just 1?
  12. Okay, sorry. So, I have managed to set up part 1 okay. I want this, url to show .:RuneHints:. Quests - All Fired Up Guide If its any help the site uses tinymce. I am not sure if that helps or this should be in php code. As I didn't code the site I post here.
  13. Hello If I have 1 header page I edit and it changes on all the pages on the website. However the title is the same on every page and I am trying to make the site more SEO friendly. I was thinking of adding an <?php echo $title; ?>, and have the rest of the code on the relevant pages. I would need to add the following code to the correct pages right? <?php $title = "New title!"; ?>< or would that be too complex? Is there an easier way? So, if I don't have a title on the page set up, I can create an if statement. Is the following code correct? <?php if ($title): echo $title; else { echo $standard title; } ?> I am a novice at php. Sorry and thanks for your help. MOD EDIT: [m] . . . [/m] tags changed to . . . tags.
  14. Sorry, I have no idea where to start this. The idea is to add new calculators, add items, edit items and delete them. If you look at my calculators Found here, http://runehints.com/calculators you may understand it better.
  15. Hello I am very new to php, in fact I have just really started learning 5 days ago. I have a book, (php3-4) that has got me through the years and if you go through the old posts of mine, you see how bad I really am with php. If you don't mind me having your MSN address so I can randomly ask questions about php, Please add me, gaogier@runehints.com So, this is what the code MUST do, add data to each calculator. The new code is for another section of our CMS. Here is the old code. From our old CMS. //------------------------Begin Calc-------------------------------------------// function calc(){ echo '<p><font class="adminheader">Caclulator Admin</font></p>'; echo "<TABLE border=\"0\" width=\"89%\" class=monster>\n"; echo "<TR><TD class=title><center>Calculator Name</center></td><td class=title><center>Insert - Edit - Delete</center></TD></TR>\n"; /* query for monsters */ $query = "SELECT id, name, members, tablename FROM calc ORDER BY name ASC"; $result = mysql_query ($query); while ($row = mysql_fetch_assoc ($result)) { /* display monsters in a table */ /* place table row data in * easier to use variables. */ $count = $count + 1; $name = $row['name']; $mem = $row['members']; if ($mem == "Y"){ $ignore = 1; }else{ $ignore = 0; } $tablename = $row['tablename']; /* display the data */ echo '<TR bgcolor="'.processRow($count).'"><TD class="calc"><b>'.$name.'</b></td><td class="calc"><a href="'.$_SERVER['PHP_SELF'] . '?flibble=calcitem&calc='.$tablename.'&ignore='.$ignore.'"><img src="images/admin/insert.png" alt="Insert data items" border="0"></a> <a href="'.$_SERVER['PHP_SELF'] . '?flibble=c_update&id='.$row['id'].'&ignore='.$ignore.'"><img src="images/admin/view.gif" alt="Edit" border="0"></a> <a href="'.$_SERVER['PHP_SELF'] . '?flibble=c_delete&id='.$row['id'].'&ignore='.$ignore.'"><img src="images/admin/delete.gif" alt="Delete" border="0"></a></TD></TR>'; if($count == 2){ $count = 0; } } /* finish up table*/ echo "</TABLE>\n"; echo '<p><b><a href="http://runehints.com/admin2.php?flibble=add_c"><img src="images/plus.gif" alt="Add" border="0"> Add calculator</a></b></p>'; } function calcitem($calc){ $calc1 = str_replace("calc", "", $calc); echo '<p><font class="adminheader">Caclulator Item Admin for '.$calc1.'</font></p>'; echo "<TABLE border=\"0\" width=\"89%\" class=monster>\n"; echo "<TR><TD class=title><center>Item Name</center></td><td class=title><center>Level - XP</center></TD><td class=title><center>Edit</center></TD</TR>\n"; /* query for monsters */ $query = "SELECT id, item, members, level, xp FROM ".$calc." ORDER BY level, item ASC"; if(!$result = mysql_query ($query)) die(mysql_error()); while ($row = mysql_fetch_assoc ($result)) { /* display monsters in a table */ /* place table row data in * easier to use variables. */ $count = $count + 1; $name = $row['item']; $mem = $row['members']; if ($mem == "1"){ $ignore = 1; }else{ $ignore = 0; } $tablename = $row['tablename']; $level = $row['level']; $xp = $row['xp']; /* display the data */ echo '<TR bgcolor="'.processRow($count).'"><TD class="calc"><b>'.$name.'</b></td><TD class="calc"><b>'.$level.' - '.$xp.'</b></td><td class="calc"><a href="'.$_SERVER['PHP_SELF'] . '?flibble=edit_citem&calc='.$calc.'&id='.$row['id'].'&ignore='.$ignore.'"><img src="images/admin/view.gif" alt="Edit" border="0"></a> <a href="'.$_SERVER['PHP_SELF'] . '?flibble=c_delete&id='.$row['id'].'"><img src="images/admin/delete.gif" alt="Delete" border="0"></a></TD></TR>'; if($count == 2){ $count = 0; } } $ignores = $_GET['ignore']; /* finish up table*/ echo "</TABLE>\n"; echo '<p><b><a href="http://runehints.com/admin2.php?flibble=add_citem&calc='.$calc.'&ignore='.$ignores.'"><img src="images/plus.gif" alt="Add" border="0"> Add a calculator item</a></b></p>'; } function c_update($id) { /* query for item */ $query = "SELECT * FROM calc WHERE id=$id"; $result = mysql_query ($query); /* if we get no results back, error out */ $numrtn = mysql_num_rows($result); if ($numrtn == 0) { echo "The Skill guide requested cannot be found\n"; return; } $row = mysql_fetch_assoc($result); /* easier to read variables and * striping out tags */ $id = $row['id']; $name = $row['name']; $members = $row['members']; $guideby = $row['calcby']; if (isset($_POST['submit'])){ //handle form require_once ('../mysql_connect.php');//connect to db $name = escape_data($_POST['name']); $members = escape_data($_POST['members']); $calcby = escape_data($_POST['guideby']); if ($name && $members && $calcby){//if evrything is ok $query = "UPDATE calc SET name = '$name' , members = '$members', calcby = '$calcby' WHERE id ='$id'"; $result = @mysql_query ($query); //Run the query. if ($result){ //if it entered correctly echo '<br /><table width=98% bgcolor=#565866 class=pass align=center><tr> <td width=40><img src=images/tick.gif></td> <td align=left> <B>Success</B> <BR> The '.$name.' calculator was successfully updated<br /> </table><br /><br />'; include ('difffooter.inc');//footer exit(); }else{ // didn't work echo '<table width=98% bgcolor=#565866 class=logfail align=center><tr> <td width=40><img src=images/exclamation.gif></td> <td align=left> <B>Update Failed!</B> <BR> The '.$name.' calculator could not be updated <BR>Please Try again later<br /> </table><br /><br />'; } }else{ echo '<table width=98% bgcolor=#565866 class=logfail align=center><tr> <td width=40><img src=images/exclamation.gif></td> <td align=left> <B>Update Failed!</B> <BR> Data missing. <BR>Please enter all information needed and try again<br /> </table><br /><br />'; } } /* display the items */ echo '<br /><center><font class="adminheader">Update Calculator Information</font></center> <br />'; echo '<form action="admin2.php?flibble=c_update&id='.$id.'" method="post">'; echo ' <center> <table class=calc> <tr><td> <table> <tr><td align=right><font class="text2">Calculator:</font></td><td align=left><input type="text" class="text" name="name" size="15" maxlength="30" value="'.$name.'" /></td></tr> <tr><td align=right><font class="text2">By:</font></td><td align=left><input type="text" class="text" name="guideby" value="'.$guideby.'" /></td></tr> <tr><td align=right><font class="text2">Members?:</font></td><td align=left><input type="text" class="text" name="members" size="1" maxlength="1" value="'.$members.'" /><font class="small2">Use Y or N only</font></td></tr> </table> </td> </tr> </table> </CENTER> </form> '; ?> <div align="center"><input type="submit" name="submit" value="Update DB" class="liteoption" /> <input type="reset" name="reset" value="reset" class="liteoption" /></div></form> <?php } function c_delete($id){ $query = "SELECT `name` FROM calc WHERE id=$id"; $result = mysql_query ($query); /* if we get no results back, error out */ $numrtn = mysql_num_rows($result); if ($numrtn == 0) { echo "The calculator requested cannot be found\n"; return; } $row = mysql_fetch_assoc($result); /* easier to read variables and * striping out tags */ $name = $row['name']; if (isset($_POST['yes'])){ //handle form $query = "DELETE FROM `calc` WHERE `id` = ".$id." LIMIT 1"; $result = mysql_query($query); if ($result) { ob_end_clean(); header("http://runehints.com/admin2.php?flibble=calc"); } } echo '<table width=98% bgcolor=#565866 class=logfail align=center><tr> <td width=40><img src=images/exclamation.gif></td> <td align=left> <B>Delete?</B> <BR> Are you sure you want to delete '.$name.' from the database? <BR><br /><form action="admin2.php?flibble=c_delete&id='.$id.'" method="post"><input type="submit" name="yes" value="Yes" class="delete" /> <input name="no" type=button onClick="javascript:history.go(-1)" value="No" class="delete" /></form> </table><br /><br />'; } function add_calc() { if (isset($_POST['submit'])){ //handle form require_once ('../mysql_connect.php');//connect to db $name = escape_data($_POST['name']); $calcby = escape_data($_POST['calcby']); $members = escape_data($_POST['members']); if ($name && $calcby && $members){//if evrything is ok $query = "INSERT INTO calc (name, calcby, members) VALUES ('$name', '$calcby','$members')"; $result = @mysql_query ($query); //Run the query. if ($result){ //if it entered correctly echo '<br /><table width=98% bgcolor=#565866 class=pass align=center><tr> <td width=40><img src=images/tick.gif></td> <td align=left> <B>Success</B> <BR> The '.$name.'\' calculator was successfully added<br /> </table><br /><br />'; include ('difffooter.inc');//footer exit(); }else{ // didn't work echo '<table width=98% bgcolor=#565866 class=logfail align=center><tr> <td width=40><img src=images/exclamation.gif></td> <td align=left> <B>Update Failed!</B> <BR> The '.$name.'\ calculator was could not be added <BR>Please Try again later<br /> </table><br /><br />'; } } } ?> <br /><font class="adminheader"><center>Add Calculator</center></font><br /> Here you can add skill guide to the database. Be sure to give credit properly where it is due!<br /> <form action="admin2.php?flibble=add_c" method="post"><center> <table class=calc> <tr><td> <table> <tr><td align=right><font class="text2">Calculator Name:</font></td><td align=left><input type="text" class="text" name="name" size="15" maxlength="30" value="<?php if (isset($_POST['name'])) echo $_POST['name']; ?>" /></td></tr> <tr><td align=right><font class="text2">Calculator by:</font></td><td align=left><input type="text" class="text" name="calcby" value="<?php if (isset($_POST['calcby'])) echo $_POST['calcby']; ?>" /></td></tr> <tr><td align=right><font class="text2">Members?:</font></td><td align=left><input type="text" class="text" name="members" size="1" maxlength="1" value="<?php if (isset($_POST['members'])) echo $_POST['members']; ?>" /><font class="small2">Use Y or N only</font></td></tr> </table> </td> </tr> <tr> <td> <div align="center"><input type="submit" name="submit" value="Add Calculator" class="liteoption" /> <input type="reset" name="reset" value="reset" class="liteoption" /></div> </td> </tr> </table> </CENTER> </form> <?php } function addcalcitem($calc){ $ignore = $_GET['ignore']; if (isset($_POST['submit'])){ //handle form require_once ('../mysql_connect.php');//connect to db $name = escape_data($_POST['name']); $level = escape_data($_POST['level']); if ($ignore != 1){ $members = strtoupper(escape_data($_POST['members'])); if ($members == "Y"){ $members =1; }else{ $members =0; } } $xp = escape_data($_POST['xp']); if ($name && $level && $xp){//if evrything is ok $query = "INSERT INTO ".$calc." (item, level, xp, members) VALUES ('$name', '$level', '$xp', '$members')"; $result = mysql_query ($query); //Run the query. if ($result){ //if it entered correctly echo '<br /><table width=98% bgcolor=#565866 class=pass align=center><tr> <td width=40><img src=images/tick.gif></td> <td align=left> <B>Success</B> <BR> The item '.$name.' was successfully added<br /> </table><br /><br />'; include ('difffooter.inc');//footer exit(); }else{ // didn't work echo '<table width=98% bgcolor=#565866 class=logfail align=center><tr> <td width=40><img src=images/exclamation.gif></td> <td align=left> <B>Update Failed!</B> <BR> The item '.$name.' could not be added <BR>Please Try again later<br /> </table><br /><br />'; } } } ?> <br /><font class="adminheader"><center>Add Calculator item</center></font><br /> Here you can add items to calculators. Be sure to give credit properly where it is due!<br /> <?php echo '<form action="'.$_SERVER['PHP_SELF'].'?flibble=add_citem&ignore='.$ignore.'&calc='.$calc.'" method="post"><center>'; ?> <table class=calc> <tr><td> <table> <tr><td align=right><font class="text2">Item name:</font></td><td align=left><input type="text" class="text" name="name" size="15" maxlength="30" value="<?php if (isset($_POST['name'])) echo $_POST['name']; ?>" /></td></tr> <tr><td align=right><font class="text2">Level:</font></td><td align=left><input type="text" class="text" name="level" value="<?php if (isset($_POST['level'])) echo $_POST['level']; ?>" /></td></tr> <tr><td align=right><font class="text2">XP(to decimal if possible):</font></td><td align=left><input type="text" class="text" name="xp" value="<?php if (isset($_POST['xp'])) echo $_POST['xp']; ?>" /></td></tr> <?php if ($ignore !=1){ echo '<tr><td align=right><font class="text2">Members?:</font></td><td align=left><input type="text" class="text" name="members" size="1" maxlength="1" value="'.$_POST['members'].'" /><font class="small2">Use Y or N only</font></td></tr> '; } ?> </table> </td> </tr> <tr> <td> <div align="center"><input type="submit" name="submit" value="Add Calculator item" class="liteoption" /> <input type="reset" name="reset" value="reset" class="liteoption" /></div> </td> </tr> </table> </CENTER> </form> <?php } function editcalcitem($calc){ $ignore = $_GET['ignore']; $id = $_GET['id']; /* query for item */ $query = "SELECT * FROM ".$calc." WHERE id='$id'"; $result = mysql_query ($query); /* if we get no results back, error out */ $numrtn = mysql_num_rows($result); if ($numrtn == 0) { echo "The calculator item requested cannot be found\n"; return; } $row = mysql_fetch_assoc($result); /* easier to read variables and * striping out tags */ $name = $row['item']; $members = $row['members']; if ($members == "1"){ $members ="Y"; }else{ $members ="N"; } $xp = $row['xp']; $level = $row['level']; $ignore = $_GET['ignore']; if (isset($_POST['submit'])){ //handle form require_once ('../mysql_connect.php');//connect to db $name = escape_data($_POST['name']); $level = escape_data($_POST['level']); if ($ignore != 1){ $members = strtoupper(escape_data($_POST['members'])); if ($members == "Y"){ $members =1; }else{ $members =0; } } $xp = escape_data($_POST['xp']); if ($name && $level && $xp){//if evrything is ok $query = "UPDATE ".$calc." SET item = '$name', level = '$level', xp = '$xp' , members='$members' WHERE id='$id'"; $result = @mysql_query ($query); //Run the query. if ($result){ //if it entered correctly echo '<br /><table width=98% bgcolor=#565866 class=pass align=center><tr> <td width=40><img src=images/tick.gif></td> <td align=left> <B>Success</B> <BR> The item '.$name.'\' was successfully added<br /> </table><br /><br />'; include ('difffooter.inc');//footer exit(); }else{ // didn't work echo '<table width=98% bgcolor=#565866 class=logfail align=center><tr> <td width=40><img src=images/exclamation.gif></td> <td align=left> <B>Update Failed!</B> <BR> The item '.$name.'\ could not be added <BR>Please Try again later<br /> </table><br /><br />'; } } } ?> <br /><font class="adminheader"><center>Edit Calculator item</center></font><br /> Here you can add items to calculators. Be sure to give credit properly where it is due!<br /> <form action="admin2.php?flibble=add_citem" method="post"><center> <table class=calc> <tr><td> <table> <tr><td align=right><font class="text2">Item name:</font></td><td align=left><input type="text" class="text" name="name" size="15" maxlength="30" value="<?php echo $name; ?>" /></td></tr> <tr><td align=right><font class="text2">Level:</font></td><td align=left><input type="text" class="text" name="level" value="<?php echo $level; ?>" /></td></tr> <tr><td align=right><font class="text2">XP(to decimal if possible):</font></td><td align=left><input type="text" class="text" name="xp" value="<?php echo $xp; ?>" /></td></tr> <?php if ($ignore !=1){ echo '<tr><td align=right><font class="text2">Members?:</font></td><td align=left><input type="text" class="text" name="members" size="1" maxlength="1" value="'.$members.'" /><font class="small2">Use Y or N only</font></td></tr> '; } ?> </table> </td> </tr> <tr> <td> <div align="center"><input type="submit" name="submit" value="Add Calculator item" class="liteoption" /> <input type="reset" name="reset" value="reset" class="liteoption" /></div> </td> </tr> </table> </CENTER> </form> <?php } //------------------------End Calc-------------------------------------------// New code - Add section. /* RuneHints CMS */ /* Achievements Add Submit */ /* Achievements Add Form */ if (($admin == 'achievements') && ($_POST['add'])) { $added = time(); $sql = "INSERT INTO `achi` (id, name, added, guideby, contributors, members, mainbody, updated, sorter) VALUES ('', '{$_POST['name']}', '$added', '{$_POST['guideby']}', '{$_POST['contributors']}', '{$_POST['members']}', '{$_POST['mainbody']}', '', '{$_POST['sorter']}' )"; $result = $db->query($sql); echo '<div class="msgOk"><span>Success</span>Record was added successfully.</div>'; } if ($admin == 'achievements') { echo '<p> <form action="" method="post"> <table> <tr> <td>Achievement Name:</td> <td><input type="text" name="name"/></td> </tr> <tr> <td>Guide By:</td> <td><input type="text" name="guideby"/></td> </tr> <tr> <td>Contributors:</td> <td><input type="text" name="contributors"/></td> </tr> <tr> <td>Members:</td> <td><input type="text" name="members"/></td> </tr> <tr> <td style="vertical-align:top;">Main Body:</td> <td> <textarea id="elm1" name="mainbody" rows="30" cols="80" width="60%"> </textarea> </td> </tr> <tr> <td>Sorter:</td> <td><input type="text" name="sorter"/></td> </tr> <tr> <td></td> <td><input type="submit" name="add" value="Add"/></td> </tr> </table> </form> </p>'; } New code edit section. /* RuneHints CMS */ /* Achievement Edit Submit */ /* Achievement Edit Form */ /* Achievement Add Submit */ /* Achievement Add Form */ /* Achievement Echo Records */ if (($admin == 'achievements') && ($_POST['edit'])) { $updated = time(); $sql = "UPDATE `achi` SET `name` = '{$_POST['name']}', `guideby` = '{$_POST['guideby']}', `contributors` = '{$_POST['contributors']}', `members` = '{$_POST['members']}', `mainbody` = '{$_POST['mainbody']}', `updated` = '$updated', `sorter` = '{$_POST['sorter']}' WHERE `id` = '{$id}'"; $result = $db->query($sql); echo '<div class="msgOk"><span>Updated</span>Record was updated successfully.</div>'; } if (($admin == 'achievements') && (!empty($id))) { $sql = "SELECT * FROM achi WHERE `id` = '{$id}'"; $result = $db->query($sql); while ($row = $db->fetch($result)) { echo '<p> <form action="" method="post"> <table> <tr> <td>Achievement Name:</td> <td><input type="text" name="name" value="'.$row['name'].'"/></td> </tr> <tr> <td>Guide By:</td> <td><input type="text" name="guideby" value="'.$row['guideby'].'"/></td> </tr> <tr> <td>Contributors:</td> <td><input type="text" name="contributors" value="'.$row['contributors'].'"/></td> </tr> <tr> <td>Members:</td> <td><input type="text" name="members" value="'.$row['members'].'"/></td> </tr> <tr> <td style="vertical-align:top;">Main Body:</td> <td> <textarea name="mainbody" rows="30"> '.$row['mainbody'].' </textarea> </td> </tr> <tr> <td>Sorter:</td> <td><input type="text" name="sorter" value="'.$row['sorter'].'"/></td> </tr> <tr> <td></td> <td><input type="submit" name="edit" value="Submit"/></td> </tr> </table> </form> </p>'; } } elseif (($admin == 'achievements') && (empty($id))) { $sql = "SELECT * FROM achi"; $result = $db->query($sql); echo '<table class="guide"> <tr class="trtitle"> <th>Achievement Name</td> <th>Delete</td> </tr>'; while ($row = $db->fetch($result)) { echo '<tr style="border-bottom: 1px solid #a07c3c;"> <td><a href="edit/'.$row[id].'">'.$row[name].'</a></td> <td><a href="delete/'.$row[id].'"><img src="/images/error.png" border="0" alt="Delete"></a></td> </tr>'; } echo '</table>'; } Our delete code. <?php if(isset($_GET['id']) && !isset($_POST['yes']) && !isset($_POST['no'])) { $id = (int) $_GET['id']; echo "Are you sure you want to delete this record."; echo "<form method='post' action=''>"; echo "<input type='hidden' name='id' value='{$_POST['id']}'>"; echo "<input type='submit' value='Yes' name='yes'>"; echo "<input type='submit' value='No' name='no'>"; echo "</form>"; } if (isset($_POST['no'])) { echo "<meta http-equiv='refresh' content='0;url=/admincp/' />"; } if (isset($_POST['yes'])) { if ($admin == 'skills') { $sql = "DELETE FROM `skill` WHERE `id` = '$_GET[id]'"; } if ($admin == 'quests') { $sql = "DELETE FROM `quest` WHERE `id` = '$_GET[id]'"; } if ($admin == 'achievements') { $sql = "DELETE FROM `achi` WHERE `id` = '$_GET[id]'"; } if ($admin == 'special') { $sql = "DELETE FROM `sp` WHERE `id` = '$_GET[id]'"; } if ($admin == 'location') { $sql = "DELETE FROM `location` WHERE `id` = '$_GET[id]'"; } if ($admin == 'maps') { $sql = "DELETE FROM `map` WHERE `id` = '$_GET[id]'"; } if ($admin == 'guilds') { $sql = "DELETE FROM `guild` WHERE `id` = '$_GET[id]'"; } if ($admin == 'randoms') { $sql = "DELETE FROM `random` WHERE `id` = '$_GET[id]'"; } $result = $db->query($sql); echo '<div class="msgOk"><span>Success</span>Record was deleted successfully.</div>'; } ?>
  16. Okay, so this is my first real php script from scratch. This is the theory of the script I am writing. Mysql database connect script already done. So, first things I need to do is connect, right? <?php //connect to db require_once ('includes/connect.php'); //connect to table $result = mysql_query ("select * FROM shop1"); //display data in table echo "<table border='1'><tr><td>Shop</td><td>city</td><td>members</td></tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['city'] . "</td>"; echo "<td>" . $row['members'] . "</td>"; echo "</tr>"; } echo "</tr></table>"; ?> Displays this, http://67.23.249.45/~gaogier/shop1.php What do you think so far? Whats still to come. How do I link 2 tables together? I mean, I plan to have many shops displayed, then, inside the shop, have the items, which will be linked to each shop. I plan to link each shop to a different page, which will be displayed like, url/shop/shopname If you are confused, i need to have a working shop database that works like this, http://www.tip.it/runescape/?rs2shops I don't care about styling at the moment, I just want the script to work. What do I do now?
  17. Problem - http://runehints.com/calculators/mining?rsname=gaogier&action=calculator So far all is correct, once you click calculate the problems start. If I do a little math, level 67 is the target, with 548028 xp, minus the current xp of 533469 that = 14559 14559 / 50 xp per coal = x amount of coal which is 291.18 coal. Now, my calculator is saying, 33173 is the answer. Which it clearly is not the case. The URL I get, http://runehints.com/calculators/mining?rsname=gaogier&action=calculate&cxp=533469&lvl=2192114 if you change the last part (2192114) to 548028 it nearly works out to be right, as it shows 291 coal. http://runehints.com/calculators/mining?rsname=gaogier&action=calculate&cxp=533469&lvl=548028 I plan to get this script rewritten over the next couple of months, is it worth fixing it? I mean can you spot the error? <?php preg_match('~calculators\/([a-zA-Z]+)~', $_SERVER['REQUEST_URI'], $which); $which = $which[1]; ?> <div id="contenttitle"><?php echo ucfirst($which); ?> Calculator</div> <div class="news"> <?php preg_match('~(agility|attack|combat|cooking|crafting|defence|farming|firemaking|fishing|fletching|herblore|hitpoints|magic|mining|prayer|ranged|runecrafting|slayer|strength|summoning|thieving|woodcutting)~', $_SERVER['REQUEST_URI'], $url); $uri = $url[1]; if (empty($uri)) { echo '<table class="guide"> <tr class="trtitle"> <th class="main">Skill Name</th> <tr> <tr> <td><a href="/calculators/agility">Agility</a></td> <tr> <tr> <td><a href="/calculators/attack">Attack</a></td> <tr> <tr> <td><a href="/calculators/cooking">Cooking</a></td> <tr> <tr> <td><a href="/calculators/crafting">Crafting</a></td> <tr> <tr> <td><a href="/calculators/defence">Defence</a></td> <tr> <tr> <td><a href="/calculators/farming">Farming</a></td> <tr> <tr> <td><a href="/calculators/fishing">Fishing</a></td> <tr> <tr> <td><a href="/calculators/fletching">Fletching</a></td> <tr> <tr> <td><a href="/calculators/herblore">Herblore</a></td> <tr> <tr> <td><a href="/calculators/hitpoints">Hitpoints</a></td> <tr> <tr> <td><a href="/calculators/magic">Magic</a></td> <tr> <tr> <td><a href="/calculators/mining">Mining</a></td> <tr> <tr> <td><a href="/calculators/prayer">Prayer</a></td> <tr> <tr> <td><a href="/calculators/ranged">Ranged</a></td> <tr> <tr> <td><a href="/calculators/runecrafting">Runecrafting</a></td> <tr> <tr> <td><a href="/calculators/slayer">Slayer</a></td> <tr> <tr> <td><a href="/calculators/strength">Strength</a></td> <tr> <tr> <td><a href="/calculators/summoning">Summoning</a></td> <tr> <tr> <td><a href="/calculators/thieving">Thieving</a></td> <tr> <tr> <td><a href="/calculators/woodcutting">Woodcutting</a></td> <tr> </table>'; } else { # All Calculator - calculate.php # Orignally created on 28 December 2004 remade using RS Hiscores on 9 June 2005 # Created by Joseph Jeffery of DSIBaN Designs //This page functions as every calculator //set page headers $lvl = 0; preg_match('~rsname=(.*)&action~', $_SERVER['REQUEST_URI'], $rsnam); $rsn = $rsnam[1]; /** * Return current xp for specific skill */ function return_exp($name, $skill) { $url = "http://hiscore.runescape.com/index_lite.ws?player=" . strtolower(str_replace(' ', '_', $name)); if (($page = @file_get_contents($url)) === false) { echo "User $name was not found in the highscores for $skill"; return false; } if(strpos($page, "<html>")) { trigger_error('Unable to parse RuneScape highscore page', E_USER_WARNING); echo "<h1>DUMP</h1>"; } $catagories = split(' ', $page); //Find proper index for skill switch($skill) { case "attack": $ind = 1; break; case "defence": $ind = 2; break; case "strength": $ind = 3; break; case "constitution": $ind = 4; break; case "ranged": $ind = 5; break; case "prayer": $ind = 6; break; case "magic": $ind = 7; break; case "cooking": $ind = 8; break; case "woodcutting": $ind = 9; break; case "fletching": $ind = 10; break; case "fishing": $ind = 11; break; case "firemaking": $ind = 12; break; case "crafting": $ind = 13; break; case "smithing": $ind = 14; break; case "mining": $ind = 15; break; case "herblore": $ind = 16; break; case "agility": $ind = 16; break; case "thieving": $ind = 17; break; case "slayer": $ind = 18; break; case "farming": $ind = 20; break; case "runecrafting": $ind = 21; break; case "hunter": $ind = 22; break; case "construction": $ind = 23; break; case "summoning": $ind = 24; break; case "dungeoneering": $ind = 25; break; } $skill_info = split(",", $catagories[$ind]); $skill_exp = $skill_info[2]; return $skill_exp; } function enter_name(){ $skill = $_GET['skill']; $mem = $_GET['members']; $_GET['action'] = 'calculator'; preg_match('~rsname=(.*)&action~', $_SERVER['REQUEST_URI'], $rsnam); $rsn = $rsnam[1]; preg_match('~&action=(.*)~', $_SERVER['REQUEST_URI'], $action); $_GET['action'] = $action[1]; echo '<form action="" method="get"> <p>Runescape name: <input type="text" name="rsname" class="text" value="' . $rsn . '" /> <input type="hidden" name="action" value="calculator" /></p> <input type="submit" class="text" value="Grab XP" onMouseOver="this.style.cursor=\'hand\';"/> </form><br /> '; } function calculator(){ preg_match('~rsname=(.*)&action~', $_SERVER['REQUEST_URI'], $rsnam); $rsn = $rsnam[1]; preg_match('~calculators\/(.*)\?rsname~', $_SERVER['REQUEST_URI'], $skill); $skill = $skill[1]; preg_match('~&action=(.*)~', $_SERVER['REQUEST_URI'], $action); $_GET['action'] = $action[1]; if($rsn != "") { $xp = return_exp($rsn, $skill); } $mem = $_GET['members']; if ($xp > 13034430){ echo 'You\'re already level 99!'; } ?> <form action="" method="get"> <table border="0" class="calcinput"> <input type="hidden" name="rsname" value="<?php echo $rsn; ?>"> <input type="hidden" name="action" value="calculate" /> <tr><td>Current Xp:</td><td> <input type="text" name="cxp" class="text" value="<?php if ($xp != "0") { echo $xp; } ?>" /></td></tr> <tr><td>Current Level:</td><td><input type="text" class="text" value="<?php echo getLevel($xp); ?>" /></td></tr> <tr><td>Desired Level:</td><td> <SELECT name="lvl" class="text"><?php genDropDown($xp); ?> </select> <?php if ($mem == "yes"){ echo '<tr><td>Show members items?:</td><td> <input name="showmembers" type="checkbox" disabled="true" value="yes" checked></td></tr> '; }else{ echo '<tr><td>Hide members items?:</td><td> <input name="showmembers" type="checkbox" value="no"></td></tr> '; } ?> <tr><td><input type="submit" class="text" value="Calculate" onMouseOver="this.style.cursor='hand';"/></td><td> <input type="reset" class="text" value="Reset" onMouseOver="this.style.cursor='hand';"/></td></tr> </table> <?php } /*Calculate level based on experience function getLevel($xp) { $a = 0; for($i = 0; $i < 100; $i++) { if($a / 4 > $xp) { return $i; } $a += floor($i + 300 * pow(2, ($i / 7))); } } */ function getLevel($exp){ $levels = array(1 => 0, 83, 174, 276, 388, 512, 650, 801, 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115, 3523, 3973, 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824, 12031, 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473, 30408, 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983, 75127, 83014, 91721, 101333, 111945, 123660, 136594, 150872, 166636, 184040, 203254, 224466, 247866, 273742, 302288, 333804, 368599, 407015, 449428, 496254, 547953, 605032, 668051, 737627, 814445, 899256, 992895, 1096278, 1210421, 1336443, 1475581, 1629200, 1798808, 1968068, 2192818, 2421087, 2673114, 2951373, 3258594, 3597729, 3972294, 4385776, 4842295, 5346332, 5902831, 6517253, 7195629, 7994614, 8771558, 9684577, 10692629, 11805606, 13034431); $l = count($levels); while ($levels[$l] > $exp) $l--; return $l; } //Generate dropdowns based on xp function genDropDown($xp) { //Gather experience $a = 0; for($i = 0; $i < 100; $i++) { if($a / 4 > $xp) { if($lvl == 0) { $lvl = $i; } echo "<option value=\"$a\">Level $i - " . floor($a / 4) . " xp</option>"; } $a += floor($i + 300 * pow(2, ($i / 7))); } } function calculate(){ preg_match('~&lvl=(.*)~', $_SERVER['REQUEST_URI'], $lvl); $lvl = $lvl[1]; preg_match('~&cxp=(.*)&lvl~', $_SERVER['REQUEST_URI'], $cxp); $cxp = $cxp[1]; preg_match('~rsname=(.*)&action~', $_SERVER['REQUEST_URI'], $rsnam); $rsn = $rsnam[1]; preg_match('~calculators\/(.*)\?rsname~', $_SERVER['REQUEST_URI'], $skills); $skills = $skills[1]; preg_match('~&action=(.*)~', $_SERVER['REQUEST_URI'], $action); $_GET['action'] = $action[1]; $lev = $_POST['lev']; $xpn = $lvl - $cxp; if ($xpn == ""){ $xpn = $_GET['xpn']; } if ($lev == ""){ $lev = $_GET['lev']; } $show = $_GET['showmembers']; if ($show == "0"){ $show = $_POST['showmembers']; } switch($skills) { case 'firemaking': $skill = "fire"; $item = "Log"; break; case 'runecrafting': $skill = "rune"; $item = "Rune"; break; case 'ranging': $skill = "range"; $item = "Monster"; break; case 'herblore': $skill = "herb"; $item = "Herb/Potion"; break; case 'fishing': $skill = "fish"; $item = "Fish"; break; case 'cooking': $skill = "cook"; $item = "Food"; break; case 'woodcutting': $skill = "wood"; $item = "Log"; break; case 'agility': $skill = "agility"; $item = "Course"; break; case 'slayer': $skill = "slayer"; $item = "monster"; break; case 'farming': $skill = "farming"; $item = "Seed/Action"; break; case 'fletching': $skill = "fletching"; $item = "Item"; break; case 'magic': $skill = "magic"; $item = "Spell"; break; case 'mining': $skill = "mining"; $item = "Ore"; break; case 'smithing': $skill = "smithing"; $item = "Bar"; break; case 'thieving': $skill = "thieving"; $item = "Chest/Stall/Pickpocket"; break; case 'fighting': $skill = "fighting"; $item = "Monster"; break; case 'crafting': $skill = "crafting"; $item = "Item"; break; case 'prayer': $skill = "prayer"; $item = "Bones"; break; default: $skill = $skill[1]; $item = "Item"; } $mem = $_GET['members']; echo' <table border="0.5" cellspacing="1" cellpadding="2" align="center" bgcolor="#857553"> <tr><td class="tableheader"><a style="color: #EED8B4" href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=level&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers='.$show.'">Level needed</a></td><td class="tableheader"><a style="color: #EED8B4" href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=item&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers='.$show.'">'.$item.'</a></td><td class="tableheader"><a style="color: #EED8B4" href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=xp&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers='.$show.'">Experience given</a></td><td class="tableheader"><a style="color: #EED8B4" href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=xp&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers='.$show.'">Number of times</a></td><td class="tableheader"><a style="color: #EED8B4" href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=members&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers='.$show.'">Members?</a></td>'; require_once ('includes/connect.php');//connect to db $by = $_GET['orderby']; if ($mem == "no"){ if ($show == "no"){ $mess = '<a href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=level&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers=no">Click here to show members items</a>'; $n_query = 'SELECT * FROM `'.$skill.'calc` WHERE `members`="0" ORDER BY `'.$by.'` ASC'; }else{ $mess = '<a href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=level&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers=yes">Click here to hide members items</a>'; $n_query = 'SELECT * FROM `'.$skill.'calc` ORDER BY `'.$by.'` ASC'; } }else{ $n_query = 'SELECT * FROM `'.$skill.'calc` ORDER BY `'.$by.'` ASC'; } $n_result = mysql_query ($n_query); while ($n_row = mysql_fetch_assoc($n_result)) { $level = $n_row['level']; $course = $n_row['item']; $xpg = $n_row['xp']; $tot1 = $xpn / $xpg; $tot = sprintf('%.0f', $tot1); $members1 = $n_row['members']; if ($members1 == "1"){ $members = "Yes"; $bg2 = "#808080"; }else{ $members = "No"; $bg2 = "#FF8C00"; } if ($lev < $level){ $bg = "#049f2c"; }else{ $bg = "#006600"; } echo '<tr><td class="calc" bgcolor="'.$bg.'"onMouseOver="this.style.backgroundColor=\'#71828A\'" onMouseOut=this.style.backgroundColor="'.$bg.'">'.$level.'</td><td>'.$course.'</td><td>'.$xpg.'</td><td>'.$tot.'</td><td class="calc" bgcolor="'.$bg2.'" onMouseOver="this.style.backgroundColor=\'#71828A\'" onMouseOut=this.style.backgroundColor="'.$bg2.'">'.$members.'</td>'; } echo' </table><br /> '; echo $lev; } preg_match('~rsname=(.*)&action~', $_SERVER['REQUEST_URI'], $rsnam); $rsn = $rsnam[1]; preg_match('~calculators\/(.*)\?rsname~', $_SERVER['REQUEST_URI'], $skill); $skill = $skill[1]; preg_match('~&action=([a-zA-Z0-9]+)~', $_SERVER['REQUEST_URI'], $action); $_GET['action'] = $action[1]; switch($_GET['action']) { case 'calculate': enter_name(); calculate(); break; case 'calculator': enter_name(); calculator(); break; case 'enter_name': enter_name(); calculator(); break; default: enter_name(); } } ?> </div>
  18. Just the field type text it hold 64kb. Is there anyway to expand this? You know what I mean now? other field types, INT, varchar, ect.
  19. how do I make a text field bigger/hold more info?
  20. hello I have a website thats powered by php and mysql. I currently can't add any more info into the mysql database. The main body is too large, its a text type, not int, varchar, or anything else.
  21. Hello I have a php 3 and php 4 book, which I never really read not alone learnt anything, I only used this to keep my site going, however I am really interested in moving my sites forward further, however I am not sure how. I have been looking for a php 5 book but the book is sold out everywhere. I am therefore interested in a php 6 book, anyone know if I should get this book or not?
  22. Ok, I have readded that code to the site, take a look at what it is doing. http://runehints.com
  23. Basically, if you look at my site, http://runehints.com - left hand menu's v right hand menu's. I want the calculators to be like the left hand ones as they are not stats. <ul class="01"> <li ><a href="/">Home </a></li> <li ><a href="/forums">Forums </a></li></ul> Here is the whole php code. <?php $calc_query = "SELECT id, name, members FROM calc ORDER BY name ASC"; $calc_result = mysql_query ($calc_query); while ($calc_row = mysql_fetch_assoc($calc_result)) { $calc_name = $calc_row['name']; $name = strtolower($calc_name); $m = $calc_row['members']; if ($m == "Y"){ $mem = "yes"; }else{ $mem = "no"; } echo '<img src="images/none.gif" height="11" width="11"> <a href="calculate.php?action=enter_name&skill='. $name. '&members=' .$mem. '">'. $calc_name. '</a><br>'; } ?> My thoughts. <ul class="01"><?php $calc_query = "SELECT id, name, members FROM calc ORDER BY name ASC"; $calc_result = mysql_query ($calc_query); while ($calc_row = mysql_fetch_assoc($calc_result)) { $calc_name = $calc_row['name']; $name = strtolower($calc_name); $m = $calc_row['members']; if ($m == "Y"){ $mem = "yes"; }else{ $mem = "no"; } echo '<li ><img src="images/none.gif" height="11" width="11"> <a href="calculate.php?action=enter_name&skill='. $name. '&members=' .$mem. '">'. $calc_name. '</a></li>'; } ?></ul>
  24. echo"<img src=\"images/none.gif\" height=\"11\" width=\"11\"> <a href=\"calculate.php?action=enter_name&skill=".$name."&members=".$mem."\">$calc_name</a><br>"; This is what I need to enter, <ul class="02" ><li > </li></ul> so each new line is different... any ideas? I think its really simple, just can't see it.
×
×
  • 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.