...

View Full Version : Can "//" be used inside a heredoc to comment out javascript?



milesdriven
10-13-2012, 05:51 PM
I use a heredoc to send javascript to the browser. I've been using 2 forward slashes inside the heredoc to comment out lines of javascript. It looked like it was working well for a while. The scripts seemed to work fine.

I'm getting the javascript error "invalid regular expression flag v".

I just learned a forward slash is the js regex delimiter. Are the 2 forward slashes I'm using (several sets of 2 forward slashes) in the heredoc causing the problem?

I used 2 forward slashes to comment out a line of css (in style tags) in a heredoc. I got the firebug error "expecting declaration, but found "/" instead - moving on to next declaration".

I removed the 2 forward slashes and that error disappeared.

I still have the "invalid regular expression flag v" error, and the javascript doesn't work. Any suggestions?

Thank you.

sunfighter
10-13-2012, 06:08 PM
Any suggestions?Yeah if your having problems stop writing javascript in a php file. Write it directly to the html file or make a file to be included in the html. The include can be written in heredoc. Have you tried the nowdoc to see if there is a difference?

milesdriven
10-13-2012, 06:23 PM
The javascript has to be sent to the users browser after login, so php has to send it - unless there is another way of sending the js after login that I'm not aware of.


make a file to be included in the html. The include can be written in heredoc.
I'm not sure what you're saying. Does html have its own include function?


Putting javascript in a php heredoc has been working well. I'm trying to figure out why the sudden "flag v" error. If there is a better way to send javascript to the browser after php login, I welcome all suggestions.

The first thing I need to do is resolve the invalid regex flag v error.

milesdriven
10-13-2012, 06:31 PM
Hi - and thanks for your reply. I noticed were talking over each other on this thread. For now, the best thing for me to do is diagnose the flag error. As soon as I figure out what is causing that I'll be in a better position to determine what the best thing to do is. I study the nowdoc then too.

Thank you

Inigoesdr
10-14-2012, 06:07 PM
For now, the best thing for me to do is diagnose the flag error. As soon as I figure out what is causing that I'll be in a better position to determine what the best thing to do is.

Post the code that causes the error so we can help you figure it out. Just posting to let everyone know you are working on something isn't going to get you anywhere here. ;)

milesdriven
10-15-2012, 07:04 PM
Post the code that causes the error so we can help you figure it out. Just posting to let everyone know you are working on something isn't going to get you anywhere here. ;)
Yes, you're right.

I isolated the area that was crashing. I tried to post, but it exceeded the 20k character limit. I eventually found the two lines that were causing the errors. Problem solved.

Just in case it helps someone, here are those two lines. I removed the red dot in line 1. For line 2, the word highlighted in red in the first part of the line did not exist in the php array inside the push method. I added it as shown. These small items were enough to crash a huge script.



1) echo "id8AM_cc_exp_month. ="." [1];";

2) for($st = 1; $st <= $days_in_month; $st++)
{
echo "id8AM_Click_To_Reset_Inserted_Into_Database.push($id8AM_Click_To_Reset_Inserted_Into_Database[$st]);\n";
}


Even though my script was too big to post, I appreciate everyone trying to help.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum