Saturday 15 September 2012

php - Script does not work, shows no errors -



php - Script does not work, shows no errors -

i made little script 'cache' copies of websites, , far can tell appears coded fine, when run in browser, not work , shows no errors.

my code:

<?php //display errors please error_reporting(e_all); ini_set('display_errors', 1); //get random string $length = 5; $string = ""; $characters = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789"; //thanks code stackoverflow while ($length > 0) { $string .= $characters[mt_rand(0,strlen($characters)-1)]; $length -= 1; } $random = $string //get url request if(isset($_get['link'])) { $link = $_get['link']; $data = file_get_contents("http://$link"); //send info html file file_put_contents("/cache/$random.html","$data"); echo "cached successfully.<br>link: http://example.com/cache/$random.html"; } ?>

there syntax error in code posted,

$random = $string

should be

$random = $string;

its thought check php files errors after edit them. 1 way (if on linux/unix system) run php command

php -l filename.php

you utilize online compiler (what did code)

http://writecodeonline.com/php/

php

No comments:

Post a Comment