TheLostGuru Posted June 8, 2007 Share Posted June 8, 2007 I have one PHP file which I call. In it, it includes another file called setcolor.php. Inside of getcolor.php is a function called setcolor which takes 1 argument, which it runs a couple of queries on and either sets $_frame equal to 1 or equal to a number it pulls from a database. The first PHP file which has included the setcolor.php file calls the function setcolor($oid). Underneath that the variable frame is passed to a swf. However when the swf receives the variable, its value is "". The only value it should be is either 1 or a different number. I will put both php files below, the setcolor.php file second. <? include "info.php"; include "util.inc.php"; include "user.inc.php"; include "sendcolor.inc.php"; header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past ?> <div style="height:242px;width:242px;"> <?php //$_oid is a variable pulled from user.inc.php SetColor($_oid); echo '<table width="242" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td align="center"> <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="242" height="242"> <param name="movie" value="http://tlgames.siteburg.com/welcome.swf?oid =' . $_oid . '&vid=' . $_vid . '&frame=' . $_frame . '" > <param name=quality value=high > <embed src="http://tlgames.siteburg.com/welcome.swf?oid=' . $_oid . '&vid=' . $_vid . '&frame=' . $_frame . '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="242" height="242"></embed> </object> </td> </tr> </table>'; ?> </div> <? include "info.php"; mysql_connect($_server,$_user,$_password); @mysql_select_db($_database) or die( "Unable to select database"); function SetColor ($us) { $query = "SELECT frame from users WHERE userID = '$us'"; $result=mysql_query($query); $color = mysql_result($result,0,"frame"); if(mysql_numrows($result)==0) { $_frame = 2; } else { $_frame = $color; } mysql_close(); } ?> Thanks for any help. I am open to any suggestions. Link to comment https://forums.phpfreaks.com/topic/54821-solved-order-of-operations/ Share on other sites More sharing options...
pocobueno1388 Posted June 8, 2007 Share Posted June 8, 2007 You didn't include "setcolor.php" at the beginning of your script. You have "sendcolor.php"...but no "setcolor.php". From what you said, it sounds like the setColor function is inside getcolor.php, so maybe you need to include that file at the beginning of your script? Link to comment https://forums.phpfreaks.com/topic/54821-solved-order-of-operations/#findComment-271139 Share on other sites More sharing options...
TheLostGuru Posted June 9, 2007 Author Share Posted June 9, 2007 No sorry, everything I need to be included is included. I messed up the names in the start, but the php file that has the function, is included at the top. Link to comment https://forums.phpfreaks.com/topic/54821-solved-order-of-operations/#findComment-271240 Share on other sites More sharing options...
pocobueno1388 Posted June 9, 2007 Share Posted June 9, 2007 Maybe it's the function that doesn't work? Could you give the code to that? Link to comment https://forums.phpfreaks.com/topic/54821-solved-order-of-operations/#findComment-271250 Share on other sites More sharing options...
TheLostGuru Posted June 9, 2007 Author Share Posted June 9, 2007 Everything is above. I wanted to make sure that my function was working properly, so I took everything from it and just put it in the main php file. Like so... mysql_connect($_server,$_user,$_password); @mysql_select_db($_database) or die( "Unable to select database"); /////////////////////////////////////////////////////Does this var need to be in single quotes? $query = "SELECT frame from users WHERE userID = '$oid'"; $result=mysql_query($query); $color = mysql_result($result,0,"frame"); if(mysql_numrows($result)==0) { $_frame = 2; } else { $_frame = $color; When I run the php file it gives me this warning (Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 7 in /home/t/tlgames.siteburg.com/WWW/welcome2.php on line 12) and sets the $_frame to 2. Link to comment https://forums.phpfreaks.com/topic/54821-solved-order-of-operations/#findComment-271254 Share on other sites More sharing options...
chigley Posted June 9, 2007 Share Posted June 9, 2007 The error you're getting means that you're asking for the row 0 result when there isn't one. $query = "SELECT frame from users WHERE userID = '{$oid}'"; $result= mysql_query($query) or die(mysql_error()); $color = mysql_fetch_row($result); $color = $color[0]; That code will work regardless of which row of data is actually selected. Link to comment https://forums.phpfreaks.com/topic/54821-solved-order-of-operations/#findComment-271298 Share on other sites More sharing options...
TheLostGuru Posted June 9, 2007 Author Share Posted June 9, 2007 Thanks, I changed my code to fit yours. If it "die's" does that mean that $color is still set to anything? Or should I default setting color to 1? Also, when I test this, it sets $color to ""; Why is this? Link to comment https://forums.phpfreaks.com/topic/54821-solved-order-of-operations/#findComment-271364 Share on other sites More sharing options...
chigley Posted June 9, 2007 Share Posted June 9, 2007 If it dies, the script will no longer continue ~ because an error has occurred. It shouldn't be returning nothing, check the query is running ok. Link to comment https://forums.phpfreaks.com/topic/54821-solved-order-of-operations/#findComment-271367 Share on other sites More sharing options...
TheLostGuru Posted June 9, 2007 Author Share Posted June 9, 2007 how do I check that? Do I just check run the query manually through a database? Link to comment https://forums.phpfreaks.com/topic/54821-solved-order-of-operations/#findComment-271371 Share on other sites More sharing options...
TheLostGuru Posted June 9, 2007 Author Share Posted June 9, 2007 Is there a way to check and see what the value of the $oid is? Link to comment https://forums.phpfreaks.com/topic/54821-solved-order-of-operations/#findComment-271374 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.