Dark Prince Posted February 15, 2012 Share Posted February 15, 2012 with the mysqli_affected_rows() function can it be run more then once in a script that has more then 1 update or insert query? like eg. I have an update query in a script and after the query is run I use if (mysqli_affected_rows($dbc) == 1) { // if this table is updated only then update the other table. $query2 = "UPDATE etc. etc." $result2 = mysqli_query($dbc, $query2); // Can I use mysqli_affected_rows() again here? } else { // First update did not work. // echo error statement here. } Link to comment Share on other sites More sharing options...
Larry Posted February 15, 2012 Share Posted February 15, 2012 Absolutely. If you tried this, you would have seen for yourself. Link to comment Share on other sites More sharing options...
Dark Prince Posted February 16, 2012 Author Share Posted February 16, 2012 I just found it odd looking at it in a literal way because it's checking to see if mysql has an affected row then to run it again the affected row would have already been affected, unlike mysqli_num_rows where you have to also include the query and not just the database connection Link to comment Share on other sites More sharing options...
Larry Posted February 17, 2012 Share Posted February 17, 2012 I see what you mean, but it's checking if there's an affected row for the most recent query on the current connection. Link to comment Share on other sites More sharing options...
Recommended Posts