Jump to content

True way to see if action was successful?


godsent

Recommended Posts

If this is a good way to see if action was successful to continue:

 

	function changeGameState($GameId)
{
	mysql_query("UPDATE challenges SET status=status+1 WHERE id='$GameId'");
}

       if (changeGameState($someId))
       {
             //was successful
       }

 

I dont know if it work or not, but i think no because changeGameState wont return any value, so I came up with another idea, but it gives me "Parse error: syntax error, unexpected T_RETURN " error in "return 0" line

 

	public function changeGameState($GameId)
{
	mysql_query("UPDATE challenges SET status=status+1 WHERE id='$GameId'")or die(return false);  
	return true; 
}

 

how can i check if action was succesful before continuing?

Link to comment
Share on other sites

try

	function changeGameState($GameId)
{
	$res = mysql_query("UPDATE challenges SET status=status+1 WHERE id='$GameId'");
                        return mysql_affected_rows($res);
}

       if (changeGameState($someId))
       {
             //was successful
       } 

Link to comment
Share on other sites

try

	function changeGameState($GameId)
{
	$res = mysql_query("UPDATE challenges SET status=status+1 WHERE id='$GameId'");
                        return mysql_affected_rows($res);
}

       if (changeGameState($someId))
       {
             //was successful
       } 

 

Works fine thanks, success returns 1, fail = -1. :)

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.