[56K WARN] pages

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

[56K WARN] pages

Post by gaogier »

i have created something that will allow staff members to put up content on my site.

Image

Image

this adds the guide to the site, but, we can not delete or edit the skill guide, why?

here is what happens when i click edit or delete

Image

here is the php code

Code: Select all

//------------------------Begin Skill-------------------------------------------//


function skill(){
$page = $_GET['page'];
    if(empty($page)){
        $page = 1;
    }     
	$limit          = 25;               
    $query_count    = "SELECT id FROM skill";    
    $result_count   = mysql_query($query_count);    
    $totalrows      = mysql_num_rows($result_count);
	
    $limitvalue = $page * $limit - ($limit);

echo '<p><center><font class="adminheader">SKill Admin</font></center></p>';
echo "<TABLE border=\"0\" width=\"89%\" class=monster>\n";
echo "<TR><TD class=title><center>Skill Name</center></td><td class=title><center>Edit</center></TD</TR>\n";
   /* query for Skills */

        $query = "SELECT id, name, sorter FROM skill ORDER BY sorter ASC LIMIT $limitvalue, $limit";
    
    $result = mysql_query ($query);

    while ($row = mysql_fetch_assoc ($result)) {
        /* display skills in a table */

		$count = $count + 1; 
        /* place table row data in 
         * easier to use variables.
         */
		$id = $row['id'];   
        $title = $row['name'];  
  

        /* display the data */
		echo '<TR bgcolor="'.processRow($count).'"><TD class="calc"><b>'.$title.'</b></td><td class="calc"><a href="'.$_SERVER['PHP_SELF'] . '?flibble=update_s&id='.$row['id'].'"><img src="images/admin/view.gif" alt="Edit" border="0"></a>&nbsp;<a href="'.$_SERVER['PHP_SELF'] . '?flibble=delete_s&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="admin2.php?flibble=skill&page='.$pageprev.'">Previous</a>&nbsp;&nbsp;';
    }else{
        echo 'Previous&nbsp;&nbsp;';
    }

    $numofpages = $totalrows / $limit;
    
    for($i = 1; $i <= $numofpages; $i++){
        if($i == $page){
            echo $i.' ';
        }else{
            echo '&nbsp;<a href="admin2.php?flibble=skill&page='.$i.'">'.$i.'</a>&nbsp;';
        }
    }
    if(($totalrows % $limit) != 0){
        if($i == $page){
            echo $i.' ';
        }else{
            echo '&nbsp;<a href="admin2.php?flibble=skill&page='.$i.'">'.$i.'</a>&nbsp;';
        }
    }
    if(($totalrows - ($limit * $page)) > 0){
        $pagenext = $page+1;
         
        echo '&nbsp;&nbsp;<a href="admin2.php?flibble=skill&page='.$pagenext.'">Next</a>';
    }else{
        echo '&nbsp;&nbsp;Next';
    }
	mysql_free_result($result);
	echo '</center>';
		
 		echo '<p><b><a href="http://runehints.com/admin2.php?flibble=add_s"><img src="images/plus.gif" alt="Add" border="0"> Add a skill guide</a></b></p>';
}

function update_s($id) {

if (isset($_POST['preview'])){  //handle form 
    $name = $_POST['name'];
    $contributors = $_POST['contributors'];
    $guideby = $_POST['guideby'];
    $members = $_POST['members'];
	$guide = $_POST['guide'];
	
	
	if ($members = "Y") {
		$mem = "members only skill</b>, so it can only be done on a <b>members</b> server.";
	}else{
		$mem = "non-members skill</b>.";
	}
	if ($updated == 0){
	$up = 'No-one has updated this skill guide';	
	}else{	
	$date2 = date("l jS of F Y @ H:i:s ", $updated);
	$up = 'It was last updated on '.$date2.'.';
	}
	if ($contributors != ""){
	$con = 'Thanks also to <b>'.$contributors.'</b> for changes.';	
	}else{
	$con = 'No-one else has contributed to this skill guide';
	}
	//$date = date("D M jS, Y g:i a", $added);
	$date = date("l jS of F Y @ H:i:s ", $added);
	
echo '
<p class="skillheader">'.$name.'</p>
<p>This skill guide was written by <b>'.$guideby.'</b> for use on Runehints. '.$con.'  <br /></p>
<p class="small2"><br />This skill is <b>'.$mem.'</p>
<p>
<span class="titles">Skill Instructions:</span></p>
<div id="skill">
<p>
   <?php echo $guide; ?>
</p></div>
<?php 
echo '
;

}

if (isset($_POST['submit'])){  //handle form 
	require_once ('../mysql_connect.php');//connect to db
	$name = $_POST['name'];
	$guideby = $_POST['guideby'];	
	$members = $_POST['members'];
	$guide = $_POST['guide'];
	$contributors = $_POST['contributors'];
	$updated = time();
	$sorter = $_POST['sorter'];
	
			if ($name){//if evrything is ok  						
					
				

					$query = "UPDATE skill SET name='".$name."', updated='".$updated."', guideby='".$guideby."', contributors='".$contributors."', members='".$members."', mainbody='".$guide."', sorter='".$sorter."' 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 skill guide for '.$name.' was successfully updated<br />							
										</table><br /><br />';
						include ('footer.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 skill guide for '.$name.' could not be updated
									<BR>Please Try again later<br />
									</table><br /><br />';
									//Name: '.$name.' Updated: '.$updated.' Contributors: '.$contributors.'  By: '.$guideby.' Members: '.$members.' Guide: '.$guide.'
					}       

			}
}


   /* query for item */
    $query = "SELECT * FROM skill 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 guide requested cannot be found\n";
        return;
    }
    $row = mysql_fetch_assoc($result);
    /* easier to read variables and 
     * striping out tags */
		$nid = $id;  
		$title = $row['name'];
		$guideby = $row['guideby'];
		$members = ucwords($row['members']);
		$guide = $row['mainbody'];
		$sorter = $row['sorter'];


 




