MCrosbie Posted March 16, 2007 Share Posted March 16, 2007 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 Quote Link to comment Share on other sites More sharing options...
per1os Posted March 16, 2007 Share Posted March 16, 2007 You could always do this instead <?php ob_start(); ?> <!-- javascript code here without any escapes --> <?php $echo .= ob_get_contents(); ob_end_clean(); ?> See if that works. Quote Link to comment Share on other sites More sharing options...
MCrosbie Posted March 16, 2007 Author Share Posted March 16, 2007 Actually I can't. The page is actually grabbing this php code from a mysql db and evaluating the code. Thanks for your suggestion, but I dont think it would work. Cheers! Quote Link to comment Share on other sites More sharing options...
btherl Posted March 16, 2007 Share Posted March 16, 2007 The code you posted gives no parse errors here, php 4.3.10 Quote Link to comment Share on other sites More sharing options...
per1os Posted March 16, 2007 Share Posted March 16, 2007 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. Quote Link to comment Share on other sites More sharing options...
btherl Posted March 16, 2007 Share Posted March 16, 2007 Hmm.. are you trying to eval() javascript code in php? 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.