Jump to content

[SOLVED] Order of Operations


TheLostGuru

Recommended Posts

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

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?

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. 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.