Jump to content

unexpected T_CONSTANT_ENCAPSED_STRING


MCrosbie

Recommended Posts

Hello,

 

I am getting this error:

"Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /*/*/public_html/client/ecom.php(119) : eval()'d code on line 491"

 

This is the code:

$echo .= '
<script language="javascript" type="text/javascript">
   counter=1;
   max_per_upload=5;
   checker="";
   function addPhoto() {
      img=eval("document.photoaddform.photofile"+counter+".value");
      img=img.replace(\'&\',\'&\').replace(\'<\',\'<\').replace(\'>\',\'>\');
      checkString=img+","
      if (checker.indexOf(checkString)>-1) {
         alert("The photo "+img+" was already selected. Please select a different photo.");
      } else {
         document.getElementById("upload").style.visibility = "visible";
         document.getElementById("cumulativeDiv").style.visibility = "visible";
         thisChooser=eval("document.photoaddform.photofile"+counter);
         thisChooser.style.position="absolute";
         thisChooser.style.top=-1000;
         if (counter<max_per_upload) {
            nextChooser = eval("document.photoaddform.photofile"+(counter+1));
            nextChooser.style.position="relative";
            nextChooser.style.top=0;
            document.getElementById("prompt").innerHTML="Add photo "+(counter+1)+"):";
         } else {
            document.getElementById("prompt").innerHTML="";
         }
         checker+=img+",";
         
         var imgsrc = "file:///" + img.replace(/\\/g, "/");
         moreHTML="<table width=\'100%\' border=0 cellspacing=0 cellpadding=0><tr bgcolor=#efefef>"+
            "<td width=\'10px\'>"+counter+") </td>"+
            "<td><img style=\'display: none;\' id=\'img_"+counter+"\' src=\'"+imgsrc+"\' width=60 vspace=2></td>"+
            "<td>"+img+"</td>"+
            "</tr>"+
            "<tr><td><img src=http://s.bebo.com/img/vid.gif width=1 height=1></td></tr>"+
            "</table>"
         var currentHTML=document.getElementById("cumulativeDiv").innerHTML; 
         document.getElementById("cumulativeDiv").innerHTML=currentHTML+moreHTML;
         if (navigator.appVersion.indexOf("MSIE")!=-1) {
            var thisImage="img_"+counter;
            img=img.replace(/\\/g,"|");
            var testImage=new Image();
            testImage.src=img;
            if (testImage.height>0) {
               document.getElementById(thisImage).src=img;
            }
            setImage(thisImage,img)
         }
         counter+=1;
      }
   }
   
   setCountTries=0
   function setImage(id,path) {
      path=path.replace(/\|/g,"\\");
      var testImage=new Image();
      testImage.src=document.getElementById(id).src
      if (testImage.height<1 && setCountTries<10) {
         document.getElementById(id).src=path ;
         setCountTries+=1;
491           path=path.replace(/\\/g,"|");
         setTimeout("setImage(\'"+id+"\',\'"+path+"\')",500);
      } else {
    document.getElementById(id).src=path;
      }
   }
</script>';

 

Any ideas how to fix this? I've already tried to double up the backslashes, as in "path=path.replace(/\\\\/g,"|");".

 

If you could help that would be great,

 

Cheers,

 

Michael Crosbie

Link to comment
https://forums.phpfreaks.com/topic/42940-unexpected-t_constant_encapsed_string/
Share on other sites

If you are grabbing it from a mysql database, what is the error?

 

If you want to put it into a mysql database without the hassle I would do this

 


<?php
ob_start();
?>
<!-- javascript code here without any escapes -->

<?php
$echo .= mysql_real_escape_string(ob_get_contents());
ob_end_clean();

?>

 

Which will automatically escape any issues mysql might have with that string. If I am missing the point of this, I will just stop now.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.