Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

"$_SERVER['PHP_SELF']."

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

"$_SERVER['PHP_SELF']."

Postby da9nlc » Tue Apr 01, 2003 1:19 pm

I found this next and previous script that produces the results the way I want.

Problem is (infact with every example of script I have tried), the fact when I click on the links to show the next rows all that happens is the whole script re-runs through which is not what i want rather than just from rows 10 to 20. Is there something Im missing? I changed all $php_self to ".$_SERVER['PHP_SELF']." but still getting the same problem.

I am using phpdev's program I thought it was possible that I hadnt installed apache as a server. but have since installed but still get the same problem.

Also as part of the script (shown below) allows the viewer to change the amount of results shown per page. This was written as $php_self and I was getting undefined variable error. I changed it to ".$_SERVER['PHP_SELF']." but all I got was T_NUM etc error.

Results per-page: <a href="<?=$PHP_SELF?>?query=<?=$query?>&page=<?=$page?>&limit=5">5</a> | <a href="<?=$PHP_SELF?>?query=<?=$query?>&page=<?=$page?>&limit=10">10</a> | <a href="<?=$PHP_SELF?>?query=<?=$query?>&page=<?=$page?>&limit=20">20</a> | <a href="<?=$PHP_SELF?>?query=<?=$query?>&page=<?=$page?>&limit=50">50</a>.

I hope I have made this legible. I would appreciate giving me some idea why $php_self isnt doing what I expect it to. Or is this in the realms of session variables?

Thanks
da9nlc
New php-forum User
New php-forum User
 
Posts: 21
Joined: Sun Feb 23, 2003 11:58 pm

Postby pootergeist » Wed Apr 02, 2003 12:56 am

are query and page made global prior in the scripting? I assume you've echoed $query and $page to assure they exist.

$query = $_GET['query']; ?

most T_ parse errors are due to badly terminating strings - certainly if you just plugged the echo string you have ".$_SERVER['PHP_SELF']." somehow into the shorttag broken html output the script would fubar rapidly
pootergeist
New php-forum User
New php-forum User
 
Posts: 191
Joined: Wed Jan 29, 2003 7:11 am
Location: UK

I solved the php_self error

Postby da9nlc » Wed Apr 02, 2003 5:34 am

I soved the php_error I was receiving

And yes I did echo ($_POST['var']; I did echo the query too a couple of times its used as part of title of result page.

Below is the way

<?php
for ($i=1; $i <= $pages; $i++) // loop through each page and give link to it.
{
$ppage = $limit*($i - 1);
if ($ppage == $page){
echo("<b>$i</b> \n");} // If current page don't give link, just text.
else{
echo("<a href=\"".$_SERVER['PHP_SELF']."?query=$query&page=$ppage&limit=$limit\">$i</a> \n");}
}
?>

I have tried adapting various examples of next and previous links but with the same problem..........or hangon should I be using $_GET rather than $_POST
da9nlc
New php-forum User
New php-forum User
 
Posts: 21
Joined: Sun Feb 23, 2003 11:58 pm

No think $_POST['var']

Postby da9nlc » Wed Apr 02, 2003 9:55 am

I tried get rather than post but was not the problem. I have done phpinfo and all variables are being parsed. So I am becoming increasingly confused as to why I am unable to move from one set of rows to the next i.e. 1 to 10 and 10 to 20.

I installed apache server with phpdev 4.2 on my system thinking this was the possible problem but was not it seems. I was questioning my setup after trying diiferent variations of next and previous links with the same result.

The correct number of rows are retrieved from my database and the correct numbering 1 to 10 of 11 and page 1 of 2 as should be. If anyone could maybe give us an idea of what the problem could be would appreciate it.
da9nlc
New php-forum User
New php-forum User
 
Posts: 21
Joined: Sun Feb 23, 2003 11:58 pm


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 4 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.