chanfuterboy Posted August 20, 2009 Share Posted August 20, 2009 hi, as i wrote the script is working fine in a stand alone page, as i included (..) to a page that use a Iframe, the page does not picup. If i remove the if...else statement it work fine in iframe. What can be the problem? <?php include('dbconfig.php'); $rs = mysql_query("select * from chat where recv_ip='' and to_id='$_SESSION[userid]'"); $newpm = mysql_num_rows($rs); $rt = mysql_query("select * from invites where resv_ip='' and frndid='$_SESSION[userid]'"); $newfr = mysql_num_rows($rt); ?> <?php if(!$_SESSION['userid']) { echo '<html> <head> <link rel="stylesheet" type="text/css" href="styles/ministyle.css"/> <script type="text/javascript" src="./scripts/tabcontainer.js"></script> <script type="text/javascript" src="./scripts/inc_lib.js"></script> <script type="text/javascript" src="./scripts/scripts.js"></script> <?php echo $base; ?>'; }else { echo '<html> <head> <link rel="stylesheet" type="text/css" href="styles/ministyle.css"/> <script type="text/javascript" src="./scripts/tabcontainer.js"></script> <script type="text/javascript" src="./scripts/inc_lib.js"></script> <script type="text/javascript" src="./scripts/scripts.js"></script> <?php echo $base; ?>'; echo'</head><body><p align="right"> <img src="http://www.awortinkos.com/realgame/styles/pm.png"><b> <font color="#FFFFFF">PM '. $newpm .'</font></b> <img src="http://www.awortinkos.com/realgame/styles/invite.png"> <b> <font color="#FFFFFF" face="Verdana" size="2">friends '. $newfr .'</font></b></p>'; } ?> Link to comment https://forums.phpfreaks.com/topic/171221-solved-echo-in-iframe/ Share on other sites More sharing options...
corbin Posted August 20, 2009 Share Posted August 20, 2009 $_SESSION[userid] should be $_SESSION['userid'] unless userid is a constant. (Might need to wrap it in {}.) Anyway, you're entering and exiting PHP twice is why it isn't working. It's literally echoing "<?php echo $base; ?>". Link to comment https://forums.phpfreaks.com/topic/171221-solved-echo-in-iframe/#findComment-902918 Share on other sites More sharing options...
chanfuterboy Posted August 20, 2009 Author Share Posted August 20, 2009 hi, there is another way to write it, without i dont write it twise? pls help Link to comment https://forums.phpfreaks.com/topic/171221-solved-echo-in-iframe/#findComment-902923 Share on other sites More sharing options...
corbin Posted August 20, 2009 Share Posted August 20, 2009 Just doing it once because I'm lazy: echo <html> <head> <link rel="stylesheet" type="text/css" href="styles/ministyle.css"/> <script type="text/javascript" src="./scripts/tabcontainer.js"></script> <script type="text/javascript" src="./scripts/inc_lib.js"></script> <script type="text/javascript" src="./scripts/scripts.js"></script> <?php echo $base; ?>'; Should be: echo '<html> <head> <link rel="stylesheet" type="text/css" href="styles/ministyle.css"/> <script type="text/javascript" src="./scripts/tabcontainer.js"></script> <script type="text/javascript" src="./scripts/inc_lib.js"></script> <script type="text/javascript" src="./scripts/scripts.js"></script> <?php echo $base; ?>'; Then it should be: echo '<html> <head> <link rel="stylesheet" type="text/css" href="styles/ministyle.css"/> <script type="text/javascript" src="./scripts/tabcontainer.js"></script> <script type="text/javascript" src="./scripts/inc_lib.js"></script> <script type="text/javascript" src="./scripts/scripts.js"></script>'. $base; By the way, when you only want the number of rows and not the actual content, instead of doing: $q = mysql_query("SELECT * FROM..."); $num_rows = mysql_num_rows($q); You should do: $q = mysql_query("SELECT COUNT(some_column) FROM ....") $num_rows = mysql_result($q, 0); Then again, you could be using the actual content in $base. Link to comment https://forums.phpfreaks.com/topic/171221-solved-echo-in-iframe/#findComment-902926 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.