|
Posted by Alvaro G. Vicario on 10/08/43 11:38
*** Pablito escribió/wrote (Sun, 29 Jan 2006 15:14:44 GMT):
> <?php
> $cont=fopen('cont.txt','r');
> $incr=fgets($cont);
> //echo $incr;
> $incr++;
> fclose($cont);
> $cont=fopen('cont.txt','w');
> fwrite($cont,$incr);
> fclose($cont);
> echo "<script type="text/javascript">
> var incr=$incr
> </script>";
> ?>
This code doesn't make much sense. You must understand that PHP and
JavaScript are _not_ executed at the same time. PHP is parsed in the server
and it's used to create the JavaScript code. So, when you get JavaScript
errors, check first the generated code.
Try this:
<?php
$cont=fopen('cont.txt','r');
$incr=fgets($cont);
//echo $incr;
$incr++;
fclose($cont);
$cont=fopen('cont.txt','w');
fwrite($cont,$incr);
fclose($cont);
?>
<script type="text/javascript"><!--
var incr=<?=$incr?>;
//--></script>
Also, your code should raise a PHP parse error. I guess your PHP install is
configured to hide errors. Edit php.ini and set accordingly the
error_reporting value.
--
-+ Álvaro G. Vicario - Burgos, Spain
++ http://bits.demogracia.com es mi sitio para programadores web
+- http://www.demogracia.com es mi web de humor libre de cloro
--
Navigation:
[Reply to this message]
|