I'm trying to adapt the code from the "jokes tutorial" to delete profiles from my database.
I'd like to delete ALL of that players info from the database but I'm having trouble with the code.
The way I have it now is like this:
On the Barracks page (for admins) there is a table that lists all the members of our team. At the end of that there are options to Edit, Update, or Delete those players. But I Don't want just one accidental click to erase the profile so here's what I did.
When you click the link "Delete" for that player it takes you to another page using the url like this
"profiledelete.php?playername=Smokey"
Here's the code from profiledelete.php
When this is run I get the error "Error deleting profile: You have an error in your SQL syntax near '' at line 1"PHP Code:<?php
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2001 by Francisco Burzi (fbc@mandrakesoft.com) */
/* h*tp://phpnuke.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
if(!IsSet($mainfile)) { include ("mainfile.php"); }
include ("header.php");
if ("Delete Player" == $deleteplayer) {
$sql = "DELETE FROM player_profile " .
"WHERE playername=$playername";
if (mysql_query($sql)) {
echo("<P>Your profile has been deleted.</P>");
} else {
echo("<P>Error deleting profile: " .
mysql_error() . "</P>"); }}
?>
<table width="99%" border="1" cellspacing="0" cellpadding="0" bordercolor="#003300">
<tr>
<td bgcolor="#003300">Confirm Deletion</td>
</tr>
<tr>
<td align="center">
<p> </p>
<p>Are you sure you want to delete the player
"<?php echo ("$playername"); ?>"
From the Roster?</p>
<FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD="POST">
<input type="submit" name="deleteplayer" value="Delete Player">
</form>
<p> </p>
</td>
</tr>
</table>
<?php
include ("footer.php");
?>
What's wrong with this code?![]()
Can you help please? TIA





Bookmarks