Re: sql query successful

From: Date: Thu, 19 Jul 2001 03:05:50 +0000
Subject: Re: sql query successful
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-58603@lists.php.net to get a copy of this message
On Thu, 19 Jul 2001 03:54, Tyler Longren wrote: > Hello everyone, > > I've been writing database enabled site for quite a while now. One > thing I have never figured out it how to determine if a sql query is > successful. > > This works: > if ($connection = mysql_connect("host","username","password")) { > print "Successful connection": > } > else { > print "No connection"; > } > > But this won't work: > > if ($sql = mysql_query("SELECT * FROM table ORDER BY rand()")) { > print "SQL executed successfully."; > } > else { > print "SQL not executed successfully."; > } > > Can anyone tell me how I can tell if the SQL executed successfully? Is > there any method besides OR DIE? > > Thanks, > Tyler You might want to look into mysql_errno and mysql_error; also mysql_affected_rows to give you feedback on INSERT, UPDATE and DELETE operations -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA Can I yell "movie" in a crowded firehouse?

« previous php.general (#58603) next »