moogle1979 Posted January 4, 2009 Share Posted January 4, 2009 I set in the code and I know there is no errors however when I test out the code, it is not updating the database at all. Here is the code <?php require('includes/required.php'); if($_SESSION['login'] != "yessir") { header("Location: ".$SITE_ROOT."includes/msg.php?code=11"); exit(); } if (isset($_POST['submit'])){ $user = $_POST['uname']; $update = mysql_query("UPDATE mod_box SET claimed = 'yes' WHERE report_user = '" . $uname . "'") or die(mysql_error()); } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Rigganmore - Moderator Panel</title> <script type="text/javascript" src="general.js"></script> <link href="general.css" type="text/css" rel="stylesheet" /> </head> <body> <table width="800" border="0" align="center" cellpadding="0" cellspacing="0" class="logo"> <!--DWLayoutTable--> <tr> <td width="106" height="52"> </td> <td width="320"> </td> <td width="99"> </td> <td width="246"> </td> <td width="29"> </td> </tr> <tr> <td height="99"> </td> <td> </td> <td> </td> <td rowspan="2" align="center" valign="middle" class="loginform"> <!-- Login Form php statement--> <?php if($_SESSION['login'] == "yessir"){ ?> <!-- Start of players Stats --> <div align="center" style="font-weight:bold;font-size:16px;">Your Stats</div> <a href="display.php"> <img src="./images/avatars/<? echo $_SESSION['dp']; ?>" alt="<? echo $_SESSION['name']; ?>'s Avatar" name="dp" width="100" height="100" align="left" style="border: solid #006699 1px;" /> </a> <div align="center"> <img src="<? echo $_SESSION['access_img']; ?>" alt="<? echo $_SESSION['status']; ?>" /> </div> <table align="center" width="25%" border="0" style="font-size:14px;"> <tr> <td width="8%"><div align="right"><b>Money:</b></div></td> <td width="92%"><? echo $_SESSION['money']; ?></td> </tr> <tr> <td><div align="right"><b>Bank:</b></div></td> <td><? echo $_SESSION['bank']; ?></td> </tr> <tr> <td><div align="right"><b>Lvl:</b></div></td> <td><? echo $_SESSION['lvl']; ?></td> </tr> <tr> <td><div align="right"><b>HP:</b></div></td> <td><? echo $_SESSION['hp']; ?></td> </tr> <tr> <td><div align="right"><b>Exp:</b></div></td> <td><? echo $_SESSION['exp']; ?></td> </tr> </table> <!-- End of players Stats --> <?php } else { ?> <!-- Login Form --> <form action="login.php" method="post" name="login" id="login"> <p align="center" class="style1 style9"><strong>Login</strong></p> <table width="80%" border="0" align="center"> <tr> <td>Username:</td> <td><input type="text" name="user" id="user" class="textbox" /></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="pass" id="pass" class="textbox" /></td> </tr> <tr> <td><input type="hidden" name="date" id="date" value="<?php echo date("m/d/y @ g:i a"); ?>" /></td> <td> <label> <input type="submit" name="btnLogin" id="btnLogin" value="" class="login" /> </label> </td> </tr> </table> <a href="forgot.php">Forgotten Password</a> </form> <?php } ?> </td> <td></td> </tr> <tr> <td height="20"> </td> <td align="center" valign="middle" class="stats"> <strong> <?php if($_SESSION['login'] != "yessir"){ echo "Please <a href='signin.php'>Login</a> to View your Stats"; } else { echo "<font color='#d9e1bc'>Welcome, ".$_SESSION['name']."! (".$_SESSION['userid'].")</font><br>"; echo "<a href='logout.php'>Logout</a>"; } ?> </strong> </td> <td> </td> <td></td> </tr> <tr> <td height="15"></td> <td></td> <td></td> <td></td> <td></td> </tr> </table> <table width="800" border="0" align="center" cellpadding="0" cellspacing="0"> <!--DWLayoutTable--> <tr> <!-- Main Nav links --> <td width="800" height="25" align="center" valign="middle" bgcolor="#003366" style="border:solid;border-color:#136A93;border-width:thin;"> <a href="estate.php"><img src="images/gifs/home.gif" alt="Home" width="60" height="25" border="0"></a> <img src="images/gifs/asterisk.gif" alt="" width="25" height="25"> <a href="about.php"><img src="images/gifs/aboutus.gif" alt="About Us" width="91" height="25" border="0"></a> <img src="images/gifs/asterisk.gif" alt="" width="25" height="25"> <a href="faq.php"><img src="images/gifs/faqs.gif" alt="FAQ's" width="61" height="25" border="0"></a> <img src="images/gifs/asterisk.gif" alt="" width="25" height="25"> <a href="contact.php"><img src="images/gifs/ContactUs.gif" alt="Contact Us" width="108" height="25" border="0"></a> <img src="images/gifs/asterisk.gif" alt="" width="25" height="25"> <a href="./forums/"><img src="images/gifs/forums.gif" alt="Forums" width="75" height="25" border="0"></a> <img src="images/gifs/asterisk.gif" alt="" width="25" height="25"> <a href="links.php"><img src="images/gifs/links.gif" alt="Links" width="56" height="25" border="0"></a> <img src="images/gifs/asterisk.gif" alt="" width="25" height="25"> <a href="prereg/prereg.php"><img src="images/gifs/prereg.gif" alt="Pre-Register" width="120" height="25" border="0"></a> </td> </tr> </table> <table width="800" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#003366"> <!--DWLayoutTable--> <tr> <td width="630" height="2"></td> <td width="170"></td> </tr> <tr> <td height="498" valign="top" style="border:solid;border-color:#136A93;border-width:thin;border-right:none;"> <!-- Main Body --> <div class="apDiv1"> <table width="90%" border="0" align="center"> <tr> <td height="189" valign="top"> <p align="center"> <span class="style14"> <span class="style1">Moderator Panel</span><br /> </span> </p> <p align="center"> <span class="style14"> THIS PAGE IS INCOMPLETE!<br /> This page currently only contains a few links to various Moderation pages on the website. But shortly, there will be a full Moderator panel with membership information, editing, reports, tools and much more! </span> </p> <p align="center"> <a href="/mod">Content Management</a> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> <a href="mod/log.php">Logs</a> </p> <p align="center"> <?php $query = mysql_query("SELECT * FROM mod_box WHERE claimed='no' ORDER BY box_id"); while ($result = mysql_fetch_array($query)){ ?> <table style=text-align:center" style="border: 2px solid #006699"> <tr> <td style="text-align:center" colspan="2" style="border: 1px solid #006699"> Reports </td> </tr> <form action="mod.php" method="post"> <tr> <td style="border: 1px solid #006699"> <?php echo $result['report_type']; ?> </td> <td style="border: 1px solid #006699"> <?php echo $result['report_user']; ?> </td> </tr> <tr> <td colspan="2" style="border: 1px solid #006699"> <?php echo $result['report_type']; ?> </td> </tr> <tr> <td> <input type="text" name="uname id="uname" value="<?php echo $result['report_user']; ?>" /> <input type="submit" name="submit" value="Claim" /> </td> </tr> </form> </table> <?php } $query = mysql_query("SELECT * FROM mod_box WHERE claimed='yes' ORDER BY box_id"); while ($result = mysql_fetch_array($query)){ ?> <table style=text-align:center" style="border: 2px solid #006699"> <tr> <td style="text-align:center" colspan="2" style="border: 1px solid #006699"> Claimed Reports </td> </tr> <tr> <td style="border: 1px solid #006699"> <?php echo $result['report_type']; ?> </td> <td style="border: 1px solid #006699"> <?php echo $result['report_user']; ?> </td> </tr> <tr> <td colspan="2" style="border: 1px solid #006699"> <?php echo $result['report_type']; ?> </td> </tr> </table> <?php } ?> </p> </td> </tr> </table> </div> </td> <!-- Side links --> <td align="center" valign="top" style="border:solid;border-color:#136A93;border-width:thin;"> <p> <a href="box.php"><img src="images/gifs/nav2_boxes.gif" width="50" height="23" border="0" /></a><br /> <img src="images/gifs/asterisk.gif" width="25" height="25" /><br /> <a href="news.php"><img src="images/news.png" width="40" height="15" border="0" /></a><br /> <img src="images/gifs/asterisk.gif" alt="" width="25" height="25" /><br /> <a href="market.php"><img src="images/gifs/nav2_market.gif" width="123" height="23" border="0" /></a><br /> <img src="images/gifs/asterisk.gif" alt="" width="25" height="25" /><br /> <a href="prison.php"><img src="images/gifs/nav2_prison.gif" width="60" height="23" border="0" /></a><br /> <img src="images/gifs/asterisk.gif" alt="" width="25" height="25" /><br /> <a href="temple.php"><img src="images/gifs/nav2_temple.gif" width="60" height="23" border="0" /></a><br /> <img src="images/gifs/asterisk.gif" alt="" width="25" height="25" /><br /> <a href="help.php"><img src="images/gifs/nav2_tourists.gif" width="80" height="23" border="0" /></a><br /> <img src="images/gifs/asterisk.gif" alt="" width="25" height="25" /><br /> <a href="town.php"><img src="images/gifs/nav2_townmap.gif" width="80" height="23" border="0" /></a><br /> <img src="images/gifs/asterisk.gif" alt="" width="25" height="25" /><br /> <a href="wilderness.php"><img src="images/gifs/nav2_wild.gif" width="80" height="23" border="0" /></a><br /> <?php if ($_SESSION['login'] == "yessir"){ echo "<img src='images/gifs/asterisk.gif'><br>"; echo "<a href='members.php'><img src='images/gifs/members.gif' border='0'></a><br>"; } if ($_SESSION['access'] > 65){ echo "<img src='images/gifs/asterisk.gif'><br>"; echo "<a href='admin.php'><img src='images/gifs/admincp.gif' border='0'></a><br>"; } if ($_SESSION['access'] > 40 && $_SESSION['access'] < 60){ echo "<img src='images/gifs/asterisk.gif'><br>"; echo "<a href='mod.php'>Mod Panel Coming Soon</a><br>"; } ?> </p> </td> </tr> </table> <table width="800" border="0" align="center" cellpadding="2" cellspacing="0"> <!--DWLayoutTable--> <tr> <td width="800" height="37"> <div align="center" class="style2">Copyright 2008 © Rigganmore LLC. All Rights Reserved.<br /> Use of this site signifies your acceptance and agreement to our <a href="http://www.rigganmore.com/tos.php">Terms of Service</a>. </div> </td> </tr> </table> </body> </html> <? //End ?> Also while I am at it, how would I go about setting it up where when a report is claimed the one that sent the report receives an alert? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted January 4, 2009 Share Posted January 4, 2009 You've assigned the value of $_POST['uname'] to $user, but then used the undefined variable $uname to update with. This is why you should develop with error_reporting set to E_ALL and errors turned on - you would then have got an error message instead of scratching your head trying to figure out what went wrong. Quote Link to comment Share on other sites More sharing options...
moogle1979 Posted January 4, 2009 Author Share Posted January 4, 2009 it is still not updating it Quote Link to comment Share on other sites More sharing options...
revraz Posted January 4, 2009 Share Posted January 4, 2009 Separate your query string from your mysql_query function, then echo the query so you can actually see what it's trying to do. Quote Link to comment Share on other sites More sharing options...
moogle1979 Posted January 4, 2009 Author Share Posted January 4, 2009 Separate your query string from your mysql_query function, then echo the query so you can actually see what it's trying to do. I did this $user = $_POST['uname']; $update = "UPDATE mod_box SET claimed = 'yes' WHERE report_user = '" . $user . "'"; $query = mysql_query($update) or die ("Database Error"); echo $query; and it echoed back a 1 which I assume means true, however it did not update it Quote Link to comment Share on other sites More sharing options...
xtopolis Posted January 4, 2009 Share Posted January 4, 2009 echo $update Copy and paste that text into your console or phpmyadmin and test it directly. Let us know if that works or not. Quote Link to comment Share on other sites More sharing options...
moogle1979 Posted January 5, 2009 Author Share Posted January 5, 2009 I fixed it, I set in a hidden value and called the hidden value to determine which one it was and it worked Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.