473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

$GET CMS

I have bought the book on advanced dreamweaver and PHP recently. I
have installed MySQL and PHP server but am getting an error on the
$GET statement show below. It says there is a problem with the
variable $GET but $GET is not a variable, I thought it came from the
page that calls the PHP file?

if(($_GET['type'])==""){

this gets an error
<?php
require_once("class/displayNews.php");
require_once("class/displayArticle.php");
require_once("class/displayMenu.php");
################################################## ##
# CMS Page Class #
################################################## ##

class Page{

var $type;
var $mainContent;
var $pageTitle;
var $menu;

function Page(){
$this->getType();
$this->createMenu();
}

function getType(){
if(isset($_GET['type'])){
if(($_GET['type'])==""){
$link = $PHP_SELF . "?type=article&menuID=0";
header("Location:" . $link);
}
if($_GET['type']=="news"){
$this->news();
}
if($_GET['type']=="article"){
$this->article();
}
}
}
Jul 16 '05 #1
3 3457
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on 2 Jul 2003 02:29:44 -0700,
ma**@presspley.com (presspley) amazingly managed to produce the
following with their Etch-A-Sketch:
I have bought the book on advanced dreamweaver

HAHAHAHAHAHA!!!!!

(Sorry... had to laugh at advanced WYSINWYG =D ).

and PHP recently. I
have installed MySQL and PHP server but am getting an error on the
$GET statement show below. It says there is a problem with the
variable $GET but $GET is not a variable, I thought it came from
the page that calls the PHP file?

if(($_GET['type'])==""){

this gets an error
<?php
require_once("class/displayNews.php");
require_once("class/displayArticle.php");
require_once("class/displayMenu.php");
################################################## ##
# CMS Page Class #
################################################## ##

class Page{

var $type;
var $mainContent;
var $pageTitle;
var $menu;

function Page(){
$this->getType();
$this->createMenu();
}

function getType(){
if(isset($_GET['type'])){
if(($_GET['type'])==""){
$link = $PHP_SELF . "?type=article&menuID=0";
header("Location:" . $link);
}
if($_GET['type']=="news"){
$this->news();
}
if($_GET['type']=="article"){
$this->article();
}
}
}

This is all a mix of globals enabled / disabled and bad coding
practice. Is this from your book!? if so, you've just wasted your
money! (and if so, was / is it a Wrox book? they do anything but
"rock" that's for sure).

$_GET[] is used where register_globals is disabled, yet you use
'$PHP_SELF' rather than $_SERVER['PHP_SELF'] too.

I suggest one or the other, $_SERVER / $_GET etc being the primary /
most secure choice.

$_GET['type'] won't be affected by the function, as the function is
never given the data to parse.

The header call is flawed too.. you're calling a relative path. This
needs[1] to be a full URL.

Some more information might be handy.. like specific error line,
specific error message....

My car don't start.. someone said it was to do with the engine.....
;)

Regards,

Ian
[1]: Redirecting using: '/somepage.php' is wrong accordin to the HTTP
RFC IIRC.. this is required to be a complete URL:
@header('Location: http://' .
$_SERVER['HTTP_HOST'] .
'/somepage.php'
);
-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0

iQA/AwUBPwKsemfqtj251CDhEQIIfQCdFd58HyPWpO0Fx/U0RmH1lCys67kAn34P
lxHSN851joEmuSYBK0JipWEG
=lOWm
-----END PGP SIGNATURE-----

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
Jul 16 '05 #2
Also I should add the actual error was

Parse error: parse error, unexpected T_IS_EQUAL, expecting ',' or ')'
in c:\inetpub\wwwroot\cms\class\createPage.php on line 23
ma**@presspley.com (presspley) wrote in message news:<7a**************************@posting.google. com>...
I have bought the book on advanced dreamweaver and PHP recently. I
have installed MySQL and PHP server but am getting an error on the
$GET statement show below. It says there is a problem with the
variable $GET but $GET is not a variable, I thought it came from the
page that calls the PHP file?

if(($_GET['type'])==""){

this gets an error
<?php
require_once("class/displayNews.php");
require_once("class/displayArticle.php");
require_once("class/displayMenu.php");
################################################## ##
# CMS Page Class #
################################################## ##

class Page{

var $type;
var $mainContent;
var $pageTitle;
var $menu;

function Page(){
$this->getType();
$this->createMenu();
}

function getType(){
if(isset($_GET['type'])){
if(($_GET['type'])==""){
$link = $PHP_SELF . "?type=article&menuID=0";
header("Location:" . $link);
}
if($_GET['type']=="news"){
$this->news();
}
if($_GET['type']=="article"){
$this->article();
}
}
}

Jul 16 '05 #3
ma**@presspley.com (presspley) wrote in message news:<7a**************************@posting.google. com>...
I have bought the book on advanced dreamweaver and PHP recently. I
have installed MySQL and PHP server but am getting an error on the
$GET statement show below. It says there is a problem with the
variable $GET but $GET is not a variable, I thought it came from the
page that calls the PHP file?

if(($_GET['type'])==""){


I could only suggest it's the extra ( ) around the variable that's
causing the problem, although it works fine on PHP 4.3.2.

However, the whole function isn't well written, IMO. If you have more
than two statement blocks executed by IF, you should use switch
instead. As Ian.H pointed out relative redirects are not RFC compliant
and only work if the browser allows it. They also drop in and out of "
to build strings. You don't need to do that. PHP will swap variable
names in strings very happily and if you enclose array variables in {
} it will work with them too. I'd write the routine like this.

function getType() {
if (isset($_GET['type'])) {
switch ($_GET['type']) {
case "" :
$link = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}?type=article&menuID=0";
header ("Location: $link");
break;
case "news" :
$this->news();
break;
case "article" :
$this->article();
}
}
}
Jul 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: R.Wieser | last post by:
Hello All, I'm trying to get a "Virtual Listbox" to work. I've currently got a form, and used CreateWindowExA to create a ListBox with the LBS_OWNERDRAWFIXED and LBS_NODATA flags on it. I've...
0
by: Al Dente | last post by:
Round round get around I get around Yeah Get around round round I get around I get around Get around round round I get around From town to town Get around round round I get around I'm a real...
11
by: Ken Varn | last post by:
I want to be able to determine my current line, file, and function in my C# application. I know that C++ has the __LINE__, __FUNCTION__, and __FILE___ macros for getting this, but I cannot find a...
19
by: LP | last post by:
I am using (trying to) CR version XI, cascading parameters feature works it asks user to enter params. But if page is resubmitted. It prompts for params again. I did set...
1
by: dx | last post by:
I'm extremely frustrated with ASP.NET...again! To me this should be as simple as setting oCheckBox.Checked = True.. yet for some reason it isn't. I have a user control (ascx) that that has a...
12
by: Jim Hammond | last post by:
I am passing the whole object instead or parameters in my select and update methods. I can get the updated object if I set UpdateMethod, let ASP.NET autogenerate an update button, and then press...
2
by: Schorschi | last post by:
Can't seemd to get ReadFile API to work! Returns invalid handle error? =========================================================================== Ok, the visual basic gurus, help! The...
5
by: IcingDeath via DotNetMonster.com | last post by:
I am building this SQL Server database app in which i can store files. In order to display files I want to have the app show the associated icon for the extension of the file that is in the...
11
by: ucasesoftware | last post by:
If i have this property Dim m_name as string Property name() as string Get return m_name end Get Set (byval Value as string) m_name = Value
0
by: georges the man | last post by:
The purpose: • Sorting and Searching • Numerical Analysis Design Specification You are to write a program called “StockAnalyser”. Your program will read a text file that contains historical...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.