Jump to content

[SOLVED] refresh information without changing page


defeated

Recommended Posts

Hi,

I have a bit of code in my site that randomly displays 15 out of 100 entries in a db.

That works fine.

I then have the following

echo "<a href='$PHP_SELF'>More.....</a>";

The trouble is that I have split my page into header, main and footer sections. header and footer are includes. The code works and displays in the header section (note not <head>).

If I am on the index page of the site it works properly.  (the list of 15 entries changes to a new random selection)

But If I am on any other page, the page refreshes to the index page.  :-\

Anybody got any ideas?

yup, that works  :)

Anybody want to explain what the difference is?

I had to write it like this by the way:-

echo "<a href='$_SERVER[php_SELF]'>More....</a>";

no quotes around the php_self bit. Is that ok? It works.

 

If it's working then it's ok.  $_SERVER is a super global array made available to your script by the php processor. I'm not sure what $PHP_SELF is. I've seen some code around where that will be set as a constant. I've never used it like that though.

 

Be sure to set your post to solved.

 

$PHP_SELF would only would if Register Globals are on (turn off by default now and removed from PHP6)

 

no quotes mean a constant, that fails an it used the constants name as the variable, so depending on the error level, you get notice's on the page, in other words you should always use quotes, anything else is lazy and bad codeing (unless you are using constants)

 

sample

<?php
$a = array("Hello" => "world<br>", "blar" => "End Of the world<br>");
echo "test #1<br>";
echo $a[Hello];

define("Hello","blar");
echo "test #2<br>";
echo $a[Hello];

echo "test #3<br>";
echo $a['Hello'];

?>

outputs

test #1<br>world<br>test #2<br>End Of the world<br>test #3<br>world<br>

 

 

$PHP_SELF would only would if Register Globals are on (turn off by default now and removed from PHP6)

 

no quotes mean a constant, that fails an it used the constants name as the variable, so depending on the error level, you get notice's on the page, in other words you should always use quotes, anything else is lazy and bad codeing (unless you are using constants)

 

 

I started with PHP5 which would explain why I've not seen the globals version of $PHP_SELF much.

>:(

It's all gone horribly wrong. Using the method above nothing after .php is passed.. eg. ?url=jobs&jobref=jb-1987-03 etc are dropped.  This will cause horrible problems since I rely heavily on passing like that. 

Is there a better way of doing this?

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.