SirChick Posted October 19, 2007 Share Posted October 19, 2007 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! ??? Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/ Share on other sites More sharing options...
simcoweb Posted October 20, 2007 Share Posted October 20, 2007 It may be that your code is failing elsewhere. Possibly this part in the phpscript2.php file: <?= $CityName ?> Try this instead: <?php echo $CityName; ?> Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/#findComment-373592 Share on other sites More sharing options...
SirChick Posted October 20, 2007 Author Share Posted October 20, 2007 <?= $CityName ?> Does work as i have short tags on though =/ Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/#findComment-373594 Share on other sites More sharing options...
igor berger Posted October 20, 2007 Share Posted October 20, 2007 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... Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/#findComment-373595 Share on other sites More sharing options...
SirChick Posted October 20, 2007 Author Share Posted October 20, 2007 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; } Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/#findComment-373597 Share on other sites More sharing options...
igor berger Posted October 20, 2007 Share Posted October 20, 2007 Did you echo $HouseLock and $HouseType do you get $HouseType equal Blanket when you do the echo? Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/#findComment-373600 Share on other sites More sharing options...
SirChick Posted October 20, 2007 Author Share Posted October 20, 2007 Did you echo $HouseLock and $HouseType do you get $HouseType equal Blanket when you do the echo? I did yes. Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/#findComment-373607 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 1. Don't use shorthand. 2. Don't use short-tags. 3. Use require_once('whatever') instead of include. Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/#findComment-373613 Share on other sites More sharing options...
igor berger Posted October 20, 2007 Share Posted October 20, 2007 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.. Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/#findComment-373617 Share on other sites More sharing options...
SirChick Posted October 20, 2007 Author Share Posted October 20, 2007 $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? Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/#findComment-373636 Share on other sites More sharing options...
igor berger Posted October 20, 2007 Share Posted October 20, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/#findComment-373652 Share on other sites More sharing options...
SirChick Posted October 20, 2007 Author Share Posted October 20, 2007 No change Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/#findComment-373657 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 Repost all relevant code. Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/#findComment-373660 Share on other sites More sharing options...
ryeman98 Posted October 20, 2007 Share Posted October 20, 2007 $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()); Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/#findComment-373662 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 Ah good catch. You can't double run it like that. Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/#findComment-373663 Share on other sites More sharing options...
ryeman98 Posted October 20, 2007 Share Posted October 20, 2007 Ah good catch. You can't double run it like that. FINALLY! lol I thought you would have caught that and I was just taking another useless guess Glad I could help. Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/#findComment-373667 Share on other sites More sharing options...
igor berger Posted October 20, 2007 Share Posted October 20, 2007 ryeman98 thanx for the assisst. Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/#findComment-373675 Share on other sites More sharing options...
SirChick Posted October 20, 2007 Author Share Posted October 20, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/#findComment-373913 Share on other sites More sharing options...
BlueSkyIS Posted October 20, 2007 Share Posted October 20, 2007 because you're running mysql_query() on the result of a previous mysql_query(). Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/#findComment-373920 Share on other sites More sharing options...
SirChick Posted October 20, 2007 Author Share Posted October 20, 2007 oh i see it now ... missed out a post in here.. thanks guys. Quote Link to comment https://forums.phpfreaks.com/topic/74013-solved-include-works-on-some-pages-but-not-others/#findComment-373925 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.