Jump to content

mySQL query [solved]


Grabeorama

Recommended Posts

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

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

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

Archived

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

×
×
  • Create New...