bluesapphire Posted April 20, 2006 Share Posted April 20, 2006 Hi there! I am facing problem that if I display/use/echo CODE #1 in a php file then it doesn,t convert the $_SESSION variables into its values and it displays as it is in the link/url.But in CODE # 2 , the $_SESSION variables are replaced with values.CODE # 1 <script language="JavaScript" src="http://pf.tradedoubler.com/pf/pf2?a=913664&cuid=88215&tid=4997&epi=<?php echo $_SESSION[UID].'-'.$_SESSION[USERNAME];?>&oe=ISO-8859-1&js=true" charset="ISO-8859-1" charset="ISO-8859-1"></script>CODE # 2 [a href=\"http://pf.tradedoubler.com/pf/pf2?a=913664&cuid=88215&tid=4997&epi=<?php\" target=\"_blank\"]http://pf.tradedoubler.com/pf/pf2?a=913664...97&epi=<?php[/a] echo $_SESSION[UID].'-'.$_SESSION[USERNAME];?>&oe=ISO-8859-1&js=true" charset="ISO-8859-1 Can any one have a solution in this regardThanks in advance Quote Link to comment Share on other sites More sharing options...
predator12341 Posted April 20, 2006 Share Posted April 20, 2006 so you have done you code like so[code]<script language="JavaScript" src="http://pf.tradedoubler.com/pf/pf2?a=913664&cuid=88215&tid=4997&epi=<?php echo $_SESSION[UID].'-'.$_SESSION[USERNAME];?>&oe=ISO-8859-1&js=true"></script>[/code]but what is your exact problem sorry i did not understand fully Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 20, 2006 Share Posted April 20, 2006 Do you have[code]<?phpsession_start();?>[/code]at the start of your script?Ken Quote Link to comment Share on other sites More sharing options...
wisewood Posted April 20, 2006 Share Posted April 20, 2006 This will put <?=$variable?> on the screen.echo "<?=$variable?>";This will put the value of $variable on the screen.echo "$variable";if you're not within <?php and ?> you should use <?=$variable?> to echo a php variable, but if you are within <?php and ?> then you should use echo "$variable";Hope this helps Quote Link to comment Share on other sites More sharing options...
predator12341 Posted April 20, 2006 Share Posted April 20, 2006 ignore this i just understood your post Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 20, 2006 Share Posted April 20, 2006 The "<?=" construct is equivalent to "<? echo" and "<?php echo" and will only work if short tags are turned on. I have heard the short tags are going away in PHP version 6, so if you use them now, start getting used to using "<?php " instead.On a side note, the first time I saw "<?=", I had no idea what it meant and I had to do a lot of digging before I found out (this forum didn't exist then). I would say to new users -- "learn the proper way instead of the shortcut way".Ken Quote Link to comment Share on other sites More sharing options...
wisewood Posted April 20, 2006 Share Posted April 20, 2006 i've heard the short version (<?) will be going in the next major release too. Funny though, until now i never realised this would impact on my use of <?=... though when you think about it, its obvious lol.Thanks ken. (my hero) Quote Link to comment Share on other sites More sharing options...
bluesapphire Posted April 20, 2006 Author Share Posted April 20, 2006 Hi there ! The session is already started. I have used "<?=" instead of "<?php echo " . But of no use .The result is same as before. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 20, 2006 Share Posted April 20, 2006 Can you post some more of the script that doesn't work. There may be something in the lines prior to this line that is causing the problem.Ken Quote Link to comment Share on other sites More sharing options...
bluesapphire Posted April 20, 2006 Author Share Posted April 20, 2006 Hi ! Following is my complete code file .Sessions are starting in other file, which is not shown here.Actually is include file and is being used in many other files. CODE : <form name="frm" method="post" enctype="multipart/form-data" onSubmit="return chek('submit/product.php');"><? if($_POST['mcat']) { $chk = "where mcat = '$_POST[mcat]'"; } else { $chk = "where 1"; } $rcount = mysql_num_rows(mysql_query("select * from product $chk"));?><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> </td> </tr> <tr> <td><table width="95%" border="1" bordercolor="#000000" cellspacing="0" cellpadding="0" align="center" bgcolor="<? echo ADMIN_MAIN_BG;?>"> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="0" align="center"> <tr bgcolor="<? echo MAIN_HEADER_BG;?>"> <td valign="top"><? if($_GET['msg'] == 'E') { echo"<div align=center class=myalert>Record Has Been Updated Successfully.</div>"; unset($_GET['msg']); } if($_GET['msg'] == 'D') { echo"<div align=center class=myalert>Record Has Been Deleted Successfully.</div>"; unset($_GET['msg']); } ?></td> </tr> <tr> <td valign="top"><table width="100%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="<? echo ADMIN_TABLE_BORDER_COLOR;?>"> <tr> <td colspan="4"><div align="center" class="myhtext">VIEW PRODUCT DETAILS</div></td> </tr> <tr> <td colspan="4" align="right"> <? $csql = "select * from productcategory order by title"; $cqry = mysql_query($csql); ?> <select name="mcat" onChange="myfunc('frm','product.php');" class="myinput"> <? echo "<option value=''>-All-</option>"; while ($cres = mysql_fetch_array($cqry)) { if(($cres['id'] == $mcat) || ($cres['id'] == $_GET['mcat'])) { echo "<option value=$cres[id] selected>$cres[title]</option>"; } else { echo "<option value=$cres[id]>$cres[title]</option>"; } } ?> </select> <a href="addproduct.php" class="adm">Add New Product</a></td> </tr> <? if($rcount>0) { ?> <!-- <tr> <td colspan="4"> <? //include "../main/page.php"; ?> </td> </tr> --> <tr> <td width="3%"> </td> <td width="3%"><div align="center" class="mytext">ID</div></td> <td width="73%"><div align="center" class="mytext">DETAIL</div></td> <td width="21%"> </td> </tr> <?php if($_POST['mcat']) { $chk = "where mcat = '$_POST[mcat]'"; } else { $chk = "where 1"; } $sql= "select * from product $chk order by id "; $cnx = mysql_query($sql); while($res = mysql_fetch_array($cnx)) { ?> <tr> <td><div align="left" class="mytext"><input type="checkbox" name="chkdel[]" value="<? echo $res['id'];?>"></div> </td> <td><div align="center" class="mytext"><?php echo $res['id'];?></div> </td> <td align="center"> <?php echo $res["description"];?> </td> <td><div align="center"> <a href="addproduct.php?mid=<?php echo $res['id'];?>&act=E&mcat=<? echo $mcat;?>" class='adm'>Edit</a> <?php if ($res['enable']){echo"<a href='submit/product.php?mid=$res[id]&act=EN&flag=E&mcat=$mcat' class='kf'>Enabled</a>";}else{echo "<a href='submit/product.php?mid=$res[id]&act=EN&flag=D&mcat=$mcat' class='mysalert'>Disabled</a>";}?></div> </td> </tr> <?php } ?> <tr> <td colspan="4"><div align="center"><input type="submit" name="delsubmit" value="Delete" class="btn"> </div></td> </tr> <?php } else { echo"<tr><td colspan='4'><div align='center' class='myalert'>No Record Available</div></td></tr>"; } ?> <input type="hidden" name="act" value="D"></table></td> </tr> </table></td> </tr> </table></td></tr> <tr> <td> </td> </tr></table> </form> Quote Link to comment 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.