webguync Posted April 14, 2010 Share Posted April 14, 2010 I want to add an echo to this Query if successfull. Please assist. <? session_start(); //DELETE QUERY TO SELECT RECORD TO DELETE BASED ON LOGIN INFO. $query_delete = "DELETE FROM log_March2010 WHERE user_id = $user_id AND roster_March2010.user_id = $user_id"; //echo $query; //for debugging test $result_delete = mysql_query($query_delete) or die(mysql_error()); ?> something like echo ("Deletion Successful"); would it just go below $result_delete or do I need to add an if/then? Quote Link to comment https://forums.phpfreaks.com/topic/198564-echohing-a-success-to-a-sql-query/ Share on other sites More sharing options...
Jax2 Posted April 14, 2010 Share Posted April 14, 2010 if ($result_delete) { echo "Bla Bla" }// end if ELSE { echo "Failed" } //end else Quote Link to comment https://forums.phpfreaks.com/topic/198564-echohing-a-success-to-a-sql-query/#findComment-1041982 Share on other sites More sharing options...
webguync Posted April 14, 2010 Author Share Posted April 14, 2010 thx, would I still need this line as is? $result_delete = mysql_query($query_delete) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/198564-echohing-a-success-to-a-sql-query/#findComment-1041987 Share on other sites More sharing options...
Jax2 Posted April 14, 2010 Share Posted April 14, 2010 Yep, just leave that there. That is what you need to check if it was successful or not ... Quote Link to comment https://forums.phpfreaks.com/topic/198564-echohing-a-success-to-a-sql-query/#findComment-1041990 Share on other sites More sharing options...
Maq Posted April 14, 2010 Share Posted April 14, 2010 webguync, please do not use shorthand PHP tags, use <?php instead. You also shouldn't be killing your script if a query fails, instead, handle it properly. Read more here. Quote Link to comment https://forums.phpfreaks.com/topic/198564-echohing-a-success-to-a-sql-query/#findComment-1042001 Share on other sites More sharing options...
webguync Posted April 14, 2010 Author Share Posted April 14, 2010 thanks, I'll try that out Maq. For my benefit what is the advantage of using <?php over shorthand? Quote Link to comment https://forums.phpfreaks.com/topic/198564-echohing-a-success-to-a-sql-query/#findComment-1042047 Share on other sites More sharing options...
Maq Posted April 15, 2010 Share Posted April 15, 2010 thanks, I'll try that out Maq. For my benefit what is the advantage of using <?php over shorthand? The main reason is if you ever want to port your code elsewhere and that server has short_open_tag disabled, your code will not work. Quote Link to comment https://forums.phpfreaks.com/topic/198564-echohing-a-success-to-a-sql-query/#findComment-1042414 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.