Jump to content

Script Wont Delete?


Bubblychaz

Recommended Posts

My php script wont delete in selected id from the mysql database

 

 

function code

 <?php


function edit_avatar($_POST)
{
if ($_POST['delete'] == 1) {
 delete_item($_POST['id']);
 return 'deleted';
}
$errors = check_required_fields($_POST);



function delete_avatars($id)
{
$query = "DELETE FROM avatar_list WHERE id = '$id' LIMIT 1";
return mysql_query($query) or die(mysql_error());
}

 

edit page code



if (!empty($_GET['delete'])) {
echo '<p style="color: green;">The avatar has been deleted.</p>';
}




 <td>Delete Avatar:</td>
		 <td><input type="checkbox" name="delete" value="1" onclick="confirm_delete(this);"/><span style="color:red;">This cannot be undone!</span></td>



 

Ive removed the rest of the code but delete bits

Edited by Bubblychaz
Link to comment
Share on other sites

What have you done to pin down exactly at what point your code and data are doing what you expect and at what point it is not? I can guarantee that the problem lies somewhere between those two points. If all you have done is run your code and it doesn't work, all you have pined the problem down to is 'somewhere in your code.'

 

Is your code taking the expected execution path? Is the input data what you expect? The reasons I ask this is -

 

1) We cannot run your code, because we don't have all of it (nor do we want you to post all of it) and we don't have your database tables or any data (nor do we want you to post this.)

 

2) We are not going to look through 100's of lines of mostly non-relevant code trying to find just the few lines that are relevant.

Link to comment
Share on other sites

My php script wont delete in selected id from the mysql database

 

 

function code

 <?php


function edit_avatar($_POST)
{
if ($_POST['delete'] == 1) {
 delete_item($_POST['id']);
 return 'deleted';
}
$errors = check_required_fields($_POST);



function delete_avatars($id)
{
$query = "DELETE FROM avatar_list WHERE id = '$id' LIMIT 1";
return mysql_query($query) or die(mysql_error());
}

 

edit page code



if (!empty($_GET['delete'])) {
echo '<p style="color: green;">The avatar has been deleted.</p>';
}




 <td>Delete Avatar:</td>
		 <td><input type="checkbox" name="delete" value="1" onclick="confirm_delete(this);"/><span style="color:red;">This cannot be undone!</span></td>



 

Ive removed the rest of the code but delete bits

 

Thanks.

 

I'm simply guessing the edit_avatar() function gets called, then delete_item() function? I don't see where delete_avatars() is being called. Should you be calling delete_avatars() instead of delete_item()? Or is delete_item() part of a larger function that calls delete_avatars() separately?

Link to comment
Share on other sites

Please, turn on error reporting before you post any more questions, and include any errors that are generated.

 

In your php.ini file, make sure the following lines exist, and are not commented out with a leading semicolon:

 

error_reporting = -1

display_errors = On

 

Then restart Apache so the changes take effect.

Link to comment
Share on other sites

Thanks.

 

I'm simply guessing the edit_avatar() function gets called, then delete_item() function? I don't see where delete_avatars() is being called. Should you be calling delete_avatars() instead of delete_item()? Or is delete_item() part of a larger function that calls delete_avatars() separately?

 

Its fixed.. Thank you.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.