emopoops Posted December 12, 2009 Share Posted December 12, 2009 $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 https://forums.phpfreaks.com/topic/184866-its-not-showing-right-if-i-do-a-query-no-matter-what-it-echos-sucessful-wtf/ Share on other sites More sharing options...
ngreenwood6 Posted December 12, 2009 Share Posted December 12, 2009 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 https://forums.phpfreaks.com/topic/184866-its-not-showing-right-if-i-do-a-query-no-matter-what-it-echos-sucessful-wtf/#findComment-975862 Share on other sites More sharing options...
emopoops Posted December 12, 2009 Author Share Posted December 12, 2009 oh ok well i was just thinking if it was sucessful that meant it actually did something.. well how can i check if it did something? or better yet how can i check if it didnt do anything so i can hold off on putting out the "SUCCESS" echo Link to comment https://forums.phpfreaks.com/topic/184866-its-not-showing-right-if-i-do-a-query-no-matter-what-it-echos-sucessful-wtf/#findComment-975868 Share on other sites More sharing options...
ngreenwood6 Posted December 12, 2009 Share Posted December 12, 2009 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 https://forums.phpfreaks.com/topic/184866-its-not-showing-right-if-i-do-a-query-no-matter-what-it-echos-sucessful-wtf/#findComment-975874 Share on other sites More sharing options...
emopoops Posted December 12, 2009 Author Share Posted December 12, 2009 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 https://forums.phpfreaks.com/topic/184866-its-not-showing-right-if-i-do-a-query-no-matter-what-it-echos-sucessful-wtf/#findComment-975878 Share on other sites More sharing options...
ngreenwood6 Posted December 12, 2009 Share Posted December 12, 2009 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 https://forums.phpfreaks.com/topic/184866-its-not-showing-right-if-i-do-a-query-no-matter-what-it-echos-sucessful-wtf/#findComment-975889 Share on other sites More sharing options...
emopoops Posted December 12, 2009 Author Share Posted December 12, 2009 wow thats complicated! i thot it was printf not sprintf Link to comment https://forums.phpfreaks.com/topic/184866-its-not-showing-right-if-i-do-a-query-no-matter-what-it-echos-sucessful-wtf/#findComment-975893 Share on other sites More sharing options...
cags Posted December 12, 2009 Share Posted December 12, 2009 printf and sprintf are different functions. The first outputs a formatted string to the screen. The second returns a string that has been formatted Link to comment https://forums.phpfreaks.com/topic/184866-its-not-showing-right-if-i-do-a-query-no-matter-what-it-echos-sucessful-wtf/#findComment-975919 Share on other sites More sharing options...
ngreenwood6 Posted December 12, 2009 Share Posted December 12, 2009 printf and sprintf are different functions like cags said but if you look at the print f page it links you to the sprintf page for the format, which is why i sent you a link to that page. it shows you how to use the %d and %s Link to comment https://forums.phpfreaks.com/topic/184866-its-not-showing-right-if-i-do-a-query-no-matter-what-it-echos-sucessful-wtf/#findComment-976072 Share on other sites More sharing options...
emopoops Posted December 13, 2009 Author Share Posted December 13, 2009 oo ok Link to comment https://forums.phpfreaks.com/topic/184866-its-not-showing-right-if-i-do-a-query-no-matter-what-it-echos-sucessful-wtf/#findComment-976306 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.