Jump to content

5 lines of php I need help with


Howman

Recommended Posts

My server is iis 7.5 and using php 5.3.6 ntsI have not been able to get this code to work it's part of an old heat map script I found from 2006. There is 2 other parts of code one java and another php but this one I can not get to work.

<? $q=$REQUEST_URI;include_once("functions.php");save_file($q, "clickcount.txt"); ?>

I have tryed playing with it a bit but what ever I try it will not write to a text file. The text file is readable and writeable I tested with a php script.As I am new to php still trying to figure it out.

Link to comment
Share on other sites

Are you sure you mean $REQUEST_URI, not $_SERVER['REQUEST_URI'] ?Did you try echo $q to see what it's value is?Are you sure you know how the save_file function works? Any reason not to use file_put_contents ?

Link to comment
Share on other sites

Are you sure you mean $REQUEST_URI, not $_SERVER['REQUEST_URI'] ?Did you try echo $q to see what it's value is?Are you sure you know how the save_file function works? Any reason not to use file_put_contents ?
Thank you for your quick repyO.k I changed $REQUEST_URI to $_SERVER['REQUEST_URI'] In FireFox web console I get thisGET http://www.mysite.co.cc/empty.php?x=99&y=137 HTTP/1.1 200 okinvalid XML markupif I add echo $q and run empty.php the screen is just white with nothing on it and no reason not to use file_put_contents just got to look it up and see what it does and how to use it.is it ok to post url to where i found script Since I am new to php
Link to comment
Share on other sites

We post URLs all the time.Maybe it would help if you explained your goal.
I guess My goal would be get it to work. I down load tuts on php still trying to rap my head around it. I guess I am not that smart but I will learn I think it would be a good thing to know.Well I was trying to get this heat map to work on a forum site and I have had no luckI did find this
function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") {  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else {  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL;}

which will echo url but have not gotten it to save to text fileI tryed adding this file_put_contents(clickcount.txt, curPageURL);it did not workThe script found herehttp://nevyan.blogspot.com/2006/12/free-we...eatmap-diy.htmlandforum site herehttp://www(dot)mybb(dot)co(dot)cc

Link to comment
Share on other sites

Make sure error reporting is on, and try writing to the file again. Add this to the top of your code:
<?php/** * @author Howman * @copyright 2011 */ini_set('display_errors', 1);ini_set('html_errors', 1);error_reporting(E_ALL);function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") {  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else {  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL;}file_put_contents(clickcount.txt, curPageURL);?>

I get 500 server errorbut if i remove this linefile_put_contents(clickcount.txt, curPageURL);I get nothing but a white page

Link to comment
Share on other sites

You need to call the function in order to submit it's return value as the second paramater of file_put_contents

file_put_contents("clickcount.txt", curPageURL());

edit: added quotes to first param

Link to comment
Share on other sites

Ok justsomeguy I found some problems needed ' ' around the text file and curPageURL but now it just writes curPageURL to text file and only onceI am looking for the text file to recourd links like thishttp://www.mysite.co.cc/empty.php?x=60&y=67and to recourd all mouse clicks like thisBut its a start took all most 3 days to get this farThank you Deirdre's Dad and justsomeguy for you help so farIf i go echo curPageURL();and goto http://www.mysite.co.cc/empty.phpI get http://www.mysite.co.cc/empty.php and not http://www.mysite.co.cc/empty.php?x=60&y=67

Link to comment
Share on other sites

Ok justsomeguy I found some problems needed ' ' around the text file and curPageURL but now it just writes curPageURL to text file and only onceI am looking for the text file to recourd links like thishttp://www.mysite.co.cc/empty.php?x=60&y=67and to recourd all mouse clicks like thisBut its a start took all most 3 days to get this farThank you Deirdre's Dad and justsomeguy for you help so farIf i go echo curPageURL();and goto http://www.mysite.co.cc/empty.phpI get http://www.mysite.co.cc/empty.php and not http://www.mysite.co.cc/empty.php?x=60&y=67
see my post about calling the functionedit: for what it's worth, what you are getting is exactly what should be happening, as dictated by why the function is doing. if you read the link you posted, you will find that this is just for setting up the page to work with the AJAX request you need to send to it. Try stepping back and re-reading the whole thing over again.
Link to comment
Share on other sites

see my post about calling the functionedit: for what it's worth, what you are getting is exactly what should be happening, as dictated by why the function is doing. if you read the link you posted, you will find that this is just for setting up the page to work with the AJAX request you need to send to it. Try stepping back and re-reading the whole thing over again.
Boy am I stupid I put ' ' around curPageURL() and was not ment to. Now it writes the links i want but, just once so Im still missing somthing some whereWhy is always stupid little misstakes that mess the whole thing up :)
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...