smengler Posted July 28, 2009 Share Posted July 28, 2009 Hi, I have some php code that's not working. When I echo a variable called $gameurl which is equal to $line["swf"], which is an array element from a database, which is equal to "../games/swf/Wacky_Ride.swf" it runs a separate mySQL query. I can't figure out why. Here's my code, the code that's giving me problems is in bold. The code "mysql_query("UPDATE games SET numOfPlays=numOfPlays+1 WHERE id='$gameid'");" always gets run twice if I have "<?PHP echo("..".$line["swf"]); ?>" in the embed src. Thanks for your help! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?PHP include_once "../scripts/php/BodyClass.php"; $newBodyClass = new BodyClass("../"); $bodyClass = $newBodyClass->getTheme('defaultTheme'); ?> <html> <head> <link rel="stylesheet" type="text/css" href="/scripts/css/siteLayout.css" /> <link rel="stylesheet" type="text/css" href="/scripts/css/themes/<?PHP echo($bodyClass)?>.css" /> </head> <?PHP include_once "../scripts/imports/GACode.php"; echo "\n"; ?> <body> <div id="container"> <div id="header"> <div id="headerLeft"><div class="logo"></div> </div> <div id="headerRight"> <script type="text/javascript"><!-- google_ad_client = "pub-6675445346935520"; /* Top Banner */ google_ad_slot = "3042382059"; google_ad_width = 728; google_ad_height = 90; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> </div> </div> <div id="menu"> <a href="/"><div>Home</div></a> <a href="/games/genres/sports.php"><div>Sports</div></a> <a href="/games/genres/shooting.php"><div>Shooting</div></a> <a href="/games/genres/adventure.php"><div>Adventure</div></a> <a href="/games/genres/action.php"><div>Action</div></a> <a href="/games/genres/arcade.php"><div>Arcade</div></a> <a href="/games/genres/puzzle.php"><div>Puzzle</div></a> <a href="/games/genres/strategy.php"><div>Strategy</div></a> <a href="/games/genres/other.php"><div>Other</div></a> <a href="/upload-game.php"><div>Submit Game</div></a> <div><form enctype="multipart/form-data" action="/games/searchgames.php" method="GET"><font>Search: <input name="q"/></font></form></div><br/> </div> <div id="content"> <div id="left"> <br/> <?PHP include '../scripts/imports/databaseUserPassAndHost.php'; // $gameid = ''; $gameurl = ''; if(isset($_GET['id'])){ $gameid = $_GET['id']; }else{ echo("<font face=\"Arial\" size=\"4\" color=\"red\"><b>Sorry, this game cannot be found.</b></font>"); } $link = mysql_connect($dbHost,$dbGamesUsername,$dbGamesPassword); mysql_select_db($dbGamesDatabase); // $sql = "SELECT * FROM games WHERE id='$gameid'"; if($results = mysql_query($sql)){ }else{ echo "Please Try Again!"; } [b]$line = mysql_fetch_assoc($results); $gameurl = $line["swf"];[/b] [b]mysql_query("UPDATE games SET numOfPlays=numOfPlays+1 WHERE id='$gameid'");[/b] mysql_close($link); ?> <title>TodaysBestGames.com - <?PHP echo($line["name"]); ?></title> <?PHP //echo "<game imgurl='" . $line["thmb"] . "' infotext='" . $line["info"] . "' imgheight = '" . $line["thmb_height"] . "' title='" . $line["name"] . "' newgamesnumofletters='" . $line["mainGames_numOfLetters"] . "' randomgame_numofletters='" . $line["sideGames_numOfLetters"] . "' randomgame_title_numofletters='" . $line["sideGames_title_numOfLetters"] . "' gamegenre='" . $line["gameGenre"] . "'/>\n"; if(true){//$gameid != '' if(true){//$gameurl != '' $swfsize = getimagesize("..".$gameurl); ?> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="<?PHP echo($swfsize[0]); ?>" height="<?PHP echo($swfsize[1]); ?>"> <param name="movie" value="<?PHP echo("..".$gameurl); ?>" /> <param name="quality" value="high" /> <embed quality="high" src="[b]<?PHP echo("..".$line["swf"]); ?>[/b]" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="<?PHP echo($swfsize[0]); ?>" height="<?PHP echo($swfsize[1]); ?>"></embed> </object> <br/> <br/> <br/> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="227" height="57" align="middle"> <param name="movie" value="../swf/rategame.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /> <param name="wmode" value="transparent"> <param name=FlashVars value="id=<?PHP echo $gameid; ?>"> <embed FlashVars="id=<?PHP echo $gameid; ?>" src="../swf/rategame.swf" width="227" height="57" align="middle" quality="high" bgcolor="#ffffff" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" /> </embed> </object> <br/> <br/> <font> <font class="subHeading">Description:</font> <br/> <?PHP echo $line["info"]; ?> <br/> <br/> <font class="subHeading">Rating:</font> <br/> <?PHP echo $line["rating"]; ?> </font> <br/> <br/> <?PHP }else{ ?> <font size="4" color="red"><b>Sorry, this game cannot be found.</b></font> <?PHP } } ?> </div> <div id="right"> <br/> <div class="ad"> <script type="text/javascript"><!-- google_ad_client = "pub-6675445346935520"; /* 120x600, created 7/16/09 */ google_ad_slot = "3675110044"; google_ad_width = 120; google_ad_height = 600; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div> <br/> <br/> <div id="featuredGame"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="126" height="266"> <param name="movie" value="/swf/featuredgame.swf"> <param name="quality" value="high"> <param name="wmode" value="transparent"> <embed src="/swf/featuredgame.swf" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="126" height="266"> </embed> </object> </div> <br/> <br/> <div id="randomGame"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="126" height="266"> <param name="movie" value="/swf/randomgame.swf"> <param name="quality" value="high"> <param name="wmode" value="transparent"> <embed src="/swf/randomgame.swf" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="126" height="266"> </embed> </object> </div> </div> </div> </div> <div id="footer"> <?PHP include_once '../scripts/imports/bottomlinks.php'; echo"\n";?> </div> <p/> </body> </html> Link to comment https://forums.phpfreaks.com/topic/167850-weird-php-problem/ Share on other sites More sharing options...
smengler Posted July 28, 2009 Author Share Posted July 28, 2009 I've narrowed it down to the src property on the line with: <embed quality="high" src="<?PHP echo("..".$line["swf"]); ?>" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="<?PHP echo($swfsize[0]); ?>" height="<?PHP echo($swfsize[1]); ?>"></embed> Whenever it loads any swf file, it seems the server loads the page again and calls the mySQL query again. Anyone know why? Link to comment https://forums.phpfreaks.com/topic/167850-weird-php-problem/#findComment-885308 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.