Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Trying to refresh page

Posted by Chris_Isaac (Chris Isaac), 22 August 2003

I want to be able to refresh a page, what basically happens is the user gets the 1st say 5 results, then if they hit refresh they get another 5 which are randomly chosen.  

I wanted to append a link to the bottom of the page to allow them to refresh using the script, the problem is the county field, although coming up in the url window is not coming up in the link, can anyone see why?  I'm printing the varibles $town and $county at the end just to prove they contain the correct information (and they do).

Any ideas? or is there a simpler way to refresh the current page?

$fullrep = "Select <a href=$PHP_SELF?nexty=2&town=$town&county=$county > here </a>".
           "for a different selection of matches  $town...$county<br>".$fullrep;

Posted by John_Moylan (jfp), 22 August 2003

Getting your script to call itself does seem the simplest way (to me) of doing this, and using $PHP_SELF is the best/ most portable way.

I can't see why this is not working though, I tried you example on the command line.
#! /opt/php-4.3/bin/php


$town = "anyTown";
$county = "anyCounty";

$fullrep = "Select <a href=$PHP_SELF?nexty=2&town=$town&county=$county> here </a>". "for a different selection of matches  $t\

print $fullrep;

and the output was

Select <a href=dumpthis.php?nexty=2&town=anyTown&county=anyCounty> here </a>for a different selection of matches  anyTown...anyCounty<br>

Which is what I assume you want it to print.

One thing I'm in the habit of doing when getting pages to call themselves is trying to control the cache, basically trying to stop the browser keeping a copy of the page.

I do this with a file that I "include(filename)" which contains the below stuff:
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Expires:Mon,26 Jul 1997 05:00:00 GMT");

They're pointers but not a real answer to why its not working I'm afraid.

Posted by Chris_Isaac (Chris Isaac), 22 August 2003
Thanks for your response jfp, if I use PHP_SELF by itself, it just takes me back to the original search page, which is not what I want.  Your example is what I'm after, but for some reason the $county field in the next bit of code isn't being picked up:


but I know $county has the correct value because I print it out to prove it!  doesn't make sense why?

I get the following link option:


The county field just isn't there!

I'll bang my head against the wall a few more time to see if the answer comes to me, but any other thoughts gratefully received!  

Posted by Chris_Isaac (Chris Isaac), 22 August 2003
Well banging my head seemed to have worked.  Now got it I substituted the line for :

$fullrep = "Select <a href=$PHP_SELF?$QUERY_STRING > here </a>"

and thats done the trick, but thank you anyway.

Posted by admin (Graham Ellis), 23 August 2003
Chris, I'm guessing that your $county variable has a character that needs URL encoding in it (it probably starts with a space), and as you weren't encoding it in the first example, that space got through and was interpretted as a delimiter at the end of the HTTP request.  Going gack to the lower level query string fixed the problem by sending out the encoded string that you read in.   Neat solution  

P.S.  This one had me baffled when I first saw the post last night - I thought you might have forgotten to echo back a field in the URL or something, but I didn't have a chance to investigate / answer.  I came here this morning thinking that I was going to have to give it some serious thought ... delighted that it's fixed, and the fix looks llike it should be a robust fix too.

Posted by Chris_Isaac (Chris Isaac), 23 August 2003
Your guess is right, there is a space there!

seems to have solved the problem, the page is doing what it should now.  

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho