Jump to content


Photo

<script> Tag Problem


  • Please log in to reply
9 replies to this topic

#1 bluesapphire

bluesapphire
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 20 April 2006 - 01:47 PM

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.tradedoubl...=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




#2 predator12341

predator12341
  • Members
  • PipPipPip
  • Advanced Member
  • 87 posts
  • LocationCheshunt, Hertfordshire, England

Posted 20 April 2006 - 01:52 PM

so you have done you code like so
<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>

but what is your exact problem sorry i did not understand fully

[a href="http://www.sloganizer.net/en/" target="_blank"][/a]

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 20 April 2006 - 01:53 PM

Do you have
<?php
session_start();
?>
at the start of your script?

Ken

#4 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 20 April 2006 - 01:53 PM

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
wisewood: proven fact, I am both wise, and wooden.

#5 predator12341

predator12341
  • Members
  • PipPipPip
  • Advanced Member
  • 87 posts
  • LocationCheshunt, Hertfordshire, England

Posted 20 April 2006 - 01:55 PM

ignore this i just understood your post
[a href="http://www.sloganizer.net/en/" target="_blank"][/a]

#6 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 20 April 2006 - 01:58 PM

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

#7 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 20 April 2006 - 02:03 PM

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)
wisewood: proven fact, I am both wise, and wooden.

#8 bluesapphire

bluesapphire
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 20 April 2006 - 02:21 PM

Hi there !
The session is already started. I have used "<?=" instead of "<?php echo " . But of no use .The result is same as before.

#9 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 20 April 2006 - 02:27 PM

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

#10 bluesapphire

bluesapphire
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 20 April 2006 - 02:35 PM

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>




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users