[PHP/MySQL] include "****.php?id=2" niet, maar "***.php" wel

Pagina: 1
Acties:
  • 61 views sinds 30-01-2008

  • masser120
  • Registratie: Januari 2004
  • Laatst online: 14-04 13:56
Hallo,
Ik heb de search gebruikt maar niks relevants gevonden.

Ik heb een php script gemaakt (nog erg rommelig):

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?
 include("config.php");  
  if (!isSet($_GET['page']) || empty($_GET['page']))  { $page = 1; } 
else { $page = intval($_GET['page']); } 
 $query = "SELECT * FROM linknr WHERE page='$page'";
  $result = mysql_query($query)
     or die("Fout bij uitvoeren query");
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
//Vul hier de resulaten in
$linkpage=mysql_result($result,$i,"link");
$i++;
}
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="<? echo "$style" ?>" rel="stylesheet" type="text/css">
</head>

<body>
<table width="100%" cellspacing="0" cellpadding="0">
  <tr> 
    <td colspan="2">Test</td>
  </tr>
  <tr> 
    <td width="127"><? include "frame.php" ?></td>
    <td><? include "test.php?id=3" ?></td>
  </tr>
</table>
</body>
</html>


Het is de bedoeling dat include "test.php?id=3" in de tabel komt te staan. De hele pagina... Dat id=3 slaar gewoon op een MySQL database. Maar dat include "test.php?id=3" wil die niet doen. Als ik nou zeg include "test.php", dan doet deze het wel, maar alles met een vraagteken doet die niet. Terwijl als ik test.php?id=3 apart open, dan doet deze het wel!

Is dit gewoon iets dat php niet kan en moet ik een omweg nemen? Of is de script fout?

Verwijderd

Dit kan php inderdaad niet, GET/POST waarden via een include meegeven.
Probeer sessions eens, of je roept het bestand waarin je test include aan met &id=3, dan kan je $_GET["id"] wel gewoon in test.php gebruiken.

  • b19a
  • Registratie: September 2002
  • Niet online
PHP:
1
$id=3; include "test.php";

[ Voor 47% gewijzigd door b19a op 20-04-2005 19:00 ]


  • 418O2
  • Registratie: November 2001
  • Laatst online: 22:39
kan jet niet gewoon

PHP:
1
2
$id = 3;
include 'test.php';

doen?

ben ook weer veel te sloom

[ Voor 23% gewijzigd door 418O2 op 20-04-2005 18:59 ]


  • simon
  • Registratie: Maart 2002
  • Laatst online: 22:18
had je gister ook niet al zo'n topic?

|>


  • Creepy
  • Registratie: Juni 2001
  • Laatst online: 06-05 18:51

Creepy

Tactical Espionage Splatterer

masser120 schreef op woensdag 20 april 2005 @ 18:55:
Ik heb de search gebruikt maar niks relevants gevonden.
Ja en? Er is ook nog google en de documentatie van PHP zelf. Als je op de de PHP site had gekeken naar de functie include had je het volgende zien staan:
Van http://nl2.php.net/manual/en/function.include.php
Example 16-7. include() through HTTP
<?php

/* This example assumes that www.example.com is configured to parse .php
* files and not .txt files. Also, 'Works' here means that the variables
* $foo and $bar are available within the included file. */

// Won't work; file.txt wasn't handled by www.example.com as PHP
include 'http://www.example.com/file.txt?foo=1&bar=2';

// Won't work; looks for a file named 'file.php?foo=1&bar=2' on the
// local filesystem.
include 'file.php?foo=1&bar=2';

// Works.
include 'http://www.example.com/file.php?foo=1&bar=2';

$foo = 1;
$bar = 2;
include 'file.txt'; // Works.
include 'file.php'; // Works.

?>
Volgende keer mag je zelf RTFM gaan doen.

Daarnaast: als Pelle zegt in een sluit message dat het te basic is voor in P&W dan is dat meestal ook zo ;)

[ Voor 8% gewijzigd door Creepy op 20-04-2005 19:04 ]

"I had a problem, I solved it with regular expressions. Now I have two problems". That's shows a lack of appreciation for regular expressions: "I know have _star_ problems" --Kevlin Henney

Pagina: 1

Dit topic is gesloten.