php error on joomla site - php

We have two instances running of a joomla hosted site. One is on test server while the other one is on live server.
We are getting one issue where on the test server, site is displaying correctly but not on live server.
We zeroed on one particular line in the page source view, here is the difference of one function from both test as well as live server
test server
<script language="javascript">
$(document).ready(
function (){
$(".pikame403").PikaChoose();
});
</script>
live server
<script language="javascript">
$(document).ready(
function (){
$(".pikame<?=$list['id']?>").PikaChoose();
});
</script>
to me it looks like on the live server, php is not concatinating the id. Any hints/suggestions are welcome. Also it would be nice if someone could indicate where the addins are store their code.

Not all servers allow to use short tags <?= for echoing. On your test server short tags switched on, on production -- switched off, so they don't work.
You can solve your problem in 2 ways:
Switch on short tags on production server.
Do not use short tags (which I strongly recommend). Just change your code <?=$list['id']?> to <?php echo $list['id']; ?>.

Related

want to stop load the script for IE in a particular page by code

I created a website in that every page is working fine in every browser but ONLY one page(form Page) in IE is taking too much time for loading and the error I get is that IE is running a long script and is not responding.
I found a solution for this that in IE under the tool section I have to disable the script option and it works also but its not possible to tell every user to follow this solution, so I wanted to know is there any script or code with the help of which I can disable the script ONLY For this FORM PAGE in IE only for every user dynamically(I created a separate template for this form)
Thanks in advance.......
How about following..
<script>
if( /* Browser checks */ )
document.write( '<script src="scripts.js"></script>' );
</script>
If all your scripts are in one place, or at least not embedded all over the page, perhaps you should include them with JavaScript after checking the browser:
This is one scenario which illustrates why keeping your code http://en.wikipedia.org/wiki/Don%27t_repeat_yourself and all in one place is important.
For detecting browsers, check out http://www.quirksmode.org/js/detect.html, but note the link to their Object detection page instead if that's more useful for your use case. http://yepnopejs.com/ is useful for the latter, which is part of Modernizr.
Credits: Disabling JS from within Website for specific browsers
Hope it helps.
Try
http://www.quirksmode.org/js/detect.html
or
alert(navigator.appName);
Use IE conditional comments:
<![if !IE]>
<script>
// your non IE script here.
</script>
<![endif]>
For more info see: http://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx
Additional explanation:
A note on how conditional comments work.
Conditional comments is an IE specific feature to expose or hide portions of content (not necessarily script) depending on IE versions or if the browser is non IE. For example:
<![if !IE]>
Hello non IE
<![endif]>
Will print Hello non IE on non IE browsers and nothing at all on IE. It is only an IF statement. It is not a magic way to erase content. For example:
Hello non IE
<![if !IE]>
Hello non IE
<![endif]>
will print:
Hello non IE
on IE and:
Hello non IE
Hello non IE
on non IE browsers. It does not delete the previous text. It merely hides the text inside it from IE.
As such, to exclude a script form IE you need to do this:
<![if !IE]>
<script src="non_ie_compatible_script.js">
<![endif]>
NOT this:
<script src="non_ie_compatible_script.js">
<![if !IE]>
<script src="non_ie_compatible_script.js">
<![endif]>
If you have no access to the original line that includes the script then there is nothing you can do.
If you have access to the script then you can use the other solutions posted on this page. But as you mentioned in your OP you don't have access to the script either so none of the solutions here will work. In fact, unless you have access to the server itself or some proxy that sits in front of the server (in which case you can intercept the entire page and delete the script inclusion tag before it's delivered to the browser) there is no solution to your problem.
Your best bet may in fact not be a coding solution but a human solution: talk to the owner/maintainer of the script or the owner/maintainer of your website and ask them to provide you with a way to turn off the script on specific pages.
Or do what #karthick suggests and debug your code instead of trying to disable the third party script.

Javascript in CakePHP

I had one page in Views in CakePHP, it have normal javascript block,
Just inserted:
<script language="JavaScript" type="text/javascript">
---code---
</script>
Inside page, and it was all working okay...
But now... It doesn't show...
How can I change configuration or something to enable showing javascript blocks without CakePHP commands.
Javascript needs data from that page so I can't use outer file,
and it's too long to use $javascript->codeBlock
Is there any way to reconfigure stupid CakePHP to start showing those blocks?
Some files are showing javascript, and it's working all okay, but some of them won't show...
Please help...
If you mean that you want to view the code when the page is displayed, try surrounding it with <pre>...</pre>
If you mean you want the browser to process the code, then provided you are
actually going to that view file and
the code isn't commented out (<!-- ... --> or <?php /* ?> ... <?php */ ?> etc.) and
the code isn't being obliviated by a php conditional (if ... then ... else... endif)
then it will be there. Try Firefox ctrl-u to view the source.
Also try posting the view code here so that we can give you some sort of informed solution.

