Jump to content

Help - PHP Notice: Undefined variable: color


carjunky

Recommended Posts

Im running php5.1.6  on rhel and im getting a ton of error notices, but the script is working....  I coloered the code within the php code so you can find the errors.  anyone know what i need to do to fix this?

 

things like this.

 

[error]  PHP Notice:  Undefined variable: atext in /home/public_html/bannerexchange/admin/cats.php on line 43, referer: http://www..com/banner

[error]  PHP Notice:  Undefined variable: rtext in /home/public_html/bannerexchange/admin/cats.php on line 47, referer: http://www..com/bannerexchange/admin/account_add.php

[error]  PHP Notice:  Undefined variable: etext in /home/public_html/bannerexchange/admin/cats.php on line 82, referer: http://www..com/bannerexchange/admin/account_add.php

[error]  PHP Notice:  Undefined variable: color in /home/public_html/bannerexchange/admin/cats.php on line 99, referer: http://www..com/bannerexchange/admin/account_add.php

 

 

heres the code page:

 

<?

session_start();

if (session_is_registered("valid_admin")) {

include "../config/config.php";

$page = 7;

if ($newcat == 1) {

if (!$addcat) {

$atext = "<font color=#CC0000><b>Category Entry Is Blank</b></font>";

} else {

$ncheck = mysql_query("select * from idevban_cats where cat = '$addcat'");

if (mysql_num_rows($ncheck)) {

$atext = "<font color=#CC0000><b>Category Already Exists</b></font>";

} else {

mysql_query("insert into idevban_cats (cat) values ('$addcat')");

$atext = "<font color=#CC0000><b>Category Added<font></b>"; } } }

if ($remove == 1) {

$get = mysql_query("select cat from idevban_accounts where cat = '$remcat'");

if (mysql_num_rows($get)) {

$rtext = "<font color=#CC0000><b>Category Not Empty</b></font>";

} else {

$get2 = mysql_query("select * from idevban_cats");

$num = mysql_num_rows($get2);

if ($num == 1) {

$rtext = "<font color=#CC0000><b>1 Category Required</b></font>";

} else {

mysql_query("delete from idevban_cats where id = '$remcat'");

$rtext = "<font color=#CC0000><b>Category Removed<font></b>"; } } }

if ($edcat == 1) {

$echeck = mysql_query("select * from idevban_cats where cat = '$edname'");

$ex = mysql_num_rows($echeck);

if ($ex > 0) {

$etext = "<font color=yellow><b>Category Already Exists</b></font>";

} else {

mysql_query("update idevban_cats set cat = '$edname' where id = '$katid'");

$etext = "<font color=yellow><b>Category Updated</b></font>"; } }

include("templates/header.php");

?>

<div align="center"><table border="0" cellspacing="1" width="98%">

<tr><td width="100%" class="admin_cells_dark" colspan="2"><font color="#FFFFFF"> <b>Manage Categories</b></font>

</td></tr><tr><td width="50%" class="admin_cells_light">

<div align="center"><center><table border="0" cellpadding="0" cellspacing="0" width="100%">

<tr><td width="35%"><b> Add A Category</b> </td>

<td width="65%" align="right"> <? if ($atext) { print $atext; } ?> </td>

</tr></table></center></div></td><td width="50%" class="admin_cells_light">

<div align="center"><center><table border="0" cellpadding="0" cellspacing="0" width="100%">

<tr><td width="45%"><b> Remove A Category</b></td>

<td width="55%" align="right"> <? if ($rtext) { print $rtext; } ?> </td>

</tr></table></center></div></td></tr><tr>

<td width="50%" align="center" class="admin_cells_light_alt">

<div align="center"><table border="0" cellspacing="0" width="100%">

<form method=POST action=cats.php><input type=hidden name=newcat value=1>

<tr><td width="100%"><div align="center">

<table border="0" cellspacing="0" width="100%" cellpadding="2">

<tr><td width="100%" height="15" colspan="3"></td></tr>

<tr><td width="25%"> Cat Name: </td><td width="50%">

<input type="text" name="addcat" size="15" maxlength="25">

</td><td width="25%"><input type=submit value="Add It!">

</td></form></tr><tr><td width="100%" height="15" colspan="3"></td></tr>

</table></div></td></tr></table></div></td>

<td width="50%" align="center" class="admin_cells_light_alt">

<div align="center"><table border="0" cellspacing="0" width="100%">

<form method=POST action=cats.php><input type=hidden name=remove value=1>

<tr><td width="100%"><div align="center">

<table border="0" cellspacing="0" width="100%" cellpadding="2">

<tr><td width="100%" height="15" colspan="2"></td></tr>

<tr><td width="60%" align=right><select size="1" name="remcat">

<?

$catnames = mysql_query("select * from idevban_cats order by cat");

if (mysql_num_rows($catnames)) {

while ($qry = mysql_fetch_array($catnames)) {

$catid=$qry['id'];

$catname=$qry['cat'];

print "<option value='$catid'>$catname</option>\n"; } }

?>

</select></td><td width="40%"><input type=submit value="Remove">

</td></form></tr><tr><td width="100%" height="15" colspan="2"></td></tr>

</table></div></td></tr></table></div></td></tr></table></div>

<BR><div align="center"><table border="0" cellspacing="1" width="98%">

<tr><td width="100%" class="admin_cells_dark" colspan="4">

<div align="center"><center><table border="0" cellpadding="0" cellspacing="0" width="100%">

<tr><td width="50%"> <font color=white><b>Edit Existing Categories</b></font>

</td><td width="50%" align="right"><b><?if ($etext) { print $etext; } ?></b>  </td>

</tr></table></center></div></td></tr>

<tr>

<td width="35%" class="admin_cells_light"> <b>Category Name</b></td>

<td width="15%" class="admin_cells_light"> <b>Accounts</b></td>

<td width="30%" class="admin_cells_light"> <b>Edit Name</b></td>

<td width="20%" class="admin_cells_light" align="right"><b>Action  </b></td>

</tr>

<?

$getlist = mysql_query("select * from idevban_cats order by cat");

$listrows = mysql_num_rows($getlist);

if ($listrows > 0) {

while ($listinfo = mysql_fetch_array($getlist)) {

$catid = $listinfo['id'];

$catname = $listinfo['cat'];

$cknums = mysql_query("select id from idevban_accounts where cat = $catid");

$howmanyhere = mysql_num_rows($cknums);

if (!$color) {

$color = "class=admin_cells_light";

} else {

$color = ""; }

print "<form method=POST action=cats.php><input type=hidden name=edcat value=1><input type=hidden name=katid value=\"$catid\">";

print "<tr class=admin_cells_light_alt><td width=35% $color> $catname</td>";

print "<td width=15% $color> $howmanyhere</td>";

print "<td width=30% $color> <input type=text name=edname value=\"$catname\" size=20></td>";

print "<td width=20% align=right $color><input type=\"submit\" value=\"Edit Name\">  </td></form></tr>";

 

} } else {

print "<tr><td colspan=4 class=admin_cells_light><BR><BR><center><b>No Categories To List</b></center><BR><BR><BR></td></tr>"; }

?>

</table></div>

<? include("templates/footer.php"); } else { header("Location: login.php"); } ?>

