NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Javascript + Php - error message


Joined: 23 Nov 2006
Posts: 48
Location: Netherlands
Reply with quote
when combining javascript with php

like

PromotionLimit = <?=$PromotionLimit?>;

it gives a warning on the code "unexpected ;"

if ( count + <?=$lNumberOfMessages?> > PromotionLimit && PromotionLimit < 0 )

it give a warning "unexpected >";

can this be resolved?

_________________
MV
View user's profileFind all posts by MacVatoSend private messageVisit poster's website
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
Are you sure it actually parses the PHP? Take a look in the source code. If "short tags" is off then those blocks are left alone.
View user's profileFind all posts by BlizzSend private messageVisit poster's website


Joined: 23 Nov 2006
Posts: 48
Location: Netherlands
Reply with quote
sorry should have mentioned these errors are generated within the editor and not when running the script

the script itself works lik a charm, just getting these errors (within the IDE) when editing the file

_________________
MV
View user's profileFind all posts by MacVatoSend private messageVisit poster's website


Joined: 18 Sep 2007
Posts: 54
Location: Croatia
Reply with quote
Since there is now 'Problems' tab in PhpEd this JavaScript error log problem is even bigger.
Here is piece of code:
Code:

changeReminder(<?php echo (int)$session->page_permission ?>, '<?php echo $session->lang_array['save_reminder_message'] ?>', true);

There shouldn't be any problems at all, but IDE is returning error on every comma and ;
Since my pages are full of JavaScripts, I'm getting a lot of errors and I can't concentrate on real one.

Please do something about it, or at least tell me how to disable this function for JS in IDE as it is consuming resources but not working well.
View user's profileFind all posts by konixnetSend private messageVisit poster's website


Joined: 10 Oct 2009
Posts: 1
Reply with quote
Loading Errors:
These are the equivalent of compile errors in languages such as C++ and Java. Since JavaScript code is an interpreted language, even the most prominent errors won't be caught until the script is loaded in a browser. This type of error, which has the grave effect of halting script execution immediately, can usually be spotted by an error message that refers to some kind of incorrect syntax, such as a missing brace or function parentheses.

Runtime Errors:
The second type of error occurs when the JavaScript interpreter comes across some code that it can't understand. Again, syntax errors, such as misspelled variable names, may be the culprit. Illegal assignments, such as to the this pointer, will also cause a runtime error.

Logic Errors:
Errors in processing logic, which can result from misunderstanding the requirements to not drinking enough coffee, are what lead to what developers affectionately refer to as "bugs". A bug can manifest itself as a JavaScript error in any number of ways. Suppose that you wrote a process that expects JSON-formatted data to be returned from the server. Unbeknownst to you, the owner of that application transfers data in XML format. You had better have some thorough error handling in place, or be ready for some strange behavior!
View user's profileFind all posts by thotkataSend private message


Joined: 30 Oct 2009
Posts: 1
Reply with quote
As far as I see the problem has not been solved. But I wanted to update PhpED to 5,9. But now I see, that I have to stay working in 5,6...
View user's profileFind all posts by maxsharovSend private message


Joined: 18 Sep 2007
Posts: 54
Location: Croatia
Reply with quote
Yep, problem still exists in 5919.
It shows it's ugly head both in file and in Problems window.

Annoying little bugger.
View user's profileFind all posts by konixnetSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
Quote:
Yep, problem still exists in 5919.
It shows it's ugly head both in file and in Problems window


This is not a bug at all. It works as intended.
IDE can't capture any valid js code from your script without executing it, but execution is not what you want, I guess.
Without executing php, your code looks like
PromotionLimit = ;
if ( count + > PromotionLimit && PromotionLimit < 0 )


I can think of two possible solutions:
1) Stop usisng code mixture. Either JS or PHP. Don't use them together. It would improve everything, including code maintainability, and performance. With php code in, your js files can not be cached at the client side, so they will be re-requested for all pages referring to the script.

2) Do not share any single statement between the languages. Either all the statement in php or in js.
For example you can write
<? echo "PromotionLimit = $PromotionLimit" ?>;
instead of
PromotionLimit = <?=$PromotionLimit?>;

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 18 Sep 2007
Posts: 54
Location: Croatia
Reply with quote
So, if it's not bug, than it's a feature. Just kidding Smile
Anyway thnx for explaining all this Dimitri, it is a valuable insight how things should be setup in PhpEd.

I liked this last option as it will not violate code and maintain dynamic setup of JS vars, what was main point from the start.
But I still think that this will continue to be somewhat problem, as many times these days, JS is getting all variables directly from php.
View user's profileFind all posts by konixnetSend private messageVisit poster's website


Joined: 18 Sep 2007
Posts: 54
Location: Croatia
Reply with quote
OK, so I've managed to clear JS errors, but what about CSS errors?

Do I have to live with errors in:
Code:

filter:progid:DXImageTransform.Microsoft.Shadow(color='CCCCCC', Direction=135, Strength=2);

and
Code:

filter:alpha(opacity=10);


or can I fix these as well?
View user's profileFind all posts by konixnetSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
Regarding CSS PhpED v5.x supports CSS 2.1 standard syntax only.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Veteran

Joined: 06 Jun 2007
Posts: 289
Location: Vancouver, Canada
Reply with quote
dmitri wrote:
1) Stop usisng code mixture. Either JS or PHP. Don't use them together. It would improve everything, including code maintainability, and performance. With php code in, your js files can not be cached at the client side, so they will be re-requested for all pages referring to the script.

There are cases where I want adjust the JS to a particular situation, and mixing in PHP code is very convenient. I understand that this is a complex issue Dmitri, but I am "sure" you can find a way around this, e.g. ignore <?php ?> tags when evaluating JS.

dmitri wrote:
2) Do not share any single statement between the languages. Either all the statement in php or in js.
For example you can write
<? echo "PromotionLimit = $PromotionLimit" ?>;
instead of
PromotionLimit = <?=$PromotionLimit?>;

Thank you, this seems a workable solution for now. I still have a strong preference to continue doing it the way MacVato has it in the first post.

_________________
Smile
View user's profileFind all posts by annoSend private messageVisit poster's website
Javascript + Php - error message
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic