Re: MySQL problem...

From: Date: Thu, 26 Apr 2001 03:23:55 +0000
Subject: Re: MySQL problem...
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-50421@lists.php.net to get a copy of this message
Here's all the code that uses MySQL... $db = mysql_connect("localhost","user","pass"); mysql_select_db("db",$db); $gmdquery="SELECT * FROM game_of_the_day"; $the_info = mysql_query($gmdquery,$db); while ($myrow = mysql_fetch_row($the_info)) { (get info from the result) } ... (decide whether or not to conduct the following operation) if (true) { $query="SELECT id FROM games WHERE rating >= 7"; $result=mysql_query($query,$db); $numgames=mysql_num_rows($result); $z=0; while ($row=mysql_fetch_row($result)){ $gotd_cand[$z]=$row[0]; $z++; } (at this point, i randomly select 2 games from the db) $query="SELECT genre,number FROM games WHERE id=$game1_to_get"; $gameinfo=mysql_query($query,$db); while($row=mysql_fetch_row($gameinfo)){ (use the result) } (do the same thing as before, but for the second game) } (update the db) $query="DELETE FROM game_of_the_day"; $result=mysql_query($query,$db); $query="INSERT INTO game_of_the_day VALUES ('',$curr_yday,'$gameone_genre',$gameone_number,'$gametwo_genre',$gametwo_nu mber)"; $result=mysql_query($query,$db); } Keep in mind that this only happens some of the time... sometimes it works, and sometimes it just doesn't. Today, I noticed that it stored the first game into the db twice (the code doesn't allow for the same game to be selected twice...) Thanks for your time ""Peter Houchin"" <peterh@vfsa.com.au> wrote in message news:NFBBJNAGDIPHLCGPBLKDGECFCEAA.peterh@sunrentals.com.au... > some code would be nice to have a look at :) > > Other than that, check table names, database names, also your result lines, I've found i get that error by not calling a result or calling the incorrect table/database > > Peter > > -----Original Message----- > From: Brian Rue [mailto:dwjw@QuixNet.net] > Sent: Thursday, April 26, 2001 10:28 AM > To: php-general@lists.php.net > Subject: [PHP] MySQL problem... > > > MySQL doesn't like me.... > > Sometimes, my pages that connect to the database get the error "Warning: > Supplied argument is not a valid MySQL result resource..." repeated over and > over again (something like 1000 times...) > > What's causing this error? Obviously, PHP isn't getting a result back from > MySQL... and it keeps trying to get it. > > Any help? > > > Thanks, > Brian Rue > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#50421) next »