Grabeorama Posted October 25, 2010 Share Posted October 25, 2010 On my page I have two variables:$ERROR = "";$IS_ERROR = falseI then have a mySQL query, the contents of which doesn't matter. What I'd like to do is add text to the $ERROR string and set $IS_ERROR to true if the query fails. I've previously done this using:$res = mysql_query("query") or print(mysql_error());But I don't want to display the error message until later on in the page.So I'd either like to use more than one expression after the "or", or use an if statement to check whether it has returned an error, if so change the variables.eg:if ($res = false) {[set variables]}Any help is appretiated Link to comment Share on other sites More sharing options...
Ixzion Posted October 25, 2010 Share Posted October 25, 2010 I'm not currently in a position to test this, but I think this would work: $res = mysql_query("query");if (!$res){$ERROR = "my text";$ISERROR = true;} But I would probably change the names of the error variables. I do not know which ones off the top of my head, but some variables are reserved by PHP and might cause problems. Link to comment Share on other sites More sharing options...
Grabeorama Posted October 25, 2010 Author Share Posted October 25, 2010 Ok thanks, I don't think they're reserved but I'll probably change them just in case Link to comment Share on other sites More sharing options...
Synook Posted October 25, 2010 Share Posted October 25, 2010 They don't appear in the list, so you should be safe. Though, by convention, you should have them in lowercase, because all caps is for constants. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.