I'm using this code for my PHP query strings
<?
$tutorials = $_GET["tutorials"]
if (($tutorials == "php") or ($tutorials == "")) {
echo ("<?php include ("tuts/php.php"); ?>");
} else if($tutorials == "perl") {
echo ("<?php include ("tuts/perl.php"); ?>");
}
?>
So when I go to tutorials.php?tutorials=php it doesn't work. Is this code OK?If you're using PHP 4.1 or higher yes, if not, then no
if you're using lesser then PHP 4.1, you need to use $HTTP_GET_VARS['tutorials'] instead of $_GET['tutorials']i don't know exactly if here's your problem but you use:
if (($tutorials == "php") or ($tutorials == "")) {
i would use:
if ($tutorials == "php" || $tutorials == "") {
..
and instead of
echo ("<?php include ("tuts/php.php"); ?>");
it would be alot simpler to simply use:
include("tuts/php.php");
but that totally depens on what you prefer yourself
(in total:
<?
$HTTP_GET_VARS['tutorials'];
if ($tutorials == "php" || $tutorials == "") {
include("php.php");
}
else if($tutorials == "perl") {
include("perl.php");
}
?>):rocker:Thanks for the help yoda. This goes in the head of every page right?Originally posted by DA Master
Thanks for the help yoda. This goes in the head of every page right?
On every page you want either a perl or php headerhey im kinda new...do i put that at the top of my page, and how do i get the urls to have = signs in them??I've explained in another thread here (<!-- m --><a class="postlink" href="http://www.htmlforums.com/showthread.php?threadid=21266">http://www.htmlforums.com/showthread.php?threadid=21266</a><!-- m -->). Here's the code anyway
<html>
<head></head>
<body>
Blah blah <br>
<?php
if ($_GET["tutorials"] == "php") || ($_GET["tutorials"] == "")) {
include ("tuts/php.php");
} else if( $_GET["tutorials"] == "perl") {
include ("tuts/perl.php");
}
?>
<br>
blah blah
</body>
</html>
first make sure your server supports PHP and then place the <?php //code ?> where you want the data to appear on the page.
and how do i get the urls to have = signs in them??
what do you mean? Please clarify Originally posted by yoda
and instead of
echo ("<?php include ("tuts/php.php"); ?>");
it would be alot simpler to simply use:
include("tuts/php.php");
but that totally depens on what you prefer yourself
that was your problem DA. if you are in php mode then you don't/can't use
echo ("<?php include ("tuts/php.php"); ?>");
as that will be making it come out of php mode.
originally posted by Justin
hey im kinda new...do i put that at the top of my page, and how do i get the urls to have = signs in them??
when the user clicks on the link it will be like this
<a href=http://www.htmlforums.com/archive/index.php/"page.php?tutorial=php">Link</a>
then in page.php you have the code on this page a the very top.
<?
$tutorials = $_GET["tutorials"]
if (($tutorials == "php") or ($tutorials == "")) {
echo ("<?php include ("tuts/php.php"); ?>");
} else if($tutorials == "perl") {
echo ("<?php include ("tuts/perl.php"); ?>");
}
?>
So when I go to tutorials.php?tutorials=php it doesn't work. Is this code OK?If you're using PHP 4.1 or higher yes, if not, then no
if you're using lesser then PHP 4.1, you need to use $HTTP_GET_VARS['tutorials'] instead of $_GET['tutorials']i don't know exactly if here's your problem but you use:
if (($tutorials == "php") or ($tutorials == "")) {
i would use:
if ($tutorials == "php" || $tutorials == "") {
..
and instead of
echo ("<?php include ("tuts/php.php"); ?>");
it would be alot simpler to simply use:
include("tuts/php.php");
but that totally depens on what you prefer yourself
(in total:
<?
$HTTP_GET_VARS['tutorials'];
if ($tutorials == "php" || $tutorials == "") {
include("php.php");
}
else if($tutorials == "perl") {
include("perl.php");
}
?>):rocker:Thanks for the help yoda. This goes in the head of every page right?Originally posted by DA Master
Thanks for the help yoda. This goes in the head of every page right?
On every page you want either a perl or php headerhey im kinda new...do i put that at the top of my page, and how do i get the urls to have = signs in them??I've explained in another thread here (<!-- m --><a class="postlink" href="http://www.htmlforums.com/showthread.php?threadid=21266">http://www.htmlforums.com/showthread.php?threadid=21266</a><!-- m -->). Here's the code anyway
<html>
<head></head>
<body>
Blah blah <br>
<?php
if ($_GET["tutorials"] == "php") || ($_GET["tutorials"] == "")) {
include ("tuts/php.php");
} else if( $_GET["tutorials"] == "perl") {
include ("tuts/perl.php");
}
?>
<br>
blah blah
</body>
</html>
first make sure your server supports PHP and then place the <?php //code ?> where you want the data to appear on the page.
and how do i get the urls to have = signs in them??
what do you mean? Please clarify Originally posted by yoda
and instead of
echo ("<?php include ("tuts/php.php"); ?>");
it would be alot simpler to simply use:
include("tuts/php.php");
but that totally depens on what you prefer yourself
that was your problem DA. if you are in php mode then you don't/can't use
echo ("<?php include ("tuts/php.php"); ?>");
as that will be making it come out of php mode.
originally posted by Justin
hey im kinda new...do i put that at the top of my page, and how do i get the urls to have = signs in them??
when the user clicks on the link it will be like this
<a href=http://www.htmlforums.com/archive/index.php/"page.php?tutorial=php">Link</a>
then in page.php you have the code on this page a the very top.