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 Link to comment https://forums.phpfreaks.com/topic/42940-unexpected-t_constant_encapsed_string/ 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. Link to comment https://forums.phpfreaks.com/topic/42940-unexpected-t_constant_encapsed_string/#findComment-208569 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! Link to comment https://forums.phpfreaks.com/topic/42940-unexpected-t_constant_encapsed_string/#findComment-208570 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 Link to comment https://forums.phpfreaks.com/topic/42940-unexpected-t_constant_encapsed_string/#findComment-208582 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. Link to comment https://forums.phpfreaks.com/topic/42940-unexpected-t_constant_encapsed_string/#findComment-208583 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? Link to comment https://forums.phpfreaks.com/topic/42940-unexpected-t_constant_encapsed_string/#findComment-208586 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.