Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-11-2012, 01:54 PM   PM User | #1
fail
Regular Coder

 
Join Date: Dec 2009
Location: Hong Kong
Posts: 118
Thanks: 8
Thanked 0 Times in 0 Posts
fail is an unknown quantity at this point
"Use of undefined constant" and $_POST['aaa']

I wanted to update the company server from XAMPP 1.73 to 1.81 today, but thought, well, just do it at home first. And bongo, nothing works!

PHP Code:
// Sample #1:

// Notice: Use of undefined constant date - assumed 'date' in C:\xampp\htdocs\bom3\scams\rthk.php on line 49

$date = ($_POST['date']);

// Sample #2:

//Notice: Undefined index: flg in C:\xampp\htdocs\bom3\scams\tool.php on line 23
//Notice: Undefined index: flg in C:\xampp\htdocs\bom3\scams\tool.php on line 24

if($_POST['flg'] == 'ugg' ) {$bbb 'selected';} ELSE {$bbb '';}
if(
$_POST['flg'] == 'uggi' ) {$bbbi 'selected';} ELSE {$bbbi '';} 
I get the message when I land on the page and the forms aren't filled.

I think it may be related to isset, or the lack of it. Hope to get some hints here.

Last edited by fail; 12-12-2012 at 03:07 AM..
fail is offline   Reply With Quote
Old 12-11-2012, 02:27 PM   PM User | #2
Redcoder
Regular Coder

 
Redcoder's Avatar
 
Join Date: May 2012
Location: /dev/couch
Posts: 309
Thanks: 2
Thanked 46 Times in 45 Posts
Redcoder has a little shameless behaviour in the past
You might as well as have an IF check because the $date is probably messing things up in some code somewhere else which is still being executed whether $_POST['date'] has anything or not.
__________________
For professional Hosting and Web design.....


NetEssentials.co.uk
Redcoder is offline   Reply With Quote
Old 12-11-2012, 02:52 PM   PM User | #3
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
This will not throw an undefined constant notice:
PHP Code:
// Sample #1:

// Notice: Use of undefined constant date - assumed 'date' in C:\xampp\htdocs\bom3\scams\rthk.php on line 49

$date = ($_POST['date']); 
'date' has been properly identified as a string. Look elsewhere for this error for which you want to find the (undefined) constant date in use.

PHP Code:
// Sample #2:

//Notice: Undefined index: flg in C:\xampp\htdocs\bom3\scams\tool.php on line 23
//Notice: Undefined index: flg in C:\xampp\htdocs\bom3\scams\tool.php on line 24

if($_POST['flg'] == 'ugg' ) {$bbb 'selected';} ELSE {$bbb '';}
if(
$_POST['flg'] == 'uggi' ) {$bbbi 'selected';} ELSE {$bbbi '';} 
This one simply has no offset under the name 'flg'. Check it with isset before attempting to read it.

Given the names in your filepaths here and the comparison criteria there, I'll sure raise question to future help requests.
Fou-Lu is offline   Reply With Quote
Old 12-12-2012, 02:59 AM   PM User | #4
fail
Regular Coder

 
Join Date: Dec 2009
Location: Hong Kong
Posts: 118
Thanks: 8
Thanked 0 Times in 0 Posts
fail is an unknown quantity at this point
Quote:
Originally Posted by Fou-Lu View Post
Given the names in your filepaths here and the comparison criteria there, I'll sure raise question to future help requests.
..it's a little tool for tracking scam stores that I use for some time. Nothing sinister. Just the move to the latest XAMPP messed things a little up.

Now time to learn more about 'isset'.....
fail is offline   Reply With Quote
Old 12-12-2012, 03:01 AM   PM User | #5
fail
Regular Coder

 
Join Date: Dec 2009
Location: Hong Kong
Posts: 118
Thanks: 8
Thanked 0 Times in 0 Posts
fail is an unknown quantity at this point
Quote:
Originally Posted by Redcoder View Post
You might as well as have an IF check because the $date is probably messing things up in some code somewhere else which is still being executed whether $_POST['date'] has anything or not.
I presume the problem is that the date ain't set in the form when it first opens. Hence, blank forms seem to cause trouble in the latest XAMPP (or at least with a fresh installed XAMPP).
fail is offline   Reply With Quote
Old 12-15-2012, 04:36 AM   PM User | #6
fail
Regular Coder

 
Join Date: Dec 2009
Location: Hong Kong
Posts: 118
Thanks: 8
Thanked 0 Times in 0 Posts
fail is an unknown quantity at this point
Solved the problem by using isset for each error at the beginning of the page:

PHP Code:
if (!isset($_POST['rthk']))   {    $_POST['rthk'] = ""; } 
Another way is to change error_reporting = in xampp\php\php.ini

But maybe a better way is to leave it in php.ini at the default error_reporting = E_ALL | E_STRICT and and use on your page i.e. error_reporting("E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR");

I am aware that it's better to have all errors reported and just write better code.
fail is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:52 PM.


Advertisement
Log in to turn off these ads.