echo '<br /><font class="adminheader"><center>Update skill guide</center></font><br />
Here you can update an existing skill guides in the database.<br />
	<center><form action="admin2.php?flibble=update_s&id='.$nid.'" method="post">
	
	<table class=calc>
	<tr><td>
	<table>

	<tr><td align=right><font class="text2">Skill Name:</font></td><td align=left><input type="text" class="text" name="name" size="15" maxlength="30" value="'.$title.'" /></td></tr>	
	
	<tr><td align=right><font class="text2">Guide Written by:</font></td><td align=left><input type="text" class="text" name="guideby" size="15" maxlength="30" 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>	

	<tr><td align=right><font class="text2">Main Guide:</font></td><td align=left><textarea name="guide" cols="50" rows="18" wrap=physical>'.$guide.'</textarea></td></tr>	

	<tr><td align=right><font class="text2">Contributors:</font></td><td align=left><input type="text" class="text" name="contributors" size="30" maxlength="255" value="'.$contributors.'" /></td></tr>	
	
	<tr><td align=right><font class="text2">Sort name:</font></td><td align=left><input type="text" class="text" name="sorter" size="30" maxlength="255" value="'.$sorter.'" /><font class="small2">This is the name of the skill without spaces or the leading "The" if it has one.</font></td></tr>	
	</table>
	</td>
	</tr>
	<tr>
	<td>
	<div align="center"><input type="submit" name="submit" value="Update Skill Guide" class="liteoption"/>&nbsp;<input type="submit" name="preview" value="Preview" class="liteoption"/>&nbsp;<input type="reset" name="reset" value="reset" class="liteoption" /></div>
	</td>
	</tr>
	</table>
</CENTER>
	</form>';
	
}


