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?

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
       } 

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. :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.