For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > December 2004 > Apples or Oranges









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Apples or Oranges
Christopher A. Kelly

2004-11-30, 3:56 am

I know that I am fixing to ask the stupid question which is better
apples or oranges, personal preference...
Anyway, I am fairly new to PHP and am wondering if there is a better
way to do the following. It works just fine, but before I get set in a
programming style I want to make sure I am doing it correctly.

if (!isset($_GET['kccontent']) or
$_GET['kccontent']=="")
{
include($pages.'/main.php');
}
else
{
$dbcnx = mysql_connect('localhost', 'mysql',
'mypass') or die('<p>Unable to connect to the database server at this
time.</p>');
mysql_select_db('kcWebsite') or die('<p>Unable to
locate the database at this time.</p>');
$result = mysql_query('SELECT * FROM kcWebNav WHERE
name="'.$_GET['kccontent'].'"') or die('<p>Error performing query: ' .
mysql_error() .'</p>');
while ($row = mysql_fetch_array($result))
{
if(!$row['path']=="")
{
if(substr($row['path'],0,7) == "http://")
{
header("Location: ".$row['path']);
}
else
{
if(substr($row['path'],0,6) ==
"ftp://")
{
header("Location: ".$row['path']);
}
else
{
include($row['path']);
}
}
}
else
{
include($pages.'/main.php');
echo('<br><hr><h1
align="center">Error!</h1>'.
'<center>Path Not Found so here you
are</center><hr>');
}
}
}
Cameron

2004-11-30, 8:56 pm

Hilarion wrote:
>
>
> Nope. It returns zero.
>
>
> Hilarion
>
>


0 == False, False == 0

~Cameron
Hilarion

2004-12-01, 3:55 am

> Note the !, this isn't a mistake, strcasecmp returns false if the strings match.

Nope. It returns zero.


Hilarion


Cameron

2004-12-01, 3:55 am

Cameron wrote:
> Hilarion wrote:
>
>
> 0 == False, False == 0
>
> ~Cameron


Oh and just before I'm called up on it

False !== 0; 0 !== false ;)

~Cameron
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com