function add_skill() {

if (isset($_POST['preview'])){  //handle form 
    $name = $_POST['name'];
    $contributors = $_POST['contributors'];
    $guideby = $_POST['guideby'];
    $members = $_POST['members'];
	$guide = $_POST['guide'];
	
	
	if ($members = "Y") {
		$mem = "members only skill</b>, so it can only be done on a <b>members</b> server.";
	}else{
		$mem = "non-members skill</b>.";
	}
	if ($updated == 0){
	$up = 'No-one has updated this skill guide';	
	}else{	
	$date2 = date("l jS of F Y @ H:i:s ", $updated);
	$up = 'It was last updated on '.$date2.'.';
	}
	if ($contributors != ""){
	$con = 'Thanks also to <b>'.$contributors.'</b> for changes.';	
	}else{
	$con = 'No-one else has contributed to this skill guide';
	}
	//$date = date("D M jS, Y g:i a", $added);
	$date = date("l jS of F Y @ H:i:s ", $added);
	
echo '
<p class="skillheader">'.$name.'</p>
<p>This skill guide was written by <b>'.$guideby.'</b> for use on Runehints. '.$con.'  <br /></p>
<p class="small2"><br />This skill is <b>'.$mem.'</p>
  <p class="small2">'.$guide.'</p>'

;

}

if (isset($_POST['submit'])){  //handle form; 
	require_once ('../mysql_connect.php');//connect to db
	$name = $_POST['name'];
	$guideby = $_POST['guideby'];	
	$members = $_POST['members'];
	$guide = $_POST['guide'];
	$added = time();
	$sorter = $_POST['sorter'];
	
			if ($name){//if evrything is ok  						
					
				

					$query = "INSERT INTO skill (name, added, guideby, members, mainbody, sorter) VALUES ('$name', '$added', '$guideby', '$members', '$guide', '$sorter')";
					$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 skill guide for '.$name.' was successfully added<br />							
										</table><br /><br />';
						include ('footer.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 skill guide for '.$name.' could not be added
									<BR>Please Try again later<br />									
									</table><br /><br />';
									
					}       

			}
}

?>

<br /><font class="adminheader"><center>Add skill guides</center></font><br />
Here you can add skill guides to the database.<br />
	<form action="admin2.php?flibble=add_s" method="post"><center>
	<table class=calc>
	<tr><td>
	<table>

	<tr><td align=right><font class="text2">Skill Name:</font></td><td align=left><input type="text" class="text" name="name" size="15" maxlength="50" value="<?php if (isset($_POST['name'])) echo stripslashes($_POST['name']); ?>" /></td></tr>	
	
	<tr><td align=right><font class="text2">Guide Written by:</font></td><td align=left><input type="text" class="text" name="guideby" size="15" maxlength="30" value="<?php if (isset($_POST['guideby'])) echo stripslashes($_POST['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="<?php if (isset($_POST['members'])) echo stripslashes($_POST['members']); ?>" /><font class="small2">Use Y or N only</font></td></tr>	

	<tr><td align=right><font class="text2">Main Guide:</font></td><td align=left><textarea name="guide" cols='50' rows='18' wrap=physical><?php if (isset($_POST['guide'])) echo stripslashes($_POST['guide']); ?></textarea>&nbsp;<font class="small2"> When including, bold, italics, images etc. Please use <a href="html.php" target="_blank">HTML</a></font></td></tr>	
	
	<tr><td align=right><font class="text2">Sort Name:</font></td><td align=left><input type="text" class="text" name="sorter" size="30" maxlength="255" value="<?php if (isset($_POST['sorter'])) echo stripslashes($_POST['sorter']); ?>" /><font class="small2">This is the name of the skill without spaces or the leading "The" if it has one.</font></td></tr>		
	</table>
	</td>
	</tr>
	<tr>
	<td>
	<div align="center"><input type="submit" name="submit" value="Add Skill Guide" class="liteoption" />&nbsp;<input type="submit" name="preview" value="Preview" class="liteoption" />&nbsp;<input type="reset" name="reset" value="reset" class="liteoption" /></div>
	</td>
	</tr>
	</table>
</CENTER>
	</form>
	<?php
}

function delete_s($id){

$query = "SELECT `name` FROM skill 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 */
	$name = $row['name'];
if (isset($_POST['yes'])){  //handle form           
$query = "DELETE FROM `skill` WHERE `id` = ".$id." LIMIT 1";
$result = mysql_query($query);

    if ($result) {
        ob_end_clean();
		header("http://runehints.com/admin2.php?flibble=skill");   
		exit();     
    }
}

if (isset($_POST['no'])) {
  	ob_end_clean();
	header("http://runehints.com/admins.php?flibble=skill");     
	exit();        
}
	
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="admin2.php?flibble=delete_s&id='.$id.'" method="post"><input type="submit" name="yes" value="Yes" class="delete" />&nbsp;<input name="no" type="submit" value="No" class="delete" /></form>
									</table><br /><br />';


}

//------------------------End skill-------------------------------------------//
the mysql database

Code: Select all

-- 
-- Table structure for table `skill`
-- 

CREATE TABLE `skill` (
  `id` int(10) NOT NULL auto_increment,
  `name` varchar(50) NOT NULL default '',
  `added` int(11) NOT NULL default '0',
  `guideby` varchar(30) NOT NULL default '',
  `contributors` varchar(225) NOT NULL default '',
  `members` char(1) NOT NULL default 'N',
  `mainbody` text NOT NULL,
  `updated` int(11) NOT NULL default '0',
  `sorter` varchar(50) NOT NULL default '',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM AUTO_INCREMENT=8 ;
Last edited by gaogier on Fri Mar 31, 2006 3:47 pm, edited 2 times in total.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

this adds the guide to the site, but, we can not delete or add the skill guide, why?
do you mean edit?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

ah, yes i did, why is there 56k warn on the title?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

56k warn because of the picture

what is the problem you're having when trying to delete or edit?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

well, the page will not load, it loads but its like nothing is there, no content, ill try and get a pic
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

can anyone help?
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

i need to get this sorted please help
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

can someone help
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

gaogier wrote:well, the page will not load, it loads but its like nothing is there, no content, ill try and get a pic
well?
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

i edited and put the pic in the first post

or its here, Image
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

anyone?
crackedPavement
Forum Newbie
Posts: 11
Joined: Wed Mar 01, 2006 8:18 pm
Location: portland, or

Post by crackedPavement »

Your code is a mess dude... I'd say that's why you're not getting any good feedback.. Procedural code is so 1999 (jk)
Post Reply