Jump to content

its not showing right if i do a query. no matter what it echos sucessful wtf?


emopoops

Recommended Posts

$flush55 = mysql_query("DELETE FROM dumps WHERE id='$flushing' AND time = '$wow'");
$flush2 = mysql_query("DELETE FROM tp WHERE dump = '$flushing'");
if($flush55){echo "SUCCESSFULLY FLUSHED THE DUMP HON!<br>";}

i dont understand because the variables arent the right ones (like i put in fake ones because they are coming from a $_GET POST.. to see if people could mass delete stuff and no matter what it says sucessful, and THERE IS NOTHING BEING DELETED halp!

Link to comment
Share on other sites

it seems to me like the query is being successful. keep in mind that just because it is successful does not mean that it actually did anything. It could have went through the database and looked for values that matched your criteria but didnt find any so it did nothing. However, that would show as successful because it didnt get any errors along the way. But if there was an error in there then it would not show as successful. You should try passing values that you know meet your criteria and check the data then because hte query looks fine. you could always do an or die(mysql_error()) after your query to see if there was an error.

Link to comment
Share on other sites

you could do something like this:

 

$flush55 = mysql_query("DELETE FROM dumps WHERE id='$flushing' AND time = '$wow'");
$flush2 = mysql_query("DELETE FROM tp WHERE dump = '$flushing'");

if($flush55 && mysql_affected_rows() > 0){
  echo "SUCCESSFULLY FLUSHED THE DUMP HON!<br>";
} else {
  echo "no rows affected";
}

 

The mysql_affected_rows is just a count of the number of rows that were changed. so all I did was add a check to see if the affect rows is greater than 0 (basically a row was changed).

Link to comment
Share on other sites

THANK YOU that function is just what i will use. BUT do u or anyone know about the %d\n in the thing from the php manual for that function.

/* this should return the correct numbers of deleted records */
mysql_query('DELETE FROM mytable WHERE id < 10');
printf("Records deleted: %d\n", mysql_affected_rows());

i took it out and it didnt work

Link to comment
Share on other sites

it is a placeholder for mysql_affected_rows(). the printf() function takes 2 or more arguments the first one is a string, the second is variables. anthing that is set with a % sign infront of it is a placeholder for a variable. the d after the % means that it is going to be an integer (see sprintf() for format http://www.php.net/manual/en/function.sprintf.php) heres a few examples:

 

$name = 'nick';
$age = 23;
printf('My name is %s and my age is %d.', $name, $age);

 

So this would show this on the screen:

My name is nick and my age is 23.

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.