gaogier Posted June 12, 2008 Share Posted June 12, 2008 Warning: Unexpected character in input: '' (ASCII=28) state=1 in /home/gaogier/public_html/admin.php on line 278 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/gaogier/public_html/admin.php:278) in /home/gaogier/public_html/diffhead.inc on line 3 //------------------------Begin Monster-------------------------------------------// function monster(){ $page = $_GET['page']; if(empty($page)){ $page = 1; } $limit = 25; $query_count = "SELECT id, name, lvl, members FROM monsters ORDER BY name ASC"; $result_count = mysql_query($query_count); $totalrows = mysql_num_rows($result_count); $limitvalue = $page * $limit - ($limit); echo "<p><font class=\"adminheader\">Monster Admin</font></p>"; echo "<TABLE border=\"0\" width=\"89%\" class=monster>\n"; echo "<TR><TD class=title><center>Monster Name</center></td><td class=title><center>Edit</center></TD</TR>\n"; /* query for monsters */ $query = "SELECT id, name, lvl, members FROM monsters ORDER BY name ASC LIMIT $limitvalue, $limit"; $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']; $level = $row['lvl']; /* display the data */ echo "<TR bgcolor=\"".processRow($count)."\"><TD class=\"calc\"><b>".$name."</b></td><td class=\"calc\"><a href=\"".$_SERVER['PHP_SELF'] . "?flibble=m_update&id=".$row['id']."\"><img src=\"images/admin/view.gif\" alt=\"Edit\" border=\"0\"></a> <a href=\"".$_SERVER['PHP_SELF'] . "?flibble=m_delete&id=".$row['id']."\"><img src=\"images/admin/delete.gif\" alt=\"Delete\" border=\"0\"></a></TD></TR>"; if($count == 2){ $count = 0; } } /* finish up table*/ echo "</TABLE><center>\n"; if($page != 1){ $pageprev = $page-1; echo "<a href=\"admin.php?flibble=monster&page=".$pageprev."\">Previous</a> "; }else{ echo "Previous "; } $numofpages = $totalrows / $limit; for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ echo $i." "; }else{ echo " <a href=\"admin.php?flibble=monster&page=".$i."\">".$i."</a> "; } } if(($totalrows % $limit) != 0){ if($i == $page){ echo $i." "; }else{ echo " <a href=\"admin.php?flibble=monster&page=".$i."\">".$i."</a> "; } } if(($totalrows - ($limit * $page)) > 0){ $pagenext = $page+1; echo " <a href=\"admin.php?flibble=monster&page=".$pagenext."\">Next</a>"; }else{ echo " Next"; } echo "<p><b><a href=\"http://runehints.com/admin.php?flibble=add_monster\"><img src=\"images/plus.gif\" alt=\"Add\" border=\"0\"> Add monster</a></b></p>"; } function m_update($id) { /* query for item */ $query = "SELECT * FROM monsters 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 monster 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']; $lvl = $row['lvl']; $hp = $row['hp']; $race = $row['race']; $location = $row['location']; $members = $row['members']; $examine = $row['examine']; $contrib = $row['contributedby']; $drops = $row['drops']; $picture = $row['picture']; $sxp = $row['slayerxp']; if ($members = "Y") { $mem = "Yes"; }else{ $mem = "No"; } $xphp1 = $hp * 1.3333333333333333333; $xpo = $hp * 4; $xp1 = $hp * 5.3333333333333333333; $xphp = sprintf('%.0f', $xphp1); $xp = sprintf('%.0f', $xp1); if (isset($_POST['submit'])){ //handle form require_once ('../mysql_connect.php');//connect to db $name = mysql_real_escape_string($_POST['name']); /* line 278 */ $picture = mysql_real_escape_string($_POST['picture']); $level = mysql_real_escape_string($_POST['level']); $hp = mysql_real_escape_string($_POST['hp']); $members = mysql_real_escape_string($_POST['members']); $examine = mysql_real_escape_string($_POST['examine']); $location = mysql_real_escape_string($_POST['location']); $loot = mysql_real_escape_string($_POST['drops']); $contrib = mysql_real_escape_string($_POST['contrib']); $race = mysql_real_escape_string($_POST['race']); $sxp = mysql_real_escape_string($_POST['sxp']); if ($name && $picture && $level && $hp && $members && $examine && $location && $loot && $contrib){//if evrything is ok $query = "UPDATE monsters SET name = '$name' , lvl = '$level', hp = '$hp', members = '$members', location = '$location', examine = '$examine', drops = '$loot', contributedby = $contrib', picture = '$picture', slayerxp = '$sxp' WHERE id ='$id'"; $result = @mysql_query ($query); //Run the query. if ($result){ //if it entered correctly echo "<br /><table width=98% bgcolor=#C6F4DF class=pass align=center><tr> <td width=40><img src=images/tick.gif></td> <td align=left> <B>Success</B> <BR> The ".$name."\'s data was successfully updated<br /> </table><br /><br />"; include ('difffooter.inc');//footer exit(); }else{ // didn't work echo "<table width=98% bgcolor=#faf5f4 class=logfail align=center><tr> <td width=40><img src=images/exclamation.gif></td> <td align=left> <B>Update Failed!</B> <BR> The ".$name."\'s data was could not be updated <BR>Please Try again later<br /> </table><br /><br />"; } }else{ echo "<table width=98% bgcolor=#faf5f4 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 Monster Information</font></center> <br />"; echo "<form action=\"admin.php?flibble=m_update&id=".$id."\" method=\"post\">"; ?> <table width="89%" height="334" border="0" class="monster"> <tr> <td><center><input type="text" class="text" name="name" size="15" maxlength="30" value="<?php echo "$name"; ?>" /></center></td> </tr> <tr> <td><table width="101%" height="297" border="1" class="monster"> <tr> <td height="115" width="17%">Picture:</td> <td><img src="monster/<?php echo $picture; ?>"><br /><br /><input type="text" class="text" name="picture" size="15" maxlength="30" value="<?php echo "$picture"; ?>" /></td> <td width="34%">Level:</td> <td><input type="text" class="text" name="level" size="3" maxlength="3" value="<?php echo "$lvl"; ?>" /></td> </tr> <tr> <td height="23" width="17%">Race:</td> <td><input type="text" class="text" name="race" size="15" maxlength="30" value="<?php echo "$race"; ?>" /></td> <td width="34%">Members?</td> <td><input type="text" class="text" name="members" size="1" maxlength="1" value="<?php echo "$members"; ?>" /></td> </tr> <tr> <td height="23" width="17%">Hitpoints:</td> <td><input type="text" class="text" name="hp" size="3" maxlength="4" value="<?php echo "$hp"; ?>" /></td> <td>Xp gained total:</td> <td><?php echo "$xp"; ?></td> </tr> <tr> <td height="23">Xp gained to hits:</td> <td colspan="1"><?php echo "$xphp"; ?></td> <td>Xp that goes to other combat skill:</td> <td colspan="1"><?php echo "$xpo"; ?></td> <tr> <td height="23" width="17%">Location:</td> <td><input type="text" class="text" name="location" value="<?php echo "$location"; ?>" /></td> <td width="34%">Examine:</td> <td><input type="text" class="text" name="examine" value="<?php echo "$examine"; ?>" /></td> </tr> <tr> <td height="74" width="17%">Contributed by:</td> <td><input type="text" class="text" name="contrib" value="<?php echo $contrib; ?>" /></td> <td width="34%">Loot:</td> <td><textarea name="loot" rows="18" cols="50"><?php echo $drops; ?></textarea></td> </tr> <tr> <td>Slayer XP:</td> <td><input type="text" class="text" name="sxp" size="3" maxlength="4" value="<?php echo "$sxp"; ?>" /></td> </tr> </table></td> </tr> </table> <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 m_delete($id){ $query = "SELECT `name` FROM monsters 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 monster 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 `monsters` WHERE `id` = ".$id." LIMIT 1"; $result = mysql_query($query); if ($result) { ob_end_clean(); header("http://runehints.com/admin.php?flibble=monster"); } } echo "<table width=98% bgcolor=#faf5f4 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=\"admin.php?flibble=m_delete&id=".$id."\" method=\"post\"><input type=\"submit\" name=\"yes\" value=\"Yes\" class=\"delete\" /> <input name=\"no\" type=button onClick=\"javascript&#38;#058;history.go(-1)\" value=\"No\" class=\"delete\" /></form> </table><br /><br />"; } function add_monster() { if (isset($_POST['submit'])){ //handle form require_once ('../mysql_connect.php');//connect to db $name = mysql_real_escape_string($_POST['name']); $picture = mysql_real_escape_string($_POST['picture']); $level = mysql_real_escape_string($_POST['level']); $hp = mysql_real_escape_string($_POST['hp']); $members = mysql_real_escape_string($_POST['members']); $examine = mysql_real_escape_string($_POST['examine']); $location = mysql_real_escape_string($_POST['location']); $loot = mysql_real_escape_string($_POST['loot']); $contrib = mysql_real_escape_string($_POST['contrib']); $race = mysql_real_escape_string($_POST['race']); $slayer = mysql_real_escape_string($_POST['sxp']); if ($name && $picture && $level && $hp && $members && $examine && $location && $loot && $contrib){//if evrything is ok $uploaddir = 'monster/'; $uploadfile = $uploaddir . $_FILES['image']['name']; $upload = move_uploaded_file($_FILES['image']['tmp_name'], $uploadfile); if( $upload == TRUE ) { echo "<font face=verdana color=green size=1>The picture was uploaded successully</font><br />"; $query = "INSERT INTO monsters (name, lvl, hp, members, location, examine, race, drops, contributedby, picture, slayerxp ) VALUES ('$name', '$level', '$hp', '$members', '$location', '$examine', '$race', '$loot', '$contrib', '$picture', '$slayerxp' )"; $result = @mysql_query ($query); //Run the query. if ($result){ //if it entered correctly echo "<br /><table width=98% bgcolor=#C6F4DF class=pass align=center><tr> <td width=40><img src=images/tick.gif></td> <td align=left> <B>Success</B> <BR> The ".$name."\'s data was successfully added<br /> </table><br /><br />"; include ('difffooter.inc');//footer exit(); }else{ // didn't work echo "<table width=98% bgcolor=#faf5f4 class=logfail align=center><tr> <td width=40><img src=images/exclamation.gif></td> <td align=left> <B>Update Failed!</B> <BR> The ".$name."\'s data was could not be added <BR>Please Try again later<br /> </table><br /><br />"; } } else { echo "Error while uploading file, transfer aborted<br /><pre>"; print_r($_FILES); echo "</pre>"; exit; } } } ?> <br /><font class="adminheader"><center>Add monster</center></font><br /> Here you can add monsters to the database. Be sure to give credit properly where it is due!<br /> <form action="admin.php?flibble=add_monster" method="post" enctype="multipart/form-data"><center> <table class=calc> <tr><td> <table> <tr><td align=right><font class="text2">Monster 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">Picture:</font></td><td align=left><input name="image" type="file"></td></tr> <tr><td align=right><font class="text2">Picture Name:</font></td><td align=left><input type="text" class="text" name="picture" size="15" maxlength="30" value="<?php if (isset($_POST['picture'])) echo $_POST['picture']; ?>" /><span class="small">Simply put the name of the file you uploaded in here. eg. if in the box above you had "C:\images\image.jpg" what would go in here is "image.jpg"</span><br /></td></tr> <tr><td align=right><font class="text2">Monster's Level:</font></td><td align=left><input type="text" class="text" name="level" size="3" maxlength="3" value="<?php if (isset($_POST['level'])) echo $_POST['level']; ?>" /></td></tr> <tr><td align=right><font class="text2">Monster's HP:</font></td><td align=left><input type="text" class="text" name="hp" size="3" maxlength="4" value="<?php if (isset($_POST['hp'])) echo $_POST['hp']; ?>" /></td></tr> <tr><td align=right><font class="text2">Slayer XP:</font></td><td align=left><input type="text" class="text" name="sxp" size="3" maxlength="4" value="<?php if (isset($_POST['sxp'])) echo $_POST['sxp']; ?>" /></td></tr> <tr><td align=right><font class="text2">Monster's Race:</font></td><td align=left><input type="text" class="text" name="race" size="15" maxlength="30" value="<?php if (isset($_POST['race'])) echo $_POST['race']; ?>" /></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> <tr><td align=right><font class="text2">Monster's Examine Description:</font></td><td align=left><input type="text" class="text" name="examine" size="25" maxlength="255" value="<?php if (isset($_POST['examine'])) echo $_POST['examine']; ?>" /><font class="small2">Please be sure to get it exact.</font></td></tr> <tr><td align=right><font class="text2">Monster's Location:</font></td><td align=left><input type="text" class="text" name="location" size="25" maxlength="255" value="<?php if (isset($_POST['location'])) echo $_POST['location']; ?>" /></td></tr> <tr><td align=right><font class="text2">Monster's Loot:</font></td><td align=left><textarea name="loot" rows="18" cols="50" wrap="physical"><?php if (isset($_POST['loot'])) echo $_POST['loot']; ?></textarea></td></tr> <tr><td align=right><font class="text2">Contributed by:</font></td><td align=left><input type="text" class="text" name="contrib" size="25" maxlength="100" value="<?php if (isset($_POST['contrib'])) echo $_POST['contrib']; ?>" /><font class="small2"> The person who gave you the information not you (unless you are providing your own information)</font></td></tr> </table> </td> </tr> <tr> <td> <div align="center"><input type="submit" name="submit" value="Add Monster" class="liteoption" /> <input type="reset" name="reset" value="reset" class="liteoption" /></div> </td> </tr> </table> </CENTER> </form> <?php } //------------------------End Monster-------------------------------------------// Link to comment https://forums.phpfreaks.com/topic/109921-error-i-dont-understand/ Share on other sites More sharing options...
ober Posted June 12, 2008 Share Posted June 12, 2008 Might want to tell us where those lines are. Link to comment https://forums.phpfreaks.com/topic/109921-error-i-dont-understand/#findComment-564046 Share on other sites More sharing options...
revraz Posted June 12, 2008 Share Posted June 12, 2008 On your second error, move your session_start(); to the first line of code on the page. Link to comment https://forums.phpfreaks.com/topic/109921-error-i-dont-understand/#findComment-564057 Share on other sites More sharing options...
gaogier Posted June 12, 2008 Author Share Posted June 12, 2008 the lines of code was escape_data which i changed to mysql_real_escape_string my code will not add data to the database Link to comment https://forums.phpfreaks.com/topic/109921-error-i-dont-understand/#findComment-564059 Share on other sites More sharing options...
revraz Posted June 12, 2008 Share Posted June 12, 2008 Remove the @ suppressor from your query and use mysql_error() after the query. Link to comment https://forums.phpfreaks.com/topic/109921-error-i-dont-understand/#findComment-564068 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.