| | |
External JavaScript and PHP Problem
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2008
Posts: 39
Reputation:
Solved Threads: 0
Can someone tell me where is the problem ?
analiz.php
PHP Syntax (Toggle Plain Text)
<script type="text/javascript" src="http://www.forumistan.net/analiz/analiz.php?site=http://www.forumistan.net"></script>
analiz.php
PHP Syntax (Toggle Plain Text)
<? Header("content-type: application/x-javascript"); ob_start(); include 'all.php'; ob_end_clean(); echo "document.write(\"<div class=\"txt\">Pagerank: $rank->pagerank <br>\")"; echo "document.write(\"Alexa: $rank->alexa_rank</div>\")"; ?>
Last edited by CasTex; Mar 31st, 2008 at 3:10 pm.
•
•
Join Date: Aug 2005
Posts: 150
Reputation:
Solved Threads: 13
try:
in the PHP-code.
If it doesn't help then open that JS directly in your browser and tell us the error-reporting.
php Syntax (Toggle Plain Text)
echo "document.write(\"<div class=\"txt\">Pagerank: ".$rank->pagerank." <br>\")"; echo "document.write(\"Alexa: ".$rank->alexa_rank."</div>\")";
If it doesn't help then open that JS directly in your browser and tell us the error-reporting.
Last edited by peter_budo; Apr 1st, 2008 at 7:11 am. Reason: Keep It Organized - please use [code] tags
I see you are using
Try removing that line -
The OB functions are for Output Buffering -
ob_end_clean() - that clears the Output buffers and turns off output buffering. I am not sure, but that might mean that your include 'all.php'; will not be used at all.Try removing that line -
ob_end_clean(); - and then at the very end of your code on that page, have ob_end_flush(); The OB functions are for Output Buffering -
ob_start() holds all php output in the buffer until it receives the ob_end_flush() command. Then is sends all the output to the browser and clears the buffer. ob_end_clean() just clears the buffers without sending the contents to the browser. •
•
Join Date: Jan 2009
Posts: 11
Reputation:
Solved Threads: 1
Try this:
Problem is at the first line. I think. Maybe.
<?PHP
Header("content-type: application/x-javascript");
ob_start();
include 'all.php';
ob_end_clean();
echo "document.write(\"<div class=\"txt\">Pagerank: $rank->pagerank <br>\")";
echo "document.write(\"Alexa: $rank->alexa_rank</div>\")";
?>Problem is at the first line. I think. Maybe.
Last edited by peter_budo; Jan 18th, 2009 at 2:14 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
this is a short script file in php that works
file:: script.js.php
header ('content-type: application-x, .........
looks for an external handler,
javascript is supposed to run in the browser
gzhandler, compresses the files before sending
file:: script.js.php
php Syntax (Toggle Plain Text)
<?php header ('content-type: text/javascript'); ob_start("ob_gzhandler"); ?> function newuntill(date) { var newimg = "./images/new.gif"; var expdate = new Date(date); var curdate = new Date(); if (expdate.getTime() > curdate.getTime()) { document.write('<img align="left" src=' + newimg + '>'); } else { document.write(''); } } function movein(which,html) { which.style.background='turquoise' window.status=html } function moveout(which) { which.style.background='#d4d0c8' window.status='' } <?php ob_flush(); ?>
looks for an external handler,
javascript is supposed to run in the browser
gzhandler, compresses the files before sending
Last edited by almostbob; Jan 18th, 2009 at 1:30 am.
Failure is not an option It's included free
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
![]() |
Similar Threads
- Can I use a template html page within another html page (Site Layout and Usability)
- Programming FAQ - Updated 1/March/2005 (Computer Science)
- Advanced verification on error checking (PHP)
- php sending mail via smtp external site (PHP)
- PHP mysql drop down populates another drop down (PHP)
- Opinions? javascript/php/etc and programming standards (JavaScript / DHTML / AJAX)
- Google and PHP (Search Engine Optimization)
- What is wrong wtih my css? (JavaScript / DHTML / AJAX)
Other Threads in the PHP Forum
- Previous Thread: get data from a dynamic form
- Next Thread: dynamically altering the image and mouseover image for a menu
| Thread Tools | Search this Thread |
advanced apache api array beginner binary broken cakephp checkbox class cms code cookies cron curl database date datepart display dropdownlist dynamic echo email eregi error execution file files folder form forms function functions google head href htaccess html if...loop image include includingmysecondfileinthechain insert ip javascript joomla jquery key library limit link login mail menu mlm multiple mysql oop password paypal pdf pdfdownload php phpvotingscript problem query radio random recursion regex remote screen script search server sessions smarty sms soap sorting source space sql startup stored syntax system table traffic tutorial update upload url validator variable video web xml youtube zend






