EagleAmerican Posted July 31, 2007 Share Posted July 31, 2007 I can't figure out how to get an edit or delete function into this. If you need to access the staff area of the site to check out how I have it layed out or anything please drop me a PM and I will set you up with a login and password and the sites URL. Thanks so much to anyone who can help me here. <html> <head> <title>ParasiteDB - Research and Remove Parasites!</title> <META content="parasite, virus, malware, removal, computer, pc, database, pdb, db" name=keywords> <META content="You can research and find ways to remove hundreds of different parasites here. Come take a look!" name=description> <style TYPE="text/css"> A{text-decoration:none} A:hover{color:#FFFFFF;text-decoration:underline} } BODY { SCROLLBAR-FACE-COLOR: #000000; SCROLLBAR-HIGHLIGHT-COLOR: #000000; SCROLLBAR-SHADOW-COLOR: #0099CC; SCROLLBAR-3DLIGHT-COLOR: #0099CC; SCROLLBAR-ARROW-COLOR: #0099CC; SCROLLBAR-TRACK-COLOR: #000000; SCROLLBAR-DARKSHADOW-COLOR: #0000000; } </style> </head> <BODY BGCOLOR="#000000" TEXT="#FFFFFF" VLINK="#0099CC" ALINK="#0099CC" LINK="#0099CC" topmargin="0"> <table border="0" cellspacing="1" width="100%"> <tr> <td width="100%" background="logo.jpg"> <table border="0" cellpadding="0" cellspacing="0" width="100%" bordercolor="#FFFFFF"> <tr> <td width="100%" background="images/logo.jpg" height="80"> <p align="center"><font color="#FFFFFF" size="4" face="Arial"><b>ParasiteDB - Research and Remove Parasites!</b></font></td> </tr> </table> </td> </tr> <tr> <td width="100%"> <table border="1" cellpadding="5" cellspacing="5" width="100%" bordercolor="#FFFFFF"> <tr> <td width="20%" valign="top"> <font face="Arial" size="2"><b> Navigation</b></font><br> <font face="Arial" size="2"> - <a href="http://parasitedb.freehostia.com/index.php">Home</a><br> - <a href="mailto:Webmaster@parasitedb.freehostia.com?subject=Contact Us">Contact Us</a><br> - <a href="mailto:Webmaster@parasitedb.freehostia.com?subject=Advertise">Advertise</a><br> - <a href="http://parasitedb.freehostia.com/search.php">Search</a><br> - <a href="index.php">Staff Login</a><br> - <a href="view_online.php">View Users Online</a></font> <font face="Arial" size="1"> <p> </font><font face="Arial" size="2"> <font face="Arial" size="2">Google Ads Coming Soon!</font></a><font face="Arial" size="1"> <p> <font face="Arial" size="2"><b> Sponsors</b></font><br> </font><font face="Arial" size="2">- <a href="http://malwareremoval.com/">Malware Removal</a><br> - <a href="http://pchelpforum.com/">PC Help Forum</a><br> </font></td> <td width="80%" valign="top"><b><font face="Arial"><font size="2" color="#FFFFFF"><center><br> <?php if (isset($_GET['addparasite'])): // User wants to add a joke ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <label>Name:<br /> <textarea name="parasitename" rows="1" cols="50"> </textarea></label><br /> <label>From:<br /> <textarea name="parasitefrom" rows="1" cols="50"> </textarea></label><br /> <label>Genre:<br /> <textarea name="parasitegenre" rows="1" cols="50"> </textarea></label><br / <label>Description:<br /> <textarea name="parasitedescription" rows="5" cols="50"> </textarea></label><br /> <label>Removal Info:<br /> <textarea name="parasiteremoval" rows="5" cols="50"> </textarea></label><br /> <input type="submit" value="Add" /> </form> <?php else: // Default page display $dbcnx = @mysql_connect('xxxxx', 'adaarm_db', 'xxxxx'); if (!$dbcnx) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } if (!@mysql_select_db('adaarm_db')) { exit('<p>Unable to locate the ' . 'database at this time.</p>'); } if (isset($_POST['parasitename'])) { $parasitename = $_POST['parasitename']; $parasitefrom = $_POST['parasitefrom']; $parasitegenre = $_POST['parasitegenre']; $parasitedescription = $_POST['parasitedescription']; $parasitetechremoval = $_POST['parasiteremoval']; $sql = "INSERT INTO parasite SET parasitename='$parasitename', parasitefrom='$parasitefrom', parasitegenre='$parasitegenre', parasitedescription='$parasitedescription', parasiteremoval='$parasiteremoval'"; if (@mysql_query($sql)) { echo "<p>The parasite '$parasitename' has been added.</p>"; } else { echo '<p>Error adding submitted parasite: ' . mysql_error() . '</p>'; } } echo '<p><a href="' . $_SERVER['PHP_SELF'] . '?addparasite=1">Add a Parasite</a></p>'; $sql = mysql_query("SELECT parasitename,parasitefrom,parasitegenre,parasitedescription,id FROM parasite ORDER BY parasitename ASC") or die(mysql_error()); echo "Parasites in Database:<br><br>"; echo "<table width=90% align=center border=1><tr> <td align=center>Name</td> <td align=center>From</td> <td align=center>Genre</td> </tr>"; while ($r = mysql_fetch_array($sql)) { // Begin while $id = $r["id"]; $name = $r["parasitename"]; $from = $r["parasitefrom"]; $genre = $r["parasitegenre"]; echo "<tr> <td><a href=view.php?id=$id>$name</a></td> <td>$from</td> <td>$genre</td></tr>"; } // end while echo "</table>"; endif; ?> </table> </center> </div> <p> </td> </tr> </table> </td> </tr> <tr> <td width="100%"> <p align="center"><font size="2"><font face="Arial">All Site Content © 2007 - ParasiteDB<br>All Rights Reserved</font></td> </tr> </table> </BODY> </html> Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/ Share on other sites More sharing options...
dbillings Posted July 31, 2007 Share Posted July 31, 2007 Delete what? Do you want a user to be able to delete a "parasite"? Or do you only want admin's to delete "parasites". Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-312129 Share on other sites More sharing options...
EagleAmerican Posted July 31, 2007 Author Share Posted July 31, 2007 I want a delete and edit button added to each line so that the staff member can delete the parasite from the database. This index.php is in the /staff dir and is protected with .htaccess for the staff only. The main site has the search function and all. Thanks, Adam Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-312138 Share on other sites More sharing options...
dbillings Posted July 31, 2007 Share Posted July 31, 2007 I'm not familiar with .htaccess. I googled it but I'm not sure how to parse a php security script so that will be up to you. not tested.... <?php // <---- Don't forget remove this php tag. if (isset($_GET['delete')) { $delete_id = $_GET['delete']; $delete_name = $_GET['name']; unset($_GET['name']); unset($_GET['delete']); $delete_sql = "DELETE * FROM parasite WHERE id='$delete_id'"; $result = mysql_query($delete_sql)or die(mysql_error()); if ($result) { echo "The parasite named $delete_name had been deleted."; }else{ echo "The delete could not be carried out."; } } if (isset($_POST['parasitename'])) { $parasitename = $_POST['parasitename']; $parasitefrom = $_POST['parasitefrom']; $parasitegenre = $_POST['parasitegenre']; $parasitedescription = $_POST['parasitedescription']; $parasitetechremoval = $_POST['parasiteremoval']; $sql = "INSERT INTO parasite SET parasitename='$parasitename', parasitefrom='$parasitefrom', parasitegenre='$parasitegenre', parasitedescription='$parasitedescription', parasiteremoval='$parasiteremoval'"; if (@mysql_query($sql)) { echo "<p>The parasite '$parasitename' has been added.</p>"; } else { echo '<p>Error adding submitted parasite: ' . mysql_error() . '</p>'; } } echo '<p><a href="' . $_SERVER['PHP_SELF'] . '?addparasite=1">Add a Parasite</a></p>'; $sql = mysql_query("SELECT parasitename,parasitefrom,parasitegenre,parasitedescription,id FROM parasite ORDER BY parasitename ASC") or die(mysql_error()); echo "Parasites in Database:<br><br>"; echo "<table width=90% align=center border=1><tr> <td align=center>Name</td> <td align=center>From</td> <td align=center>Genre</td> </tr>"; while ($r = mysql_fetch_array($sql)) { // Begin while $id = $r["id"]; $name = $r["parasitename"]; $from = $r["parasitefrom"]; $genre = $r["parasitegenre"]; /* create a $_GET variable called delete using the objects id. Edit the this page link to the name of this page.*/ echo "<tr> <td><a href=view.php?id=$id>$name</a></td> <td>$from</td> <td>$genre</td> <td><a href='thispage.php?delete=$id&name=$name'>Delete</a></td></tr>"; } // end while echo "</table>"; endif; ?> Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-312244 Share on other sites More sharing options...
EagleAmerican Posted July 31, 2007 Author Share Posted July 31, 2007 What about the edit? :S Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-312377 Share on other sites More sharing options...
dbillings Posted August 1, 2007 Share Posted August 1, 2007 Here's the edit, not tested and there's a solid chance of errors. <?php // <---- Don't forget remove this php tag. if (isset($_GET['edit')) { $edit_id = $_GET['edit']; unset($_GET['edit']); $query = "SELECT * FROM parasite WHERE id='$edit_id'"; $result = mysql_query($query)or die(mysql_error()); $data = mysql_fetch_assoc($result); ?> <fieldset><legend>Parasite Edit</legend> <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <input type="hidden" name="id" value="<?php echo $data['id']; ?>"> Parasitename:<input type="text" name="parasitename" value="<?php echo $data['parasitename']; ?>"><br /> Parasitefrom:<input type="text" name"parasitefrom" value="<?php echo $data['parasitefrom']; ?>"><br /> Parasitegenre:<input type="text" name="parasitegenre" value="<?php echo $data['parasitegenre']; ?>"><br /> Parasitedescription:<input type="text" name="parasitedescription" value="<?php echo $data['parasitedescription']; ?>"><br /> Parasiteremoval:<input type="text" name="parasiteremoval" value="<?php echo $data['parasiteremoval']; ?>"><br /> <input type="submit" value="Submit" name="parasiteedit"> </form> </fieldset> <?php } if (isset($_REQUEST['parasiteedit'])) { $n = $_REQUEST['parasitename']; $f = $_REQUEST['parasitefrom']; $g = $_REQUEST['parasitegenre']; $d = $_REQUEST['parasitedescription']; $r = $_REQUEST['parasiteremoval']; $id= $_REQUEST['id']; $edit_sql = "UPDATE parasite SET parasitename='$n', parasitefrom='$f', parasitegenre='$g', parasitedescription='$d', parasiteremoval='$r' WHERE id='$id'"; $result = mysql_query($edit_sql)or die(mysql_error()); if ($result) { echo "The parasite named $edit_name has been changed.<br /> New values: <br /> Parasitename: $parasitename <br /> Parasitefrom: $parasitefrom <br /> Parasitegenre: $parasitegenre <br /> Parasitedescription: $parasitedescription <br /> Parasiteremoval: $parasiteremoval"; }else{ echo "The edit request could not be carried out."; } } <?php // <---- Don't forget remove this php tag. if (isset($_GET['delete')) { $delete_id = $_GET['delete']; $delete_name = $_GET['name']; unset($_GET['name']); unset($_GET['delete']); $delete_sql = "DELETE * FROM parasite WHERE id='$delete_id'"; $result = mysql_query($delete_sql)or die(mysql_error()); if ($result) { echo "The parasite named $delete_name had been deleted."; }else{ echo "The delete could not be carried out."; } } if (isset($_POST['parasitename'])) { $parasitename = $_POST['parasitename']; $parasitefrom = $_POST['parasitefrom']; $parasitegenre = $_POST['parasitegenre']; $parasitedescription = $_POST['parasitedescription']; $parasitetechremoval = $_POST['parasiteremoval']; $sql = "INSERT INTO parasite SET parasitename='$parasitename', parasitefrom='$parasitefrom', parasitegenre='$parasitegenre', parasitedescription='$parasitedescription', parasiteremoval='$parasiteremoval'"; if (@mysql_query($sql)) { echo "<p>The parasite '$parasitename' has been added.</p>"; } else { echo '<p>Error adding submitted parasite: ' . mysql_error() . '</p>'; } } echo '<p><a href="' . $_SERVER['PHP_SELF'] . '?addparasite=1">Add a Parasite</a></p>'; $sql = mysql_query("SELECT parasitename,parasitefrom,parasitegenre,parasitedescription,parasiteremoval,id FROM parasite ORDER BY parasitename ASC") or die(mysql_error()); echo "Parasites in Database:<br><br>"; echo "<table width=90% align=center border=1><tr> <td align=center>Name</td> <td align=center>From</td> <td align=center>Genre</td> </tr>"; while ($r = mysql_fetch_array($sql)) { // Begin while $id = $r["id"]; $name = $r["parasitename"]; $from = $r["parasitefrom"]; $genre = $r["parasitegenre"]; $description = $r["parasitegenre"]; $removal = $r["parasiteremoval"]; /* create a $_GET variable called delete using the objects id. Edit the this page link to the name of this page.*/ echo "<tr> <td><a href=view.php?id=$id>$name</a></td> <td>$from</td> <td>$genre</td> <td><a href='thispage.php?delete=$id&name=$name'>Delete</a></td> <td><a href='thispage.php?edit=$id>Edit</a></tr>"; } // end while echo "</table>"; endif; ?> Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-312519 Share on other sites More sharing options...
EagleAmerican Posted August 2, 2007 Author Share Posted August 2, 2007 I've been trying and get it to work. I keep getting different PHP errors when I try to fix them I get another one. This has gone on for a day and I can't take it anymore. Any help appreciated? :'( Thanks, Adam Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-313594 Share on other sites More sharing options...
teng84 Posted August 2, 2007 Share Posted August 2, 2007 show your current code Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-313605 Share on other sites More sharing options...
EagleAmerican Posted August 2, 2007 Author Share Posted August 2, 2007 I restored it to before I started messing around using the backup I made because my friend wanted to add some more entries. The code it is at right now is in my original post. And thank you for your response and time. Thanks, Adam Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-313606 Share on other sites More sharing options...
EagleAmerican Posted August 2, 2007 Author Share Posted August 2, 2007 Anyone? :'( Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-314250 Share on other sites More sharing options...
dbillings Posted August 3, 2007 Share Posted August 3, 2007 Try this.... If you get errors post them. <html> <head> <title>ParasiteDB - Research and Remove Parasites!</title> <META content="parasite, virus, malware, removal, computer, pc, database, pdb, db" name=keywords> <META content="You can research and find ways to remove hundreds of different parasites here. Come take a look!" name=description> <style TYPE="text/css"> A{text-decoration:none} A:hover{color:#FFFFFF;text-decoration:underline} } BODY { SCROLLBAR-FACE-COLOR: #000000; SCROLLBAR-HIGHLIGHT-COLOR: #000000; SCROLLBAR-SHADOW-COLOR: #0099CC; SCROLLBAR-3DLIGHT-COLOR: #0099CC; SCROLLBAR-ARROW-COLOR: #0099CC; SCROLLBAR-TRACK-COLOR: #000000; SCROLLBAR-DARKSHADOW-COLOR: #0000000; } </style> </head> <BODY BGCOLOR="#000000" TEXT="#FFFFFF" VLINK="#0099CC" ALINK="#0099CC" LINK="#0099CC" topmargin="0"> <table border="0" cellspacing="1" width="100%"> <tr> <td width="100%" background="logo.jpg"> <table border="0" cellpadding="0" cellspacing="0" width="100%" bordercolor="#FFFFFF"> <tr> <td width="100%" background="images/logo.jpg" height="80"> <p align="center"><font color="#FFFFFF" size="4" face="Arial"><b>ParasiteDB - Research and Remove Parasites!</b></font></td> </tr> </table> </td> </tr> <tr> <td width="100%"> <table border="1" cellpadding="5" cellspacing="5" width="100%" bordercolor="#FFFFFF"> <tr> <td width="20%" valign="top"> <font face="Arial" size="2"><b> Navigation</b></font><br> <font face="Arial" size="2"> - <a href="http://parasitedb.freehostia.com/index.php">Home</a><br> - <a href="mailto:Webmaster@parasitedb.freehostia.com?subject=Contact Us">Contact Us</a><br> - <a href="mailto:Webmaster@parasitedb.freehostia.com?subject=Advertise">Advertise</a><br> - <a href="http://parasitedb.freehostia.com/search.php">Search</a><br> - <a href="index.php">Staff Login</a><br> - <a href="view_online.php">View Users Online</a></font> <font face="Arial" size="1"> <p> </font><font face="Arial" size="2"> <font face="Arial" size="2">Google Ads Coming Soon!</font></a><font face="Arial" size="1"> <p> <font face="Arial" size="2"><b> Sponsors</b></font><br> </font><font face="Arial" size="2">- <a href="http://malwareremoval.com/">Malware Removal</a><br> - <a href="http://pchelpforum.com/">PC Help Forum</a><br> </font></td> <td width="80%" valign="top"><b><font face="Arial"><font size="2" color="#FFFFFF"><center><br> <?php if (isset($_GET['addparasite'])): // User wants to add a joke ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <label>Name:<br /> <textarea name="parasitename" rows="1" cols="50"> </textarea></label><br /> <label>From:<br /> <textarea name="parasitefrom" rows="1" cols="50"> </textarea></label><br /> <label>Genre:<br /> <textarea name="parasitegenre" rows="1" cols="50"> </textarea></label><br / <label>Description:<br /> <textarea name="parasitedescription" rows="5" cols="50"> </textarea></label><br /> <label>Removal Info:<br /> <textarea name="parasiteremoval" rows="5" cols="50"> </textarea></label><br /> <input type="submit" value="Add" /> </form> <?php else: // Default page display $dbcnx = @mysql_connect('xxxxx', 'adaarm_db', 'xxxxx'); if (!$dbcnx) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } if (!@mysql_select_db('adaarm_db')) { exit('<p>Unable to locate the ' . 'database at this time.</p>'); } if (isset($_GET['edit')) { $edit_id = $_GET['edit']; unset($_GET['edit']); $query = "SELECT * FROM parasite WHERE id='$edit_id'"; $result = mysql_query($query)or die(mysql_error()); $data = mysql_fetch_assoc($result); ?> <fieldset><legend>Parasite Edit</legend> <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <input type="hidden" name="id" value="<?php echo $data['id']; ?>"> Parasitename:<input type="text" name="parasitename" value="<?php echo $data['parasitename']; ?>"><br /> Parasitefrom:<input type="text" name"parasitefrom" value="<?php echo $data['parasitefrom']; ?>"><br /> Parasitegenre:<input type="text" name="parasitegenre" value="<?php echo $data['parasitegenre']; ?>"><br /> Parasitedescription:<input type="text" name="parasitedescription" value="<?php echo $data['parasitedescription']; ?>"><br /> Parasiteremoval:<input type="text" name="parasiteremoval" value="<?php echo $data['parasiteremoval']; ?>"><br /> <input type="submit" value="Submit" name="parasiteedit"> </form> </fieldset> <?php } if (isset($_REQUEST['parasiteedit'])) { $n = $_REQUEST['parasitename']; $f = $_REQUEST['parasitefrom']; $g = $_REQUEST['parasitegenre']; $d = $_REQUEST['parasitedescription']; $r = $_REQUEST['parasiteremoval']; $id= $_REQUEST['id']; $edit_sql = "UPDATE parasite SET parasitename='$n', parasitefrom='$f', parasitegenre='$g', parasitedescription='$d', parasiteremoval='$r' WHERE id='$id'"; $result = mysql_query($edit_sql)or die(mysql_error()); if ($result) { echo "The parasite named $edit_name has been changed.<br /> New values: <br /> Parasitename: $parasitename <br /> Parasitefrom: $parasitefrom <br /> Parasitegenre: $parasitegenre <br /> Parasitedescription: $parasitedescription <br /> Parasiteremoval: $parasiteremoval"; }else{ echo "The edit request could not be carried out."; } } if (isset($_GET['delete')) { $delete_id = $_GET['delete']; $delete_name = $_GET['name']; unset($_GET['name']); unset($_GET['delete']); $delete_sql = "DELETE * FROM parasite WHERE id='$delete_id'"; $result = mysql_query($delete_sql)or die(mysql_error()); if ($result) { echo "The parasite named $delete_name had been deleted."; }else{ echo "The delete could not be carried out."; } } if (isset($_POST['parasitename'])) { $parasitename = $_POST['parasitename']; $parasitefrom = $_POST['parasitefrom']; $parasitegenre = $_POST['parasitegenre']; $parasitedescription = $_POST['parasitedescription']; $parasitetechremoval = $_POST['parasiteremoval']; $sql = "INSERT INTO parasite SET parasitename='$parasitename', parasitefrom='$parasitefrom', parasitegenre='$parasitegenre', parasitedescription='$parasitedescription', parasiteremoval='$parasiteremoval'"; if (@mysql_query($sql)) { echo "<p>The parasite '$parasitename' has been added.</p>"; } else { echo '<p>Error adding submitted parasite: ' . mysql_error() . '</p>'; } } echo '<p><a href="' . $_SERVER['PHP_SELF'] . '?addparasite=1">Add a Parasite</a></p>'; $sql = mysql_query("SELECT parasitename,parasitefrom,parasitegenre,parasitedescription,parasiteremoval,id FROM parasite ORDER BY parasitename ASC") or die(mysql_error()); echo "Parasites in Database:<br><br>"; echo "<table width=90% align=center border=1><tr> <td align=center>Name</td> <td align=center>From</td> <td align=center>Genre</td> </tr>"; while ($r = mysql_fetch_array($sql)) { // Begin while $id = $r["id"]; $name = $r["parasitename"]; $from = $r["parasitefrom"]; $genre = $r["parasitegenre"]; $description = $r["parasitegenre"]; $removal = $r["parasiteremoval"]; /* create a $_GET variable called delete using the objects id. Edit the this page link to the name of this page.*/ echo "<tr> <td><a href=view.php?id=$id>$name</a></td> <td>$from</td> <td>$genre</td> <td><a href='thispage.php?delete=$id&name=$name'>Delete</a></td> <td><a href='thispage.php?edit=$id>Edit</a></tr>"; } // end while echo "</table>"; endif; ?> </table> </center> </div> <p> </td> </tr> </table> </td> </tr> <tr> <td width="100%"> <p align="center"><font size="2"><font face="Arial">All Site Content © 2007 - ParasiteDB<br>All Rights Reserved</font></td> </tr> </table> </BODY> </html> Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-314604 Share on other sites More sharing options...
EagleAmerican Posted August 6, 2007 Author Share Posted August 6, 2007 Sorry about the delay and thanks. Error: Parse error: parse error, unexpected ')', expecting ']' in /home/www/parasitedb.freehostia.com/staff/index.php on line 94 Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-316354 Share on other sites More sharing options...
EagleAmerican Posted August 6, 2007 Author Share Posted August 6, 2007 Ok, I got that error fixed.. should have checked it before posting. New error that I can't figure out: Parse error: parse error, unexpected '{' in /home/www/parasitedb.freehostia.com/staff/index.php on line 94 Line with error is if (isset($_GET['edit]) { <html> <head> <title>ParasiteDB - Research and Remove Parasites!</title> <META content="parasite, virus, malware, removal, computer, pc, database, pdb, db" name=keywords> <META content="You can research and find ways to remove hundreds of different parasites here. Come take a look!" name=description> <style TYPE="text/css"> A{text-decoration:none} A:hover{color:#FFFFFF;text-decoration:underline} } BODY { SCROLLBAR-FACE-COLOR: #000000; SCROLLBAR-HIGHLIGHT-COLOR: #000000; SCROLLBAR-SHADOW-COLOR: #0099CC; SCROLLBAR-3DLIGHT-COLOR: #0099CC; SCROLLBAR-ARROW-COLOR: #0099CC; SCROLLBAR-TRACK-COLOR: #000000; SCROLLBAR-DARKSHADOW-COLOR: #0000000; } </style> </head> <BODY BGCOLOR="#000000" TEXT="#FFFFFF" VLINK="#0099CC" ALINK="#0099CC" LINK="#0099CC" topmargin="0"> <table border="0" cellspacing="1" width="100%"> <tr> <td width="100%" background="logo.jpg"> <table border="0" cellpadding="0" cellspacing="0" width="100%" bordercolor="#FFFFFF"> <tr> <td width="100%" background="images/logo.jpg" height="80"> <p align="center"><font color="#FFFFFF" size="4" face="Arial"><b>ParasiteDB - Research and Remove Parasites!</b></font></td> </tr> </table> </td> </tr> <tr> <td width="100%"> <table border="1" cellpadding="5" cellspacing="5" width="100%" bordercolor="#FFFFFF"> <tr> <td width="20%" valign="top"> <font face="Arial" size="2"><b> Navigation</b></font><br> <font face="Arial" size="2"> - <a href="http://parasitedb.freehostia.com/index.php">Home</a><br> - <a href="mailto:Webmaster@parasitedb.freehostia.com?subject=Contact Us">Contact Us</a><br> - <a href="mailto:Webmaster@parasitedb.freehostia.com?subject=Advertise">Advertise</a><br> - <a href="http://parasitedb.freehostia.com/search.php">Search</a><br> - <a href="index.php">Staff Login</a><br> - <a href="view_online.php">View Users Online</a></font> <font face="Arial" size="1"> <p> </font><font face="Arial" size="2"> <font face="Arial" size="2">Google Ads Coming Soon!</font></a><font face="Arial" size="1"> <p> <font face="Arial" size="2"><b> Sponsors</b></font><br> </font><font face="Arial" size="2">- <a href="http://malwareremoval.com/">Malware Removal</a><br> - <a href="http://pchelpforum.com/">PC Help Forum</a><br> </font></td> <td width="80%" valign="top"><b><font face="Arial"><font size="2" color="#FFFFFF"><center><br> <?php if (isset($_GET['addparasite'])): // User wants to add a joke ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <label>Name:<br /> <textarea name="parasitename" rows="1" cols="50"> </textarea></label><br /> <label>From:<br /> <textarea name="parasitefrom" rows="1" cols="50"> </textarea></label><br /> <label>Genre:<br /> <textarea name="parasitegenre" rows="1" cols="50"> </textarea></label><br / <label>Description:<br /> <textarea name="parasitedescription" rows="5" cols="50"> </textarea></label><br /> <label>Removal Info:<br /> <textarea name="parasiteremoval" rows="5" cols="50"> </textarea></label><br /> <input type="submit" value="Add" /> </form> <?php else: // Default page display $dbcnx = @mysql_connect('xxxxx', 'adaarm_db', 'xxxxx'); if (!$dbcnx) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } if (!@mysql_select_db('adaarm_db')) { exit('<p>Unable to locate the ' . 'database at this time.</p>'); } if (isset($_GET['edit']) { $edit_id = $_GET['edit']; unset($_GET['edit']); $query = "SELECT * FROM parasite WHERE id='$edit_id'"; $result = mysql_query($query)or die(mysql_error()); $data = mysql_fetch_assoc($result); ?> <fieldset><legend>Parasite Edit</legend> <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <input type="hidden" name="id" value="<?php echo $data['id']; ?>"> Parasitename:<input type="text" name="parasitename" value="<?php echo $data['parasitename']; ?>"><br /> Parasitefrom:<input type="text" name"parasitefrom" value="<?php echo $data['parasitefrom']; ?>"><br /> Parasitegenre:<input type="text" name="parasitegenre" value="<?php echo $data['parasitegenre']; ?>"><br /> Parasitedescription:<input type="text" name="parasitedescription" value="<?php echo $data['parasitedescription']; ?>"><br /> Parasiteremoval:<input type="text" name="parasiteremoval" value="<?php echo $data['parasiteremoval']; ?>"><br /> <input type="submit" value="Submit" name="parasiteedit"> </form> </fieldset> <?php } if (isset($_REQUEST['parasiteedit'])) { $n = $_REQUEST['parasitename']; $f = $_REQUEST['parasitefrom']; $g = $_REQUEST['parasitegenre']; $d = $_REQUEST['parasitedescription']; $r = $_REQUEST['parasiteremoval']; $id= $_REQUEST['id']; $edit_sql = "UPDATE parasite SET parasitename='$n', parasitefrom='$f', parasitegenre='$g', parasitedescription='$d', parasiteremoval='$r' WHERE id='$id'"; $result = mysql_query($edit_sql)or die(mysql_error()); if ($result) { echo "The parasite named $edit_name has been changed.<br /> New values: <br /> Parasitename: $parasitename <br /> Parasitefrom: $parasitefrom <br /> Parasitegenre: $parasitegenre <br /> Parasitedescription: $parasitedescription <br /> Parasiteremoval: $parasiteremoval"; }else{ echo "The edit request could not be carried out."; } } if (isset($_GET['delete')) { $delete_id = $_GET['delete']; $delete_name = $_GET['name']; unset($_GET['name']); unset($_GET['delete']); $delete_sql = "DELETE * FROM parasite WHERE id='$delete_id'"; $result = mysql_query($delete_sql)or die(mysql_error()); if ($result) { echo "The parasite named $delete_name had been deleted."; }else{ echo "The delete could not be carried out."; } } if (isset($_POST['parasitename'])) { $parasitename = $_POST['parasitename']; $parasitefrom = $_POST['parasitefrom']; $parasitegenre = $_POST['parasitegenre']; $parasitedescription = $_POST['parasitedescription']; $parasitetechremoval = $_POST['parasiteremoval']; $sql = "INSERT INTO parasite SET parasitename='$parasitename', parasitefrom='$parasitefrom', parasitegenre='$parasitegenre', parasitedescription='$parasitedescription', parasiteremoval='$parasiteremoval'"; if (@mysql_query($sql)) { echo "<p>The parasite '$parasitename' has been added.</p>"; } else { echo '<p>Error adding submitted parasite: ' . mysql_error() . '</p>'; } } echo '<p><a href="' . $_SERVER['PHP_SELF'] . '?addparasite=1">Add a Parasite</a></p>'; $sql = mysql_query("SELECT parasitename,parasitefrom,parasitegenre,parasitedescription,parasiteremoval,id FROM parasite ORDER BY parasitename ASC") or die(mysql_error()); echo "Parasites in Database:<br><br>"; echo "<table width=90% align=center border=1><tr> <td align=center>Name</td> <td align=center>From</td> <td align=center>Genre</td> </tr>"; while ($r = mysql_fetch_array($sql)) { // Begin while $id = $r["id"]; $name = $r["parasitename"]; $from = $r["parasitefrom"]; $genre = $r["parasitegenre"]; $description = $r["parasitegenre"]; $removal = $r["parasiteremoval"]; /* create a $_GET variable called delete using the objects id. Edit the this page link to the name of this page.*/ echo "<tr> <td><a href=view.php?id=$id>$name</a></td> <td>$from</td> <td>$genre</td> <td><a href='thispage.php?delete=$id&name=$name'>Delete</a></td> <td><a href='thispage.php?edit=$id>Edit</a></tr>"; } // end while echo "</table>"; endif; ?> </table> </center> </div> <p> </td> </tr> </table> </td> </tr> <tr> <td width="100%"> <p align="center"><font size="2"><font face="Arial">All Site Content © 2007 - ParasiteDB<br>All Rights Reserved</font></td> </tr> </table> </BODY> </html> Thanks, Adam Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-316357 Share on other sites More sharing options...
redarrow Posted August 6, 2007 Share Posted August 6, 2007 if (isset($_GET['edit']) ) // ) <<<closing tag missing{ Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-316361 Share on other sites More sharing options...
teng84 Posted August 6, 2007 Share Posted August 6, 2007 NOTE: Parse error: parse error, unexpected '{' in /home/www/parasitedb.freehostia.com/staff/index.php on line 94 when you receive a message something like that its obvious that your missing or over use of the define character please check it first before posting Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-316363 Share on other sites More sharing options...
EagleAmerican Posted August 6, 2007 Author Share Posted August 6, 2007 Ok, thanks. Now we are getting somewhere. Now we have another problem. The table that displays the parasites is all in one row and it has the first parasites name, from and genre and then it just keeps adding Delete and makes the page huge in width. Current code: <html> <head> <title>ParasiteDB - Research and Remove Parasites!</title> <META content="parasite, virus, malware, removal, computer, pc, database, pdb, db" name=keywords> <META content="You can research and find ways to remove hundreds of different parasites here. Come take a look!" name=description> <style TYPE="text/css"> A{text-decoration:none} A:hover{color:#FFFFFF;text-decoration:underline} } BODY { SCROLLBAR-FACE-COLOR: #000000; SCROLLBAR-HIGHLIGHT-COLOR: #000000; SCROLLBAR-SHADOW-COLOR: #0099CC; SCROLLBAR-3DLIGHT-COLOR: #0099CC; SCROLLBAR-ARROW-COLOR: #0099CC; SCROLLBAR-TRACK-COLOR: #000000; SCROLLBAR-DARKSHADOW-COLOR: #0000000; } </style> </head> <BODY BGCOLOR="#000000" TEXT="#FFFFFF" VLINK="#0099CC" ALINK="#0099CC" LINK="#0099CC" topmargin="0"> <table border="0" cellspacing="1" width="100%"> <tr> <td width="100%" background="logo.jpg"> <table border="0" cellpadding="0" cellspacing="0" width="100%" bordercolor="#FFFFFF"> <tr> <td width="100%" background="images/logo.jpg" height="80"> <p align="center"><font color="#FFFFFF" size="4" face="Arial"><b>ParasiteDB - Research and Remove Parasites!</b></font></td> </tr> </table> </td> </tr> <tr> <td width="100%"> <table border="1" cellpadding="5" cellspacing="5" width="100%" bordercolor="#FFFFFF"> <tr> <td width="20%" valign="top"> <font face="Arial" size="2"><b> Navigation</b></font><br> <font face="Arial" size="2"> - <a href="http://parasitedb.freehostia.com/index.php">Home</a><br> - <a href="mailto:Webmaster@parasitedb.freehostia.com?subject=Contact Us">Contact Us</a><br> - <a href="mailto:Webmaster@parasitedb.freehostia.com?subject=Advertise">Advertise</a><br> - <a href="http://parasitedb.freehostia.com/search.php">Search</a><br> - <a href="index.php">Staff Login</a><br> - <a href="view_online.php">View Users Online</a></font> <font face="Arial" size="1"> <p> </font><font face="Arial" size="2"> <font face="Arial" size="2">Google Ads Coming Soon!</font></a><font face="Arial" size="1"> <p> <font face="Arial" size="2"><b> Sponsors</b></font><br> </font><font face="Arial" size="2">- <a href="http://malwareremoval.com/">Malware Removal</a><br> - <a href="http://pchelpforum.com/">PC Help Forum</a><br> </font></td> <td width="80%" valign="top"><b><font face="Arial"><font size="2" color="#FFFFFF"><center><br> <?php if (isset($_GET['addparasite'])): // User wants to add a joke ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <label>Name:<br /> <textarea name="parasitename" rows="1" cols="50"> </textarea></label><br /> <label>From:<br /> <textarea name="parasitefrom" rows="1" cols="50"> </textarea></label><br /> <label>Genre:<br /> <textarea name="parasitegenre" rows="1" cols="50"> </textarea></label><br / <label>Description:<br /> <textarea name="parasitedescription" rows="5" cols="50"> </textarea></label><br /> <label>Removal Info:<br /> <textarea name="parasiteremoval" rows="5" cols="50"> </textarea></label><br /> <input type="submit" value="Add" /> </form> <?php else: // Default page display $dbcnx = @mysql_connect('xxx', 'adaarm_db', 'xxx'); if (!$dbcnx) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } if (!@mysql_select_db('adaarm_db')) { exit('<p>Unable to locate the ' . 'database at this time.</p>'); } if (isset($_GET['edit'])) { $edit_id = $_GET['edit']; unset($_GET['edit']); $query = "SELECT * FROM parasite WHERE id='$edit_id'"; $result = mysql_query($query)or die(mysql_error()); $data = mysql_fetch_assoc($result); ?> <fieldset><legend>Parasite Edit</legend> <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <input type="hidden" name="id" value="<?php echo $data['id']; ?>"> Parasitename:<input type="text" name="parasitename" value="<?php echo $data['parasitename']; ?>"><br /> Parasitefrom:<input type="text" name"parasitefrom" value="<?php echo $data['parasitefrom']; ?>"><br /> Parasitegenre:<input type="text" name="parasitegenre" value="<?php echo $data['parasitegenre']; ?>"><br /> Parasitedescription:<input type="text" name="parasitedescription" value="<?php echo $data['parasitedescription']; ?>"><br /> Parasiteremoval:<input type="text" name="parasiteremoval" value="<?php echo $data['parasiteremoval']; ?>"><br /> <input type="submit" value="Submit" name="parasiteedit"> </form> </fieldset> <?php } if (isset($_REQUEST['parasiteedit'])) { $n = $_REQUEST['parasitename']; $f = $_REQUEST['parasitefrom']; $g = $_REQUEST['parasitegenre']; $d = $_REQUEST['parasitedescription']; $r = $_REQUEST['parasiteremoval']; $id= $_REQUEST['id']; $edit_sql = "UPDATE parasite SET parasitename='$n', parasitefrom='$f', parasitegenre='$g', parasitedescription='$d', parasiteremoval='$r' WHERE id='$id'"; $result = mysql_query($edit_sql)or die(mysql_error()); if ($result) { echo "The parasite named $edit_name has been changed.<br /> New values: <br /> Parasitename: $parasitename <br /> Parasitefrom: $parasitefrom <br /> Parasitegenre: $parasitegenre <br /> Parasitedescription: $parasitedescription <br /> Parasiteremoval: $parasiteremoval"; }else{ echo "The edit request could not be carried out."; } } if (isset($_GET['delete'])) { $delete_id = $_GET['delete']; $delete_name = $_GET['name']; unset($_GET['name']); unset($_GET['delete']); $delete_sql = "DELETE * FROM parasite WHERE id='$delete_id'"; $result = mysql_query($delete_sql)or die(mysql_error()); if ($result) { echo "The parasite named $delete_name had been deleted."; }else{ echo "The delete could not be carried out."; } } if (isset($_POST['parasitename'])) { $parasitename = $_POST['parasitename']; $parasitefrom = $_POST['parasitefrom']; $parasitegenre = $_POST['parasitegenre']; $parasitedescription = $_POST['parasitedescription']; $parasitetechremoval = $_POST['parasiteremoval']; $sql = "INSERT INTO parasite SET parasitename='$parasitename', parasitefrom='$parasitefrom', parasitegenre='$parasitegenre', parasitedescription='$parasitedescription', parasiteremoval='$parasiteremoval'"; if (@mysql_query($sql)) { echo "<p>The parasite '$parasitename' has been added.</p>"; } else { echo '<p>Error adding submitted parasite: ' . mysql_error() . '</p>'; } } include'notes.php'; echo '<p><a href="' . $_SERVER['PHP_SELF'] . '?addparasite=1">Add a Parasite</a></p>'; $sql = mysql_query("SELECT parasitename,parasitefrom,parasitegenre,parasitedescription,parasiteremoval,id FROM parasite ORDER BY parasitename ASC") or die(mysql_error()); echo "Parasites in Database:<br><br>"; echo "<table width=90% align=center border=1><tr> <td align=center>Name</td> <td align=center>From</td> <td align=center>Genre</td> </tr>"; while ($r = mysql_fetch_array($sql)) { // Begin while $id = $r["id"]; $name = $r["parasitename"]; $from = $r["parasitefrom"]; $genre = $r["parasitegenre"]; $description = $r["parasitegenre"]; $removal = $r["parasiteremoval"]; /* create a $_GET variable called delete using the objects id. Edit the this page link to the name of this page.*/ echo "<tr> <td><a href=view.php?id=$id>$name</a></td> <td>$from</td> <td>$genre</td> <td><a href='thispage.php?delete=$id&name=$name'>Delete</a></td> <td><a href='thispage.php?edit=$id>Edit</a></tr>"; } // end while echo "</table>"; endif; ?> </table> </center> </div> <p> </td> </tr> </table> </td> </tr> <tr> <td width="100%"> <p align="center"><font size="2"><font face="Arial">All Site Content © 2007 - ParasiteDB<br>All Rights Reserved</font></td> </tr> </table> </BODY> </html> Thanks, Adam Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-316365 Share on other sites More sharing options...
teng84 Posted August 6, 2007 Share Posted August 6, 2007 <html> <head> <title>ParasiteDB - Research and Remove Parasites!</title> <META content="parasite, virus, malware, removal, computer, pc, database, pdb, db" name=keywords> <META content="You can research and find ways to remove hundreds of different parasites here. Come take a look!" name=description> <style TYPE="text/css"> A{text-decoration:none} A:hover{color:#FFFFFF;text-decoration:underline} } BODY { SCROLLBAR-FACE-COLOR: #000000; SCROLLBAR-HIGHLIGHT-COLOR: #000000; SCROLLBAR-SHADOW-COLOR: #0099CC; SCROLLBAR-3DLIGHT-COLOR: #0099CC; SCROLLBAR-ARROW-COLOR: #0099CC; SCROLLBAR-TRACK-COLOR: #000000; SCROLLBAR-DARKSHADOW-COLOR: #0000000; } </style> </head> <BODY BGCOLOR="#000000" TEXT="#FFFFFF" VLINK="#0099CC" ALINK="#0099CC" LINK="#0099CC" topmargin="0"> <table border="0" cellspacing="1" width="100%"> <tr> <td width="100%" background="logo.jpg"> <table border="0" cellpadding="0" cellspacing="0" width="100%" bordercolor="#FFFFFF"> <tr> <td width="100%" background="images/logo.jpg" height="80"> <p align="center"><font color="#FFFFFF" size="4" face="Arial"><b>ParasiteDB - Research and Remove Parasites!</b></font></td> </tr> </table> </td> </tr> <tr> <td width="100%"> <table border="1" cellpadding="5" cellspacing="5" width="100%" bordercolor="#FFFFFF"> <tr> <td width="20%" valign="top"> <font face="Arial" size="2"><b> Navigation</b></font><br> <font face="Arial" size="2"> - <a href="http://parasitedb.freehostia.com/index.php">Home</a><br> - <a href="mailto:Webmaster@parasitedb.freehostia.com?subject=Contact Us">Contact Us</a><br> - <a href="mailto:Webmaster@parasitedb.freehostia.com?subject=Advertise">Advertise</a><br> - <a href="http://parasitedb.freehostia.com/search.php">Search</a><br> - <a href="index.php">Staff Login</a><br> - <a href="view_online.php">View Users Online</a></font> <font face="Arial" size="1"> <p> </font><font face="Arial" size="2"> <font face="Arial" size="2">Google Ads Coming Soon!</font></a><font face="Arial" size="1"> <p> <font face="Arial" size="2"><b> Sponsors</b></font><br> </font><font face="Arial" size="2">- <a href="http://malwareremoval.com/">Malware Removal</a><br> - <a href="http://pchelpforum.com/">PC Help Forum</a><br> </font></td> <td width="80%" valign="top"><b><font face="Arial"><font size="2" color="#FFFFFF"><center><br> <?php if (isset($_GET['addparasite'])): // User wants to add a joke ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <label>Name:<br /> <textarea name="parasitename" rows="1" cols="50"> </textarea></label><br /> <label>From:<br /> <textarea name="parasitefrom" rows="1" cols="50"> </textarea></label><br /> <label>Genre:<br /> <textarea name="parasitegenre" rows="1" cols="50"> </textarea></label><br / <label>Description:<br /> <textarea name="parasitedescription" rows="5" cols="50"> </textarea></label><br /> <label>Removal Info:<br /> <textarea name="parasiteremoval" rows="5" cols="50"> </textarea></label><br /> <input type="submit" value="Add" /> </form> <?php else: // Default page display $dbcnx = @mysql_connect('xxx', 'adaarm_db', 'xxx'); if (!$dbcnx) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } if (!@mysql_select_db('adaarm_db')) { exit('<p>Unable to locate the ' . 'database at this time.</p>'); } if (isset($_GET['edit'])) { $edit_id = $_GET['edit']; unset($_GET['edit']); $query = "SELECT * FROM parasite WHERE id='$edit_id'"; $result = mysql_query($query)or die(mysql_error()); $data = mysql_fetch_assoc($result); ?> <fieldset><legend>Parasite Edit</legend> <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <input type="hidden" name="id" value="<?php echo $data['id']; ?>"> Parasitename:<input type="text" name="parasitename" value="<?php echo $data['parasitename']; ?>"><br /> Parasitefrom:<input type="text" name"parasitefrom" value="<?php echo $data['parasitefrom']; ?>"><br /> Parasitegenre:<input type="text" name="parasitegenre" value="<?php echo $data['parasitegenre']; ?>"><br /> Parasitedescription:<input type="text" name="parasitedescription" value="<?php echo $data['parasitedescription']; ?>"><br /> Parasiteremoval:<input type="text" name="parasiteremoval" value="<?php echo $data['parasiteremoval']; ?>"><br /> <input type="submit" value="Submit" name="parasiteedit"> </form> </fieldset> <?php } if (isset($_REQUEST['parasiteedit'])) { $n = $_REQUEST['parasitename']; $f = $_REQUEST['parasitefrom']; $g = $_REQUEST['parasitegenre']; $d = $_REQUEST['parasitedescription']; $r = $_REQUEST['parasiteremoval']; $id= $_REQUEST['id']; $edit_sql = "UPDATE parasite SET parasitename='$n', parasitefrom='$f', parasitegenre='$g', parasitedescription='$d', parasiteremoval='$r' WHERE id='$id'"; $result = mysql_query($edit_sql)or die(mysql_error()); if ($result) { echo "The parasite named $edit_name has been changed.<br /> New values: <br /> Parasitename: $parasitename <br /> Parasitefrom: $parasitefrom <br /> Parasitegenre: $parasitegenre <br /> Parasitedescription: $parasitedescription <br /> Parasiteremoval: $parasiteremoval"; }else{ echo "The edit request could not be carried out."; } } if (isset($_GET['delete'])) { $delete_id = $_GET['delete']; $delete_name = $_GET['name']; unset($_GET['name']); unset($_GET['delete']); $delete_sql = "DELETE * FROM parasite WHERE id='$delete_id'"; $result = mysql_query($delete_sql)or die(mysql_error()); if ($result) { echo "The parasite named $delete_name had been deleted."; }else{ echo "The delete could not be carried out."; } } if (isset($_POST['parasitename'])) { $parasitename = $_POST['parasitename']; $parasitefrom = $_POST['parasitefrom']; $parasitegenre = $_POST['parasitegenre']; $parasitedescription = $_POST['parasitedescription']; $parasitetechremoval = $_POST['parasiteremoval']; $sql = "INSERT INTO parasite SET parasitename='$parasitename', parasitefrom='$parasitefrom', parasitegenre='$parasitegenre', parasitedescription='$parasitedescription', parasiteremoval='$parasiteremoval'"; if (@mysql_query($sql)) { echo "<p>The parasite '$parasitename' has been added.</p>"; } else { echo '<p>Error adding submitted parasite: ' . mysql_error() . '</p>'; } } include'notes.php'; echo '<p><a href="' . $_SERVER['PHP_SELF'] . '?addparasite=1">Add a Parasite</a></p>'; $sql = mysql_query("SELECT parasitename,parasitefrom,parasitegenre,parasitedescription,parasiteremoval,id FROM parasite ORDER BY parasitename ASC") or die(mysql_error()); echo "Parasites in Database:<br><br>"; echo "<table width=90% align=center border=1><tr> <td align=center>Name</td> <td align=center>From</td> <td align=center>Genre</td> </tr>"; while ($r = mysql_fetch_array($sql)) { // Begin while $id = $r["id"]; $name = $r["parasitename"]; $from = $r["parasitefrom"]; $genre = $r["parasitegenre"]; $description = $r["parasitegenre"]; $removal = $r["parasiteremoval"]; /* create a $_GET variable called delete using the objects id. Edit the this page link to the name of this page.*/ echo "<tr> <td><a href=view.php?id=$id>$name</a></td> <td>$from</td> <td>$genre</td> <td><a href='thispage.php?delete=$id&name=$name'>Delete</a></td> <td><a href='thispage.php?edit=$id>Edit</a></td> </tr>"; } // end while echo "</table>"; endif; ?> </table> </center> </div> <p> </td> </tr> </table> </td> </tr> <tr> <td width="100%"> <p align="center"><font size="2"><font face="Arial">All Site Content © 2007 - ParasiteDB<br>All Rights Reserved</font></td> </tr> </table> </BODY> </html> you missed </td> indent your code properly to avoid syntax error Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-316366 Share on other sites More sharing options...
EagleAmerican Posted August 6, 2007 Author Share Posted August 6, 2007 Same thing is happening. I can't figure it out.. looked at it. Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-316372 Share on other sites More sharing options...
EagleAmerican Posted August 6, 2007 Author Share Posted August 6, 2007 Found it, ' was missing. Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-316375 Share on other sites More sharing options...
EagleAmerican Posted August 6, 2007 Author Share Posted August 6, 2007 It all looks good now! Thanks all!! But now upon trying to delete I get this error: 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 '* FROM parasite WHERE id='32'' at line 1 Upon edit it added a new one with the same values and edited the old one but removed the from data. Wierd. Page code: <html> <head> <title>ParasiteDB - Research and Remove Parasites!</title> <META content="parasite, virus, malware, removal, computer, pc, database, pdb, db" name=keywords> <META content="You can research and find ways to remove hundreds of different parasites here. Come take a look!" name=description> <style TYPE="text/css"> A{text-decoration:none} A:hover{color:#FFFFFF;text-decoration:underline} } BODY { SCROLLBAR-FACE-COLOR: #000000; SCROLLBAR-HIGHLIGHT-COLOR: #000000; SCROLLBAR-SHADOW-COLOR: #0099CC; SCROLLBAR-3DLIGHT-COLOR: #0099CC; SCROLLBAR-ARROW-COLOR: #0099CC; SCROLLBAR-TRACK-COLOR: #000000; SCROLLBAR-DARKSHADOW-COLOR: #0000000; } </style> </head> <BODY BGCOLOR="#000000" TEXT="#FFFFFF" VLINK="#0099CC" ALINK="#0099CC" LINK="#0099CC" topmargin="0"> <table border="0" cellspacing="1" width="100%"> <tr> <td width="100%" background="logo.jpg"> <table border="0" cellpadding="0" cellspacing="0" width="100%" bordercolor="#FFFFFF"> <tr> <td width="100%" background="images/logo.jpg" height="80"> <p align="center"><font color="#FFFFFF" size="4" face="Arial"><b>ParasiteDB - Research and Remove Parasites!</b></font></td> </tr> </table> </td> </tr> <tr> <td width="100%"> <table border="1" cellpadding="5" cellspacing="5" width="100%" bordercolor="#FFFFFF"> <tr> <td width="20%" valign="top"> <font face="Arial" size="2"><b> Navigation</b></font><br> <font face="Arial" size="2"> - <a href="http://parasitedb.freehostia.com/index.php">Home</a><br> - <a href="mailto:Webmaster@parasitedb.freehostia.com?subject=Contact Us">Contact Us</a><br> - <a href="mailto:Webmaster@parasitedb.freehostia.com?subject=Advertise">Advertise</a><br> - <a href="http://parasitedb.freehostia.com/search.php">Search</a><br> - <a href="index.php">Staff Login</a><br> - <a href="view_online.php">View Users Online</a></font> <font face="Arial" size="1"> <p> </font><font face="Arial" size="2"> <font face="Arial" size="2">Google Ads Coming Soon!</font></a><font face="Arial" size="1"> <p> <font face="Arial" size="2"><b> Sponsors</b></font><br> </font><font face="Arial" size="2">- <a href="http://malwareremoval.com/">Malware Removal</a><br> - <a href="http://pchelpforum.com/">PC Help Forum</a><br> </font></td> <td width="80%" valign="top"><b><font face="Arial"><font size="2" color="#FFFFFF"><center><br> <?php if (isset($_GET['addparasite'])): // User wants to add a joke ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <label>Name:<br /> <textarea name="parasitename" rows="1" cols="50"> </textarea></label><br /> <label>From:<br /> <textarea name="parasitefrom" rows="1" cols="50"> </textarea></label><br /> <label>Genre:<br /> <textarea name="parasitegenre" rows="1" cols="50"> </textarea></label><br / <label>Description:<br /> <textarea name="parasitedescription" rows="5" cols="50"> </textarea></label><br /> <label>Removal Info:<br /> <textarea name="parasiteremoval" rows="5" cols="50"> </textarea></label><br /> <input type="submit" value="Add" /> </form> <?php else: // Default page display $dbcnx = @mysql_connect('xxx', 'adaarm_db', 'xxx'); if (!$dbcnx) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } if (!@mysql_select_db('adaarm_db')) { exit('<p>Unable to locate the ' . 'database at this time.</p>'); } if (isset($_GET['edit'])) { $edit_id = $_GET['edit']; unset($_GET['edit']); $query = "SELECT * FROM parasite WHERE id='$edit_id'"; $result = mysql_query($query)or die(mysql_error()); $data = mysql_fetch_assoc($result); ?> <fieldset><legend>Parasite Edit</legend> <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <input type="hidden" name="id" value="<?php echo $data['id']; ?>"> Parasitename:<input type="text" name="parasitename" value="<?php echo $data['parasitename']; ?>"><br /> Parasitefrom:<input type="text" name"parasitefrom" value="<?php echo $data['parasitefrom']; ?>"><br /> Parasitegenre:<input type="text" name="parasitegenre" value="<?php echo $data['parasitegenre']; ?>"><br /> Parasitedescription:<input type="text" name="parasitedescription" value="<?php echo $data['parasitedescription']; ?>"><br /> Parasiteremoval:<input type="text" name="parasiteremoval" value="<?php echo $data['parasiteremoval']; ?>"><br /> <input type="submit" value="Submit" name="parasiteedit"> </form> </fieldset> <?php } if (isset($_REQUEST['parasiteedit'])) { $n = $_REQUEST['parasitename']; $f = $_REQUEST['parasitefrom']; $g = $_REQUEST['parasitegenre']; $d = $_REQUEST['parasitedescription']; $r = $_REQUEST['parasiteremoval']; $id= $_REQUEST['id']; $edit_sql = "UPDATE parasite SET parasitename='$n', parasitefrom='$f', parasitegenre='$g', parasitedescription='$d', parasiteremoval='$r' WHERE id='$id'"; $result = mysql_query($edit_sql)or die(mysql_error()); if ($result) { echo "The parasite named $edit_name has been changed.<br /> New values: <br /> Parasitename: $parasitename <br /> Parasitefrom: $parasitefrom <br /> Parasitegenre: $parasitegenre <br /> Parasitedescription: $parasitedescription <br /> Parasiteremoval: $parasiteremoval"; }else{ echo "The edit request could not be carried out."; } } if (isset($_GET['delete'])) { $delete_id = $_GET['delete']; $delete_name = $_GET['name']; unset($_GET['name']); unset($_GET['delete']); $delete_sql = "DELETE * FROM parasite WHERE id='$delete_id'"; $result = mysql_query($delete_sql)or die(mysql_error()); if ($result) { echo "The parasite named $delete_name had been deleted."; }else{ echo "The delete could not be carried out."; } } if (isset($_POST['parasitename'])) { $parasitename = $_POST['parasitename']; $parasitefrom = $_POST['parasitefrom']; $parasitegenre = $_POST['parasitegenre']; $parasitedescription = $_POST['parasitedescription']; $parasitetechremoval = $_POST['parasiteremoval']; $sql = "INSERT INTO parasite SET parasitename='$parasitename', parasitefrom='$parasitefrom', parasitegenre='$parasitegenre', parasitedescription='$parasitedescription', parasiteremoval='$parasiteremoval'"; if (@mysql_query($sql)) { echo "<p>The parasite '$parasitename' has been added.</p>"; } else { echo '<p>Error adding submitted parasite: ' . mysql_error() . '</p>'; } } echo '<p><a href="' . $_SERVER['PHP_SELF'] . '?addparasite=1">Add a Parasite</a></p>'; $sql = mysql_query("SELECT parasitename,parasitefrom,parasitegenre,parasitedescription,parasiteremoval,id FROM parasite ORDER BY parasitename ASC") or die(mysql_error()); echo "Parasites in Database:<br><br>"; echo "<table width=90% align=center border=1><tr> <td align=center>Name</td> <td align=center>From</td> <td align=center>Genre</td> </tr>"; while ($r = mysql_fetch_array($sql)) { // Begin while $id = $r["id"]; $name = $r["parasitename"]; $from = $r["parasitefrom"]; $genre = $r["parasitegenre"]; $description = $r["parasitegenre"]; $removal = $r["parasiteremoval"]; /* create a $_GET variable called delete using the objects id. Edit the this page link to the name of this page.*/ echo "<tr> <td><a href=view.php?id=$id>$name</a></td> <td>$from</td> <td>$genre</td> <td><a href='thispage.php?delete=$id&name=$name'>Delete</a></td> <td><a href='thispage.php?edit=$id'>Edit</a></td></tr>"; } // end while echo "</table>"; endif; ?> </table> </center> </div> <p> </td> </tr> </table> </td> </tr> <tr> <td width="100%"> <p align="center"><font size="2"><font face="Arial">All Site Content © 2007 - ParasiteDB<br>All Rights Reserved</font></td> </tr> </table> </BODY> </html> All help appreciated. Thanks, Adam Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-316378 Share on other sites More sharing options...
teng84 Posted August 6, 2007 Share Posted August 6, 2007 try $query = "SELECT * FROM parasite WHERE id=".$edit_id.""; Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-316379 Share on other sites More sharing options...
EagleAmerican Posted August 6, 2007 Author Share Posted August 6, 2007 *Fixed* Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-316380 Share on other sites More sharing options...
EagleAmerican Posted August 6, 2007 Author Share Posted August 6, 2007 Ok all I need fixed now is that delete. I don't understand why that isn't working. The edit and add I fixed and are working great, thanks!! Now lets see if we can get that dang delete to work. Any ideas? =/ New code: <html> <head> <title>ParasiteDB - Research and Remove Parasites!</title> <META content="parasite, virus, malware, removal, computer, pc, database, pdb, db" name=keywords> <META content="You can research and find ways to remove hundreds of different parasites here. Come take a look!" name=description> <style TYPE="text/css"> A{text-decoration:none} A:hover{color:#FFFFFF;text-decoration:underline} } BODY { SCROLLBAR-FACE-COLOR: #000000; SCROLLBAR-HIGHLIGHT-COLOR: #000000; SCROLLBAR-SHADOW-COLOR: #0099CC; SCROLLBAR-3DLIGHT-COLOR: #0099CC; SCROLLBAR-ARROW-COLOR: #0099CC; SCROLLBAR-TRACK-COLOR: #000000; SCROLLBAR-DARKSHADOW-COLOR: #0000000; } </style> </head> <BODY BGCOLOR="#000000" TEXT="#FFFFFF" VLINK="#0099CC" ALINK="#0099CC" LINK="#0099CC" topmargin="0"> <table border="0" cellspacing="1" width="100%"> <tr> <td width="100%" background="logo.jpg"> <table border="0" cellpadding="0" cellspacing="0" width="100%" bordercolor="#FFFFFF"> <tr> <td width="100%" background="images/logo.jpg" height="80"> <p align="center"><font color="#FFFFFF" size="4" face="Arial"><b>ParasiteDB - Research and Remove Parasites!</b></font></td> </tr> </table> </td> </tr> <tr> <td width="100%"> <table border="1" cellpadding="5" cellspacing="5" width="100%" bordercolor="#FFFFFF"> <tr> <td width="20%" valign="top"> <font face="Arial" size="2"><b> Navigation</b></font><br> <font face="Arial" size="2"> - <a href="http://parasitedb.freehostia.com/index.php">Home</a><br> - <a href="mailto:Webmaster@parasitedb.freehostia.com?subject=Contact Us">Contact Us</a><br> - <a href="mailto:Webmaster@parasitedb.freehostia.com?subject=Advertise">Advertise</a><br> - <a href="http://parasitedb.freehostia.com/search.php">Search</a><br> - <a href="index.php">Staff Login</a><br> - <a href="view_online.php">View Users Online</a></font> <font face="Arial" size="1"> <p> </font><font face="Arial" size="2"> <font face="Arial" size="2">Google Ads Coming Soon!</font></a><font face="Arial" size="1"> <p> <font face="Arial" size="2"><b> Sponsors</b></font><br> </font><font face="Arial" size="2">- <a href="http://malwareremoval.com/">Malware Removal</a><br> - <a href="http://pchelpforum.com/">PC Help Forum</a><br> </font></td> <td width="80%" valign="top"><b><font face="Arial"><font size="2" color="#FFFFFF"><center><br> <?php if (isset($_GET['addparasite'])): ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <label>Name:<br /> <textarea name="parasitename" rows="1" cols="50"> </textarea></label><br /> <label>From:<br /> <textarea name="parasitefrom" rows="1" cols="50"> </textarea></label><br /> <label>Genre:<br /> <textarea name="parasitegenre" rows="1" cols="50"> </textarea></label><br / <label>Description:<br /> <textarea name="parasitedescription" rows="5" cols="50"> </textarea></label><br /> <label>Removal Info:<br /> <textarea name="parasiteremoval" rows="5" cols="50"> </textarea></label><br /> <input type="submit" value="Add" name="parasiteadd" /> </form> <?php else: // Default page display $dbcnx = @mysql_connect('xxx', 'adaarm_db', 'xxx'); if (!$dbcnx) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } if (!@mysql_select_db('adaarm_db')) { exit('<p>Unable to locate the ' . 'database at this time.</p>'); } if (isset($_GET['edit'])) { $edit_id = $_GET['edit']; unset($_GET['edit']); $query = "SELECT * FROM parasite WHERE id='$edit_id'"; $result = mysql_query($query)or die(mysql_error()); $data = mysql_fetch_assoc($result); ?> <fieldset><legend>Parasite Edit</legend> <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <input type="hidden" name="id" value="<?php echo $data['id']; ?>"> Parasitename:<input type="text" name="parasitename" value="<?php echo $data['parasitename']; ?>"><br /> Parasitefrom:<input type="text" name="parasitefrom" value="<?php echo $data['parasitefrom']; ?>"><br /> Parasitegenre:<input type="text" name="parasitegenre" value="<?php echo $data['parasitegenre']; ?>"><br /> Parasitedescription:<input type="text" name="parasitedescription" value="<?php echo $data['parasitedescription']; ?>"><br /> Parasiteremoval:<input type="text" name="parasiteremoval" value="<?php echo $data['parasiteremoval']; ?>"><br /> <input type="submit" value="Submit" name="parasiteedit"> </form> </fieldset> <?php } if (isset($_REQUEST['parasiteedit'])) { $n = $_REQUEST['parasitename']; $f = $_REQUEST['parasitefrom']; $g = $_REQUEST['parasitegenre']; $d = $_REQUEST['parasitedescription']; $r = $_REQUEST['parasiteremoval']; $id= $_REQUEST['id']; $edit_sql = "UPDATE parasite SET parasitename='$n', parasitefrom='$f', parasitegenre='$g', parasitedescription='$d', parasiteremoval='$r' WHERE id='$id'"; $result = mysql_query($edit_sql)or die(mysql_error()); if ($result) { echo "The parasite named $edit_name has been changed.<br /> New values: <br /> Parasitename: $parasitename <br /> Parasitefrom: $parasitefrom <br /> Parasitegenre: $parasitegenre <br /> Parasitedescription: $parasitedescription <br /> Parasiteremoval: $parasiteremoval"; }else{ echo "The edit request could not be carried out."; } } if (isset($_GET['delete'])) { $delete_id = $_GET['delete']; unset($_GET['delete']); $delete_sql = "DELETE * FROM parasite WHERE id='$delete_id'"; $result = mysql_query($delete_sql)or die(mysql_error()); if ($result) { echo "The parasite has been deleted."; } else { echo "The delete could not be carried out."; } } if (isset($_POST['parasiteadd'])) { $parasitename = $_POST['parasitename']; $parasitefrom = $_POST['parasitefrom']; $parasitegenre = $_POST['parasitegenre']; $parasitedescription = $_POST['parasitedescription']; $parasitetechremoval = $_POST['parasiteremoval']; $sql = "INSERT INTO parasite SET parasitename='$parasitename', parasitefrom='$parasitefrom', parasitegenre='$parasitegenre', parasitedescription='$parasitedescription', parasiteremoval='$parasiteremoval'"; if (@mysql_query($sql)) { echo "<p>The parasite '$parasitename' has been added.</p>"; } else { echo '<p>Error adding submitted parasite: ' . mysql_error() . '</p>'; } } echo '<p><a href="' . $_SERVER['PHP_SELF'] . '?addparasite=1">Add a Parasite</a></p>'; $sql = mysql_query("SELECT parasitename,parasitefrom,parasitegenre,parasitedescription,parasiteremoval,id FROM parasite ORDER BY parasitename ASC") or die(mysql_error()); echo "Parasites in Database:<br><br>"; echo "<table width=90% align=center border=1><tr> <td align=center>Name</td> <td align=center>From</td> <td align=center>Genre</td> <td align=center>Delete</td> <td align=center>Edit</td> </tr>"; while ($r = mysql_fetch_array($sql)) { // Begin while $id = $r["id"]; $name = $r["parasitename"]; $from = $r["parasitefrom"]; $genre = $r["parasitegenre"]; $description = $r["parasitegenre"]; $removal = $r["parasiteremoval"]; /* create a $_GET variable called delete using the objects id. Edit the this page link to the name of this page.*/ echo "<tr> <td><a href=view.php?id=$id>$name</a></td> <td>$from</td> <td>$genre</td> <td><a href='index.php?delete=$id'>Delete</a></td> <td><a href='index.php?edit=$id'>Edit</a></td></tr>"; } // end while echo "</table>"; endif; ?> </table> </center> </div> <p> </td> </tr> </table> </td> </tr> <tr> <td width="100%"> <p align="center"><font size="2"><font face="Arial">All Site Content © 2007 - ParasiteDB<br>All Rights Reserved</font></td> </tr> </table> </BODY> </html> Thanks for all of your help, Adam Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-316384 Share on other sites More sharing options...
teng84 Posted August 6, 2007 Share Posted August 6, 2007 your code $delete_sql = "DELETE * FROM parasite WHERE id='$delete_id'"; should remove the * Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-316388 Share on other sites More sharing options...
EagleAmerican Posted August 6, 2007 Author Share Posted August 6, 2007 Thank you so much!! As that is a sensitive link and deletes without any confirmation.. how could I make a popup message before it executes it? Like it does a popup box that says Are you sure you want to delete? Ok or Cancel (or something like that) as the buttons and Cancel just keeps them on the page like nothing happened and Ok will go ahead and delete it. Thanks, Adam Quote Link to comment https://forums.phpfreaks.com/topic/62711-solved-edit-and-delete-function/#findComment-316390 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.