Forum Moderators: open
Then in my PHP file I output everything with JavaScript. An example is something of this nature.
Header("content-type: application/x-javascript");
if("some condition here"){\
$message = "True";
echo("alert('$message')");
}
else{
$message = "False";
echo("alert('$message')");
}
Now that will display a JavaScript alert box with the statement. It works just fine until I put my variable in a for loop. i.e.
//returns an array with each file that you specify
//ending with a .txt extension
$var = glob("c:\folder\*.txt");
foreach ($var as $i){
$message .= "{$i}\\n";
}//foreach
echo("alert('$message')");
if I do that I get a JavaScript error saying it is an unterminated string literal. However if I manually do it, it works fine. i.e.
$msg .="test\\n";
$msg .="test2\\n";
echo("alert('$msg')");
Any suggestions? Thanks,
One more thing. You should be getting JUST the PHP script working at this time. Forget the asynchronous call to this script unless it is working just fine :)
//open the file just pretend $fname is a valid path for a file
$file = fopen($fname, 'a');
//store the file into an array
$lines = file($fname);
foreach($lines as $i){
fwrite($file, "{$i}");
$msg .= "{$i}";
}//foreach
now if I var_dump($msg) here is my exact output.
"$LANG = "VBScript"
' VBS script learned for "ANSI - MS BCBS.HAW" on 03/09/06 at 08:50:23.
cr = Chr(13)
haAbortOnError
haWaitForPrompt "gon Id: "
haTypeText "S2176"&cr
haWaitForPrompt "ssword: "
haTypeText "ECLAIM"&cr
haWaitForPrompt cr&Chr(10)&cr&"cmd> "
haTypeText "$$ADD ID=S2176FFW BID='PANSI837P'"&cr
haSetXferProtocol 1, 8
haXferAddToSendList "\\sybase01\insurance$\MSBCBS\MSBCBS_20080701_170203_.edi"
haWaitForPrompt "7fed4"&cr&Chr(10)&Chr(17)
haXferSendFromList
haWaitForPrompt cr&Chr(10)&cr&"cmd> "
haTypeText "$$ADD ID=S2176FUZ BID='PANSI837P'"&cr
haSetXferProtocol 1, 8
haXferAddToSendList "\\sybase01\insurance$\MSBCBS\MSBCBS_20080701_170203_1.edi"
haWaitForPrompt "7fed4"&cr&Chr(10)&Chr(17)
haXferSendFromList
haWaitForPrompt cr&Chr(10)&cr&"cmd> "
haTypeText "$$ADD ID=S2176DQR BID='PANSI837P'"&cr
haSetXferProtocol 1, 8
haXferAddToSendList "\\sybase01\insurance$\MSBCBS\MSBCBS_20080701_195038_.edi"
haWaitForPrompt "7fed4"&cr&Chr(10)&Chr(17)
haXferSendFromList
haWaitForPrompt cr&Chr(10)&cr&"cmd> "
haTypeText "$$LOGOFF"&cr
haTerminate"
could my string problem be because the text file has " in it. And if so any ideas on how to fix it. I would need to escape the " but I need to escape them for the JavaScript output, not for the PHP. Thanks,