Link to comment
Share on other sites

well i did use the code at first but then the color coding wouldnt work... so i had to go default to make it easy to find the lines...  Thanks for your imput.

 

Here are the peices out of the code.  up top the code sectiosn are coloer to make it easier to find them in the code bit.

 

[error]  PHP Notice:  Undefined variable: atext in /home/public_html/bannerexchange/admin/cats.php on line 43, referer: http://www..com/banner


<? if ($atext) { print $atext; } ?>

 

 

[error]  PHP Notice:  Undefined variable: etext in /home/public_html/bannerexchange/admin/cats.php on line 82, referer: http://www..com/bannerexchange/admin/account_add.php

<? if ($rtext) { print $rtext; } ?>

 

 

[error]  PHP Notice:  Undefined variable: color in /home/public_html/bannerexchange/admin/cats.php on line 99, referer: http://www..com/bannerexchange/admin/account_add.php


if (!$color) {
$color = "class=admin_cells_light";
} else {
$color = ""; }

 

 

 

Link to comment
Share on other sites

Thanks a lot guys....  I noticed that if i turn the error checking off in the php.ini the logs wouldn't be 136m....  but i kinda wanted to fix the issues, since this is all code from a bannerexchange script i bought and i now see why its not for sale any more....

 

but if i iron out these bugs  (no pun intended) it will work great.

 

