Re: Simple Question
| From: | Paul DuBois | Date: | Wed, 25 Oct 2000 21:40:10 +0000 |
| Subject: | Re: Simple Question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-21943@lists.php.net to get a copy of this message | ||
At 9:41 AM -0700 10-23-2000, Chris wrote:
Hi, I looked in the manual but can't find anything to help. How do I repress mysql errors from displaying?Read the chapter in the manual called "Error Handling"; it's in the "Features" section. Note the discussion of "@".
Ex: $strsql = "SELECT myval FROM table where date = '$strdte'"; $result = mysql_db_query("db",$strsql); How can I see if $result is valid?if ($result) it's valid else it's not Simple as that. mysql_db_query() returns FALSE if the statement failed. Note that a statement that returns no rows is not considered "failed", though. That's perfectly legal.
When I do echo $result, it allways prints the number 2, whether is finds data or not. If not it give me the error that mysql can jumpt to row 0 on the next statement which is: $strmydte = mysql_result($result,"myval");Pass $result to mysql_num_rows() to find out how many rows are in your result set (if $result isn't FALSE, of course.) By the way... mysql_result() takes a numeric second argument. Why are you passing "myval" to it?
I need to see if there is a result before I reach the above line so I can prevent the error display and do something else. Thanks, Chris-- Paul DuBois, paul@snake.net