...

View Full Version : Warning message in my PHP code.



twilight85
08-06-2008, 02:10 AM
Hi,

I just changed the a website to a new web host and now I am getting warning messages in the following pages:

Notice: Undefined index: cat in /clientdata/clients/w/e/welcome.asn.au/www/practice.php on line 6

Notice: Undefined index: pic in /clientdata/clients/w/e/welcome.asn.au/www/practice.php on line 11

http://www.welcome.asn.au/new.php
http://www.welcome.asn.au/practice.php

I must of turned off warnings in the old web host. Could anyone tell me how to fix the code?



<?php

$cat = "";
$pic = "";

if ($_GET["cat"] != "") {
$cat = $_GET["cat"];
} else {
$cat = "";
}
if ($_GET["pic"] != "") {
$pic = $_GET["pic"];
}

if ($cat == "roam") {
include("p_header.php");
if ($pic == "") {
$pic = "roam";
}
include("practice/series/roam/r_thumb.php");
} else if ($cat == "bound") {
include("p_header.php");
if ($pic == "") {
$pic = "b_mca";
}
include("practice/series/bound/b_thumb.php");
} else if ($cat == "estate") {
include("p_header.php");
if ($pic == "") {
$pic = "de_pers";
include("practice/series/estate/d_thumb.php");
}

} else if ($cat == "portrait") {
include("p_header.php");
if ($pic == "") {
$pic = "p_kirby";
}
include("practice/portrait/p_desc.php");
} else if ($cat == "portrait") {
include("p_header.php");
if ($pic == "") {
$pic = "p_wrees";
}
include("practice/portrait/p_desc.php");

} else if ($cat == "untitled") {
include("p_header.php");
if ($pic == "") {
$pic = "1_s";
}
include("practice/untitled/un_pic.php");

} else if ($cat == "progress") {
include("p_header.php");
if ($pic == "") {
$pic = "l_jsm";
}
include("practice/progress/luna/luna_d.php");


} else {
include("p_header.php");

}
?>
</div>
<div class="mainContentPanel">
<?php
if ($cat == "roam") { print "<a href=\"practice/series/roam/roam_en/$pic.jpg\" target=\"new\" border=\"0\"><img src=\"practice/series/roam/$pic.jpg\"></a>";}
else if ($cat == "bound") { print "<a href=\"practice/series/bound/bound_en/$pic.jpg\" target=\"new\" border=\"0\"><img src=\"practice/series/bound/$pic.jpg\"></a>"; }
else if ($cat == "estate") { print "<a href=\"practice/series/estate/de_en/$pic.jpg\" target=\"new\" border=\"0\"><img src=\"practice/series/estate/$pic.jpg\"></a>"; }
else if ($cat == "portrait") { print "<a href=\"practice/portrait/port_en/$pic.jpg\" target=\"new\" border=\"0\"><img src=\"practice/portrait/$pic.jpg\"></a>"; }
else if ($cat == "untitled"){ print "<br><br><br><br><a href=\"practice/untitled/un_en/$pic.jpg\" target=\"new\" border=\"0\"><img src=\"practice/untitled/$pic.jpg\"></a>"; }
else if ($cat == "progress") { print "<a href=\"practice/progress/luna/luna_en/$pic.jpg\" target=\"new\" border=\"0\"><img src=\"practice/progress/luna/$pic.jpg\"></a>"; }



?>

<?php include("p_foot.php"); ?>

_Aerospace_Eng_
08-06-2008, 02:14 AM
Try this

<?php

$cat = "";
$pic = "";

if (isset($_GET["cat"]) && $_GET["cat"] != "") {
$cat = $_GET["cat"];
} else {
$cat = "";
}
if (isset($_GET["pic"]) && $_GET["pic"] != "") {
$pic = $_GET["pic"];
}

if ($cat == "roam") {
include("p_header.php");
if ($pic == "") {
$pic = "roam";
}
include("practice/series/roam/r_thumb.php");
} else if ($cat == "bound") {
include("p_header.php");
if ($pic == "") {
$pic = "b_mca";
}
include("practice/series/bound/b_thumb.php");
} else if ($cat == "estate") {
include("p_header.php");
if ($pic == "") {
$pic = "de_pers";
include("practice/series/estate/d_thumb.php");
}

} else if ($cat == "portrait") {
include("p_header.php");
if ($pic == "") {
$pic = "p_kirby";
}
include("practice/portrait/p_desc.php");
} else if ($cat == "portrait") {
include("p_header.php");
if ($pic == "") {
$pic = "p_wrees";
}
include("practice/portrait/p_desc.php");

} else if ($cat == "untitled") {
include("p_header.php");
if ($pic == "") {
$pic = "1_s";
}
include("practice/untitled/un_pic.php");

} else if ($cat == "progress") {
include("p_header.php");
if ($pic == "") {
$pic = "l_jsm";
}
include("practice/progress/luna/luna_d.php");


} else {
include("p_header.php");

}
?>
</div>
<div class="mainContentPanel">
<?php
if ($cat == "roam") { print "<a href=\"practice/series/roam/roam_en/$pic.jpg\" target=\"new\" border=\"0\"><img src=\"practice/series/roam/$pic.jpg\"></a>";}
else if ($cat == "bound") { print "<a href=\"practice/series/bound/bound_en/$pic.jpg\" target=\"new\" border=\"0\"><img src=\"practice/series/bound/$pic.jpg\"></a>"; }
else if ($cat == "estate") { print "<a href=\"practice/series/estate/de_en/$pic.jpg\" target=\"new\" border=\"0\"><img src=\"practice/series/estate/$pic.jpg\"></a>"; }
else if ($cat == "portrait") { print "<a href=\"practice/portrait/port_en/$pic.jpg\" target=\"new\" border=\"0\"><img src=\"practice/portrait/$pic.jpg\"></a>"; }
else if ($cat == "untitled"){ print "<br><br><br><br><a href=\"practice/untitled/un_en/$pic.jpg\" target=\"new\" border=\"0\"><img src=\"practice/untitled/$pic.jpg\"></a>"; }
else if ($cat == "progress") { print "<a href=\"practice/progress/luna/luna_en/$pic.jpg\" target=\"new\" border=\"0\"><img src=\"practice/progress/luna/$pic.jpg\"></a>"; }



?>

<?php include("p_foot.php"); ?>
I believe you need to check to see if the $_GET variable is set.

twilight85
08-06-2008, 02:26 AM
Thank you!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum