I have function that performs a mysql_query()
and then does some other stuff.
I want to be able to perform another mysql_query()
only if the first one succeeds.
Here is the function
function myFunction($qtext)
{
mysql_query($qtext) or die(mysql_error() . "\n");
//do some more stuff
return true;
}
I'm calling the function and attempting to check if it failed with an if else conditional...
if(!myFunction($query_text))
{
echo "first query failed";
}
else
{
mysql_query($query_text1) or die (mysql_error() . "\n");
}
This seems to work when the first query passes, but if the first query fails it goes to the or die
and returns the mysql_error()
text and the echo "first query failed";
line in the conditional is never reached.
Ideally id like to be able to alert the user with the mysql_error text but without or die
ing, so I can run more code in the conditional.
Any help with explanations of behavior is greatly appreciated. Thanks.
p.s.
I'm a beginner... I'm not sure if Im using the return true;
properly in the function