Thanks... Works like a champ....
Bruce
"Tom Thackrey" <use.signature@nospam.com> wrote in message
news:ZMYtb.10650$0E6.9470@newssvr29.news.prodigy.c om...[color=blue]
>
> On 16-Nov-2003, "Bruce A. Julseth" <bruceaj@attglobal.net> wrote:
>[color=green]
> > I know the following $sql will fail since there is no Customer='Smith'.[/color][/color]
I[color=blue][color=green]
> > want to determine how to test a failure of mysql_query.
> >
> > I thought mysql_query returned false if a query failed. The test fail[/color][/color]
path[color=blue][color=green]
> > is never taken in the following code is never taken.
> >
> > Also, I get an invalid argument on mysql_num_rows($Result) error[/color][/color]
message.[color=blue][color=green]
> >
> > $sql = "Update Table Set Password='password' where[/color][/color]
Customer='Smith';[color=blue][color=green]
> >
> > $Connection = mysql_connect("localhost", "User", "PW") Or
> > die(mysql_error());
> >
> > $DB = mysql_select_db("Database", $Connection);
> >
> > $Result = mysql_query($sql, $Connection) or die(mysql_error());
> >
> > if(!$Result) {
> >
> > echo "Fail<br>";
> >
> > }
> >
> > $Rows = mysql_num_rows($Result) or die(mysql_error());
> >
> > if($Rows > 0) {
> >
> > echo "Success Rows: $Rows<br>";
> >
> > } else {
> >
> > echo "Failure<br>";
> >
> > }
> >
> > What do I need to do to test for a mysql_query failure?[/color]
>
> The query will not 'fail' it will not affect any rows. Use
> mysql_affected_rows() and check for zero.
>
> --
> Tom Thackrey
>
www.creative-light.com
> tom (at) creative (dash) light (dot) com
> do NOT send email to
jamesbutler@willglen.net (it's reserved for spammers)[/color]