Drupal incorrectly escapes tags in javascript

I installed drupal-6.16.
I applied the patch from the post http://drupal.org/node/222926#comment-930745.
It works correctly in simple cases.
But following code of counter is handled incorrectly and counter is now displayed on the page after drupal.
Drupal modifies the string
"alt='1Gb.ua counter'><\/a>")</script>
to
"alt='1Gb.ua counter' /><\/a>")</a></script>
The full code of counter follows:
<br><br>
Text
<br><br>
<!-- counter.1Gb.ua -->
<script language="javascript" type="text/javascript">
cgb_js="1.0"; cgb_r=""+Math.random()+"&r="+
escape(document.referrer)+"&pg="+
escape(window.location.href);
document.cookie="rqbct=1; path=/"; cgb_r+="&c="+
(document.cookie?"Y":"N");
</script><script language="javascript1.1" type="text/javascript">
cgb_js="1.1";cgb_r+="&j="+
(navigator.javaEnabled()?"Y":"N")</script>
<script language="javascript1.2" type="text/javascript">
cgb_js="1.2"; cgb_r+="&wh="+screen.width+
'x'+screen.height+"&px="+
(((navigator.appName.substring(0,3)=="Mic"))?
screen.colorDepth:screen.pixelDepth)</script>
<script language="javascript1.3" type="text/javascript">
cgb_js="1.3"</script>
<script language="javascript"
type="text/javascript">cgb_r+="&js="+cgb_js;
document.write("<a href='http://www.1Gb.ua?cnt=1416'>"+
"<img src='http://counter.1Gb.ua/cnt.aspx?"+
"u=1416&"+cgb_r+
"&' border=0 width=88 height=31 "+
"alt='1Gb.ua counter'><\/a>")</script>
<noscript><a href='http://www.1Gb.ua?cnt=1416'>
<img src="http://counter.1Gb.ua/cnt.aspx?u=1416"
border=0 width="88" height="31" alt="1Gb.ua counter"></a>
</noscript>
<!-- /counter.1Gb.ua -->
Does anybody have this code working?
How should Drupal be fixed to handle this code in correct way?
Other suggestions are welcome.
EDIT:
Removing comments does not resolve the issue.
The issue you describe only when you use the HTML corrector with HTML comments. A quick solution is to remove the comments or disable the HTML corrector.
It would be great if the HTML corrector could handle HTML comments, but IMO HTML comments don't belong in the content of a node etc. If you plan on making markup so complex and special that it needs comments, it's an indicator that it belongs in your theme and not as content.
In your case, you want to add some javascript. Drupal has a function, drupal_add_js, for this, that not only will add the script, but with settings you can cache and minify it for production environment. This will boost performance and general is the way you want to add js to a Drupal site.
Since you are only trying out Drupal, the quickest solution for you now, is just to remove the HTML comments and you should be fine. But if you want to make something meant for a live site, you should check out drupal_add_js.
The input filters settings can be found at admin/settings/filters when you edit or create a new filter here you can decide which roles can use it and if the HTML corrector should be applied.
It is fixed in drupal 7.x.
Details are here.
Enabling the PHP filter module and setting the input format to PHP solved this issue for me.
I got this issue randomly in Drupal6 for all content, with or without editor enabled Filtered, Full HTML or PHP.
Found that culprit is the magic_quotes_gpc flag in PHP.
Luckily I was able to turn it off easily in php.ini, which solved the problem of all kinds of weird escaping.

