Jump to content

[SOLVED] Include works on some pages but not others


SirChick

Recommended Posts

This is most strange...

 

I have same include on 2 pages right but it's only working on one of the pages... theres no special code going on in either of them to be honest so I cannot figure out what could be blocking the include on the second instance.

 

This is generally it.. it's alot of code so i'll give shorted example..

 

phpscript1.php

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Cannot view this page!</title>
</head>
<?
include ("mainmenu.php");
?>
<div id="bv_" style="position:absolute;left:325px;top:298px;width:365px;height:44px;z-index:10" align="center">
<font style="font-size:19px" color="#FFFFFF" face="Arial"><u>You cannot view this page until you buy a house! </u></font></div>
<div id="bv_" style="position:absolute;left:443px;top:446px;width:150px;height:24px;z-index:11" align="center">
<font style="font-size:21px" color="#000000" face="Arial"><b><u><a href="homelogin.php">Home</a></u></b></font></div>
</body>
</html>

 

 

Phpscript2.php:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Home Login Page</title>
</head>
<?
include ("mainmenu.php");
?>
<div id="bv_" style="position:absolute;left:76px;top:225px;width:247px;height:79px;z-index:11" align="center">
<img src="menu_gradient.gif" id="Shape2" align="top" alt="" border="0" width="319" height="360"></div>
<div id="bv_" style="position:absolute;left:103px;top:291px;width:263px;height:79px;z-index:12" align="left">
<font style="font-size:13px" color="#000000" face="Arial">Your are living in  <b><?= $CityName ?></b>. If you are new to this game why not click the Help Tutorial Link to the right hand side and get to grips with this game!<br>
</font></div>

 

 

Both contain :

<?

include ("mainmenu.php");

?>

 

Now in this include i have something like this:

 

mainmenu.php:

 

$HouseLock = mysql_query("SELECT * FROM houses WHERE UserID='{$_SESSION['Current_User']}'")
			Or die(mysql_error());
			$lockrow = mysql_fetch_assoc($HouseLock);
	$HouseLock = $lockrow['MessageBoxLocked'];
	$HouseType = $lockrow['HouseType'];

			If ($HouseType == 'Blanket'){

Echo 'Blanket';
}Else{
Echo 'Not Blanket';
}

 

 

The problem i have is phpscript1.php echos Blanket, but Phpscript2.php echos Not Blanket.

 

But how can this be? Same include and its same query being used =/

 

This has big time stumped me!  ???

Link to comment
Share on other sites

echo $_SESSION['Current_User'] in the include and see if the session value is passed, it maybe ppassed on the first page but not on the second, so you may not get the same result when quering your database.

 

If the result is same echo the retrived value from the database...

Link to comment
Share on other sites

session is working fine also.

 

i have narrowed it down to a mysql script (though it is not producing an error), so i didnt think it was that... but when i hashed it out ... the code works, im unsure why it won't work and the fact that it provides no error when i looked at page source... so its still not making great deal of sense to me:

 

$GotMobile = mysql_query("SELECT * FROM useritem WHERE UserID='{$_SESSION['Current_User']}' AND ItemID='2'")
			Or die(mysql_error());
			$result = mysql_query($GotMobile) or die("Problem with the query: $GotMobile<br>" . mysql_error());

			if (mysql_num_rows($result) != 1){
			$SetGotMobile = 0;
			}
			else {
					$SetGotMobile = 1;
				 }

Link to comment
Share on other sites

Are you using any php on page two besides the inlude?

 

If you are maybe you have syntax error that is causing it to work not the way you plan it to!

 

For example if you have if () {  }  this is an include

 

if ()

 

{

 

if () {  }  this is an include

 

}

 

You following? check all your PHP with the include included, check all your if and else that they all match as you need them too!

 

Debugging is not fun!

 

Maybe you have short hand, short tag on the page 2...and it is hard to find where the parathesis do not match..

Link to comment
Share on other sites

$GotMobile = mysql_query("SELECT * FROM useritem WHERE UserID='{$_SESSION['Current_User']}' AND ItemID='2'")
			Or die(mysql_error());
			$result = mysql_query($GotMobile) or die("Problem with the query: $GotMobile<br>" . mysql_error());

			if (mysql_num_rows($result) != 1){
			$SetGotMobile = 0;
			}
			else {
					$SetGotMobile = 1;
				 }

 

This is all there is on the other page... but it does not produce error so i didn't think this would be to blame?

Link to comment
Share on other sites

Try changing this.

 

$GotMobile = mysql_query("SELECT * FROM useritem WHERE UserID='{$_SESSION['Current_User']}' AND ItemID='2'")

 

 

to

 

$user_id=$_SESSION['Current_User'];

 

$GotMobile = mysql_query("SELECT * FROM useritem WHERE UserID='$user_id' AND ItemID='2'")

 

This way it is clean, I do not know all the short hand code, but this is old school and it works.

 

Link to comment
Share on other sites

$GotMobile = mysql_query("SELECT * FROM useritem WHERE UserID='{$_SESSION['Current_User']}' AND ItemID='2'")
			Or die(mysql_error());
			$result = mysql_query($GotMobile) or die("Problem with the query: $GotMobile<br>" . mysql_error());

			if (mysql_num_rows($result) != 1){
			$SetGotMobile = 0;
			}
			else {
					$SetGotMobile = 1;
				 }

 

I'm not positive but you're running a mysql query twice ...

 

$GotMobile = mysql_query("SELECT * FROM useritem WHERE UserID='{$_SESSION['Current_User']}' AND ItemID='2'")

Or die(mysql_error());

$result = mysql_query($GotMobile) or die("Problem with the query: $GotMobile<br>" . mysql_error());

 

$GotMobile is a query already and result is running another query ... try this:

 

$GotMobile = "SELECT * FROM useritem WHERE UserID='{$_SESSION['Current_User']}' AND ItemID='2'";
			$result = mysql_query("$GotMobile") or die("Problem with the query: $GotMobile<br>" . mysql_error());

Link to comment
Share on other sites

Still not working guys ! :(

 

It is 100% this part of the script though, because when i blanked it out using //  it worked..

 

$user_id=$_SESSION['Current_User'];

			$GotMobile = mysql_query("SELECT * FROM useritem WHERE UserID='$user_id' AND ItemID='2'")
			Or die(mysql_error());
			$result = mysql_query($GotMobile) or die("Problem with the query: $GotMobile<br>" . mysql_error());

			if (mysql_num_rows($result) != 1){
			$SetGotMobile = 0;
			}
			else {
					$SetGotMobile = 1;
				 }
			If ($SetGotMobile == '1' && $HouseType != 'Blanket'){
			Echo'Test';
}Else{
Echo 'test2';
}

 

But now an error is producing at last:

 

Problem with the query: Resource id #21<br>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #21' at line 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.