Jump to content

<script> Tag Problem


bluesapphire

Recommended Posts

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 regard

Thanks in advance


Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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)
Link to comment
Share on other sites

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>&nbsp;</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>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<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%">&nbsp;</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%">&nbsp;</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>&nbsp;</td>
<td><div align="center" class="mytext"><?php echo $res['id'];?></div>&nbsp;</td>
<td align="center">
<?php echo $res["description"];?>&nbsp;</td>
<td><div align="center">&nbsp;<a href="addproduct.php?mid=<?php echo $res['id'];?>&act=E&mcat=<? echo $mcat;?>" class='adm'>Edit</a>&nbsp;&nbsp;&nbsp;<?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>&nbsp;</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>&nbsp;</td>
</tr>
</table>
</form>
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.