473,387 Members | 1,891 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,387 software developers and data experts.

My php source code do not work

Hi at all
this code it'ld stop and exit if the user do not entered $dbf but it do not
work
Why?

if (!isset($_GET['dbf']) || (isset($_GET['dbf']) && trim($_GET['dbf']) ==
''))
{header('Location: http://www.pablo.es/index.php');
exit();}

May 29 '07 #1
4 1371
Pablo wrote:
Hi at all
this code it'ld stop and exit if the user do not entered $dbf but it do
not work
Why?

if (!isset($_GET['dbf']) || (isset($_GET['dbf']) && trim($_GET['dbf']) ==
''))
{header('Location: http://www.pablo.es/index.php');
exit();}
Hi,

Look at the logic:
if
(!isset($_GET['dbf']) || (isset($_GET['dbf']) && trim($_GET['dbf'])== ''))

My guess is you ment:
1) Demand that $_GET['dbf'] is set.
2) And if set, it must contain something (not empty string)

The above mixes the || and && is a strange way.

So try this:
if ( (isset($_GET['dbf']) && (trim($_GET['dbf']) != '')){
// OK
} else {
// Not OK
// header and exit.
}

You do not need the second isset-test this way.
When PHP evaluates the first part (isset($_GET['dbf']) to false and sees the
AND-logic operator && it doesn't even try to evaluate that, because the
if-statement can never evaluate to true.

Regards,
Erwin Moller

May 29 '07 #2
also this make error

if (!isset($_GET['dbf']))
{header("Location:http://www.pablo.es");}

why?
May 29 '07 #3
Pablo wrote:
also this make error

if (!isset($_GET['dbf']))
{header("Location:http://www.pablo.es");}

why?
Hi,

I don't know why it makes an error.
Most probably because your script makes an error somewhere futher down the
script, because you forgot the exit-command after the header.

Try this:
if (!isset($_GET['dbf'])){
header("Location:http://www.pablo.es");
exit;
}

Remember that PHP can set as many headers as you want, and the script runs
on and on and on.
You must stop it yourself by using exit.

Also, try using brackets {} like I did. It makes the code a lot more
readable. :-)
Good luck.

Regards,
Erwin Moller
May 29 '07 #4
Pablo wrote:
also this make error

if (!isset($_GET['dbf']))
{header("Location:http://www.pablo.es");}

why?

What error do you get? If you get a message about headers already being
sent, it means you've output something before the call to header(). You
can't output ANYTHING - not even a blank line - before this call.

Also, to stop execution here, you need to follow it with

exit();

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 29 '07 #5

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

Similar topics

9
by: FISH | last post by:
Ever have one of those days when you're not sure if it's you who's gone mad, or the rest of the world? I have an Open Source project on SourceForge for communication with YSMG - Yahoo's IM...
188
by: Ilias Lazaridis | last post by:
I'm a newcomer to python: - E01: The Java Failure - May Python Helps? http://groups-beta.google.com/group/comp.lang.python/msg/75f0c5c35374f553 - I've download (as suggested) the python...
9
by: TCMA | last post by:
I am looking for some tools to help me understand source code of a program written in C++ by someone else. Are there any non-commercial, open source C or C++ tools to reverse engineer C or C++...
115
by: TheAd | last post by:
At this moment I use MsAccess and i can build about every databound application i want. Who knows about a serious open source alternative? Because Windows will be a client platform for some time, i...
2
by: Carlo \(MCP only\) | last post by:
Hi to all I'm askyng you a suggestion about the best way to share the same source code between VS2003 and VS2005. The project I'm developing is a controls and components library, and the...
1
by: TC | last post by:
I'm using Visual Studio 2005 with SourceGear Vault. I'm having trouble with the integrated source code control features. I think the problem is entirely with Visual Studio, not Vault. First, let...
13
by: treble54 | last post by:
I need to build PHP from source with the pdo_ibm extension and I am having an issue with it. Firstly, I am using Visual Studio .NET 2003 and I am building PHP from source through the Visual Studio...
66
by: Jon Skeet [C# MVP] | last post by:
I'm sure the net will be buzzing with this news fairly soon, but just in case anyone hasn't seen it yet: Microsoft are going to make the source code for the .NET framework (parts of it,...
10
by: Tomás Ó hÉilidhe | last post by:
I'd post this on a gcc newsgroup but I'd be more productive talking to the wall. Anyway, let's say someone throws some source code at you for a particular program and says, "Just compile it, it...
22
by: Ken Foskey | last post by:
On Thu, 14 Aug 2008 10:09:01 -0700, raylopez99 wrote: The facts of the case above are that the person took a whole application and distributed it after some minor modifications, ie they did not...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.