$(document).ready(function() isn't called

I've set document.ready in the middle of a page.
It was working fine on local server, on an online production beta server, but failed on the final server.
Any suggestions?
thx
Code:
$(document).ready(function() {
And yes. JQuery is loading and it's working propely
UPDATE: These days I've found the same issue and for futher reference the script tag that includes the jQuery must be propely closed. If not the $(document).ready() is never called.
Wrong:
<script type='text/javascript' src='js/jquery-1.6.2.min.js'/>
Also wrong:
<script type='text/javascript' src='js/jquery-1.6.2.min.js'>
Right:
<script type='text/javascript' src='js/jquery-1.6.2.min.js'></script>
Nowadays using hmtl5 <!DOCTYPE html>
Get Firebug and check:
is jQuery loading or is it missing. And is it loaded before the document.ready ?
is the script throwing any JavaScript-errors?
The most likely problem is the production server doesn't have a copy of jquery. Switching to having google provide jquery for you is a good practice.

PHP / JavaScript. Browser "loads" forever, even after all resources are finished downloading, plus Opera/Chrome Issues

I have a page that does the following:
The browser loads a very simple page with a valid head and body, with only a script/noscript pair as content.
In the body, it has a script (script a) that runs a function onLoad. This function dynamically includes a second script (script b), and runs a function in it when it becomes available.
The second script is a .js file that does various work.
Both scripts are parsed by PHP and use the application/x-javascript content type.
Now, I have this all working just fine, except a couple of JS hiccups. JavaScript isn't one of my strong languages, so I'm hoping these are simple issues and somebody can point me in the right direction.
Problem 1: If I do a simple alert('you are in script b'); in the second script, it works as expected. However, if I do anything else, it works fine, and then the browser keeps indicating that it is loading forever. This is the color tween in firefox, or the spinning thing in IE.
I've tried ending the script in different ways, and nothing seems to help. Any idea how to indicate to the browser that the script is all the way loaded? It's a .js file that is forced to parse through PHP.
Problem 2: The second script doesn't seem to be included at all in either Opera or Google Chrome. Works fine in FF/IE, other than the loading issue. Can anyone see if Im using something that isn't compatible in the loading of the second script?
Thanks!
Update:
Thanks for the answers. I actually have firebug, which is why I know everything is working properly (in FF, at least). I don't actually know that the script isn't working in Opera/Chrome, but nothing happens.
It is quite a bit of code =o) I will copy the actual responses out of firebug and post those, so you can see exactly what the code is. As far as the webserver closing the connection, I was thinking that too, but it seems odd that if I make script b into alert('whatever'); it will alert and then stop loading, but it I do everything exactly identical, but make the script document.write('whatever); it will load forever.
Here are the scripts, updated, copied directly from the net tab of firebug:
Note that discoverfire.net is an internal domain, so you won't be able to load anything from there...
Initial HTML page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Welcome!</title>
<style>body { font-family:arial; }</style>
<script language="JavaScript" type="text/javascript" src="http://www.discoverfire.net/analytics/l/a.js">
</script>
<script language="JavaScript" type="text/javascript">
document.onload = Start();
function Start(){
TAFKing_version = '1.0';
TAFKing_lkey = '19-8O-KKA8HV';
TAFKing_Lander();
}
</script>
</head>
<body>
<noscript>
Oops! We can't forward you properly because your JavaScript is turned off.<br /><br />
<a href='http://www.discoverfire.net/analytics/l/noscript/19-8O-KKA8HV.html'>Please click here to continue.</a>
<img src='http://www.discoverfire.net/analytics/l/imp/19-8O-KKA8HV.png' border='0' alt='tell a friend' />
</noscript>
</body>
</html>
** Script A (...a.js): http://www.discoverfire.net/analytics/l/a.js **
function TAFKing_Lander(){
version = TAFKing_version;
lkey = TAFKing_lkey;
var scrb = document.createElement('script');
scrb.type = 'text/javascript';
scrb.src = 'http://www.discoverfire.net/analytics/l/b.js?lkey='+lkey+'&version='+version+'&cb=4eohe8e65'
;
document.getElementsByTagName('head')[0].appendChild(scrb);
Interval = setInterval("Waiter()", 10);
return;
}
function Waiter(){
if(window.TAFKing_LanderB) {
clearInterval(Interval);
TAFKing_LanderB();
}
}
Script B (...b.js): http://www.discoverfire.net/analytics/l/b.js?lkey=19-8O-KKA8HV&version=1.0&cb=4eohe8e65
function TAFKing_LanderB(){
document.write("there are just a whole bunch of doc.writes here that build a simple table");
}
I bet it is nothing related with the scripts, but with the webserver. Your description, specially that it affects many browsers, and some of them don't even run the scripts, leads me to believe that the webserver is not closing the connection. Perhaps the webserver is not properly handling HTTP/1.1 Keep-alive requests.
Try using Firebug in Firefox. Install it, enable it for your page, reload the page and check the "Net" tab for what really is keeping the connection open.
This is a lot of code to go through. You should definitely get Firebug to help you diagnose it. The latest version will even show you when/if the onload events occur.
Firebug will also allow you to output message simply by writing console.log('somevar=',var); to test their values. You can even use the console to test value after the page has loaded since you're using the global name space.
Off the top of my head, I would make sure the connection properly closes in php. Also
document.onload = Start();
would assign the result of Start() to onload, not Start which is defined later.
Also window.onload is more compatible/standard.
You may want to save the output of your js files as outputphpA.js and outputphpB.js, directly source those and see if the loading behavior differs. That should help diagnose if it's a php issue.

Categories