Thank you.

Link to comment
Share on other sites

Personally, I'd leave the error checking on if your developing.  You could turn error checking off and the errors would disappear, or you

could prefix the check with '@' eg.

 

if ( @!$color )

 

But this isn't good code, and you should be aiming to see and eliminate _all_ errors and notices if you want to do a good job :-)

Link to comment
Share on other sites

I agree... phpzone, ideally i should be able to run with error checking / logging on, I now it is nanoseconds but it there is error in the code php the server stubbles, since its not right.

 

I'm about to try and repair the abundance of errors im finding.... thank you all again.

Link to comment
Share on other sites

Damn this code is buggy.

 

I'm now getting these errors.

Undefined variable: update

I tried something like if ( isset($update ==1)) but didnt work...

if ($update == 1) {
mysql_query("update idevban_setup set site_name = '$site_name', site_url = '$site_url', admin_email = '$admin_email', size_1 = '$size_1', size_2 = '$size_2', limit_banners = '$limit_banners', ratio = '$ratio', done = 1");
$utag = "Configuration Updated"; }

if ($update == 2) {
mysql_query("update idevban_setup set approve_accts = '$approve_accts', notify = '$notify', ini_creds = '$ini_creds', use_url = '$use_url', url_text = '$url_text', paypal = '$pp', paypal_address = '$ppe', shownum = '$shownum', expire = '$expire'");
$utag = "Options Updated"; }
include "../config/config.php";
include("templates/header.php");

 

 

 

PHP Notice:  Use of undefined constant idevbanx - assumed 'idevbanx' in /home/public_html/bannerexchange/display.php on line 31, referer:

PHP Notice:  Undefined index:  idevbanx in /home/public_html/bannerexchange/display.php on line 31, referer:

if (($_COOKIE[idevbanx] != $id) && (!$ipe)) {
setcookie ("idevbanx",$id, time()+$expire);
if ($stats == 1) { if ($ratio == 1) { include("sections/sct_3.php"); }
elseif ($ratio != 1) { include("sections/sct_4.php"); }
mysql_query("update idevban_banners set views=views+1 where num = $number");
} elseif ($stats == 0) { include("sections/sct_5.php"); }
} else { include("sections/sct_6.php"); }
mysql_query("update idevban_accounts set ip = '$uip' where id = $id");
print "<a href=$install_url/click.php?goto=$pick&source=$id&click=$number target=_blank><img src=$banner border=0 width=$size_1 height=$size_2></a>";
?>

 

 

Undefined index:  ip in /home/public_html/bannerexchange/config/config.php on line 27, referer:

$rip=$cfg['ip'];

 

Undefined index:  $valid_user in /home/public_html/bannerexchange/config/config.php on line 28, referer:

ORG CODE...
$logged= "$valid_user"; 

I tried...
$logged=$cfg['valid_user']; 

 

Whole page...

<? include("/home/public_html/bannerexchange/config/database.php");

// #### DO NOT EDIT BELOW THIS LINE ####
$setup = mysql_query("select * from idevban_setup"); 
$cfg = mysql_fetch_array($setup);
$site_name=$cfg['site_name'];
$site_url=$cfg['site_url'];
$admin_email=$cfg['admin_email'];
$size_1=$cfg['size_1'];
$size_2=$cfg['size_2'];
$url_text=$cfg['url_text'];
$use_url=$cfg['use_url'];
$approve_accts=$cfg['approve_accts'];
$ini_creds=$cfg['ini_creds'];
$pp=$cfg['paypal'];
$ppe=$cfg['paypal_address'];
$limit_banners=$cfg['limit_banners'];
$ratio=$cfg['ratio'];
if ($ratio == 2) { $sc = 1;
} elseif ($ratio == 3) { $sc = 2;
} elseif ($ratio == 4) { $sc = 3;
} elseif ($ratio == 1) { $sc = 1; }
$notify=$cfg['notify'];
$done=$cfg['done'];
$shownum=$cfg['shownum'];
$expire=$cfg['expire'];
$rip=$cfg['ip'];
$logged= "$valid_user'; 


?>

 

 


 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.