index.php?page=something

Problems with the Windows version of XAMPP, questions, comments, and anything related.

index.php?page=something

Postby Encore » 31. October 2007 16:14

Hello,
I've got a problem on localhost with link type http://localhost/index.php?page=something. It show me only index.php with banner and menu, but not content.

For example:
I want to see member list.
On web, I go to the http://mysite.com/index.php?page=members and everything is OK.
On my computer, I'll type http://localhost/index.php?page=members and I can see only banner and menu with links, but not Member List.

Probably I forgot to allow some function...

I'm using XAMPP for Windows, version 1.6.4.

Thanks for help...
Encore
 
Posts: 4
Joined: 31. October 2007 16:02

Postby Wiedmann » 31. October 2007 16:18

I've got a problem on localhost with link type http://localhost/index.php?page=something. It show me only index.php with banner and menu, but not content.

There is something "wrong" with your code. Please read:
http://de.php.net/manual/en/language.va ... ternal.php
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby Encore » 31. October 2007 16:44

Code: Select all
<?
session_start();
include("config.php");
require "./func.php";
if ($_GET["pg"]=="login")
{
  $link=mysql_connect(SQL_HOST, SQL_USERNAME, SQL_PASSWORD);
  mysql_select_db(SQL_DBNAME);
  $id = iduzivatele($_POST["jmeno"], $_POST["heslo"], $link);
  if ($id<>0) $_SESSION["id"]=$id;
}
elseif ($_GET["pg"]=="logout")
{
  $nm=mysql_result(mysql_query("SELECT jmeno FROM web_users WHERE id=".$_SESSION["id"], $link), 0);
  mysql_query("INSERT INTO web_log (uzivatel, akce, cas) VALUES ('".$nm."', 'LOGOUT', NOW())", $link);
  unset($_SESSION["id"]);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <link rel="stylesheet" type="text/css" href="main.css">
    <title>My Page</title>
  </head>
  <body>
    <div id="page">
      <div id="logo">
        <a href="index.php"><img src="pictures/template/logo1.PNG" alt="Klikněte pro návrat na hlavní stránku..."></a>
      </div>   
      <div id="menu">
          <ul>
                <li><a href="index.php?pg=novinky" title="Novinky">Novinky</a></li>
                <li><a href="index.php?pg=kodex" title="Kodex">Kodex</a></li>
                <li><a href="index.php?pg=historie" title="Historie">Historie</a></li>
                <li><a href="index.php?pg=clenove" title="Členové">Členové</a></li>
                <li><a href="index.php?pg=vypravy" title="Výpravy">Výpravy</a></li>
                <li><a href="index.php?pg=gallery" title="">Galerie</a></li>
                <li><a href="index.php?pg=download" title="">Download</a></li>
                <li><a href="index.php?pg=yoko" title="">Yoko</a></li>
                <li><a href="index.php?pg=shop" title="">Obchod</a></li>
            <li><a href="index.php?pg=phorum" title="">Fórum</a></li>
                <? if (isset($_SESSION["id"])): ?>
                <li><a href="index.php?pg=administrace" title="Administrace">Administrace</a></li>
            <li><a href="index.php?pg=logout" title="Logout">Logout</a></li>           
                <? else: ?><li><a href="index.php?pg=login" title="Login">Login</a></li><? endif ?>
          </ul>
      </div>
      <div id="stranka">
<?
          if($pg=="uvod") {include "uvod.php";}
          elseif ($pg=="novinky") {include "novinky.php";}
          elseif ($pg=="kodex") {include "kodex.php";}
          elseif ($pg=="historie") {include "historie.php";}
          elseif ($pg=="clenove") {include "clenove.php";}
          elseif ($pg=="vypravy") {include "vypravy.php";}
          elseif ($pg=="download") {include "download.php";}
          elseif ($pg=="shop") {include "shop.php";}
          elseif ($pg=="login") {include "login.php";}
          elseif ($pg=="logout") {include "logout.php";}
          elseif ($pg=="administrace") {include "administrace.php";}
          elseif ($pg=="registrace") {include "registrace.php";}
          elseif ($pg=="log") {include "log.php";}
          elseif ($pg=="temp") {include "temp.php";}
         
          //else {include "uvod.php";}
?>
      </div>
      <div id="over">
        &nbsp;
      </div>
      <p style="margin-top: 0px; text-align: center; font-size: 6pt; color: #FFFFFF">Design & code: &copy; Encore 2007. PHP | HTML | CSS<br>Stránka je validní dle HTML 4.01 Strict.</p>
    </div>
  </body>
</html>

If I uncomment this line
//else {include "uvod.php";}
it will show me banner, menu and in content place is uvod.php (uvod is Czech word for "introduction"), but if I click on link (localhost/index.php?pg=kodex for example), I still can see "uvod.php".

It's strange, that it works on my webhosting, but on local it doesn't...
Encore
 
Posts: 4
Joined: 31. October 2007 16:02

Postby Wiedmann » 31. October 2007 17:14

Code: Select all
<?
          if($pg=="uvod") {include "uvod.php";}
          elseif ($pg=="novinky") {include "novinky.php";}
          elseif ($pg=="kodex") {include "kodex.php";}
          elseif ($pg=="historie") {include "historie.php";}
          elseif ($pg=="clenove") {include "clenove.php";}
          elseif ($pg=="vypravy") {include "vypravy.php";}
          elseif ($pg=="download") {include "download.php";}
          elseif ($pg=="shop") {include "shop.php";}
          elseif ($pg=="login") {include "login.php";}
          elseif ($pg=="logout") {include "logout.php";}
          elseif ($pg=="administrace") {include "administrace.php";}
          elseif ($pg=="registrace") {include "registrace.php";}
          elseif ($pg=="log") {include "log.php";}
          elseif ($pg=="temp") {include "temp.php";}
         
          //else {include "uvod.php";}
?>

In this part of the script you compare strings with the value of the variable "$pg". But you have never defined this variable. Thus this variable have the value "" (automatic type changing) in your comparisons.

If I uncomment this line
Code: Select all
//else {include "uvod.php";}

it will show me banner, menu and in content place is uvod.php

Thus the variable "$pg" is allways "", you can only see something, if you enable this default.

You should enable a error_reporting of E_ALL to see such bugs.

BTW:
Use "<?php" and not only "<?".
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby Encore » 31. October 2007 17:27

error_reporting = E_ALL & ~E_NOTICE

I added $pg=""; to the top of code, but still nothing. :(
Encore
 
Posts: 4
Joined: 31. October 2007 16:02

Postby Encore » 31. October 2007 18:35

I used $_GET["pg"] and it works now! :) Thanks for your advices.
Here is edited part of code:
Code: Select all
          if($_GET["pg"]=="uvod") {include "uvod.php";}
          elseif ($_GET["pg"]=="novinky") {include "novinky.php";}
          elseif ($_GET["pg"]=="kodex") {include "kodex.php";}
          elseif ($_GET["pg"]=="historie") {include "historie.php";}
          elseif ($_GET["pg"]=="clenove") {include "clenove.php";}
          elseif ($_GET["pg"]=="vypravy") {include "vypravy.php";}
          elseif ($_GET["pg"]=="download") {include "download.php";}
          elseif ($_GET["pg"]=="shop") {include "shop.php";}
          elseif ($_GET["pg"]=="login") {include "login.php";}
          elseif ($_GET["pg"]=="logout") {include "logout.php";}
          elseif ($_GET["pg"]=="administrace") {include "administrace.php";}
          elseif ($_GET["pg"]=="registrace") {include "registrace.php";}
          elseif ($_GET["pg"]=="log") {include "log.php";}
          elseif ($_GET["pg"]=="temp") {include "temp.php";}
         
          else {include "uvod.php";}
Encore
 
Posts: 4
Joined: 31. October 2007 16:02

Postby Wiedmann » 31. October 2007 18:37

Wiedmann wrote:You should enable a error_reporting of E_ALL to see such bugs.

error_reporting = E_ALL & ~E_NOTICE

"E_ALL", not "E_ALL & ~E_NOTICE".

I added $pg=""; to the top of code,

The same as before, but without a notice.
Now $pg defined and the value is allways set to "" (empty string).


but still nothing.

You remember the link from my post above and you have read this page...?

You have this link:
Encore wrote:'ve got a problem on localhost with link type "http://localhost/index.php?page=something"

But this must be wrong. You mean: "http://localhost/index.php?pg=something"?

This is a GET request, and so you can found this value in the "$_GET" array, key "pg".

Wiedmann wrote:In this part of the script you compare strings with the value of the variable "pg".

So you must use "$_GET['pg']" in the comparison. Or set the value of the variable "$pg" to the value of the array key "$_GET['pg']" --> "$pg = $_GET['pg']".
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 103 guests