[PHP] contant /

2010-04-08 Thread Jack
I get a couple of errors like this one for undefined variable:

PHP Notice:  Undefined variable: s_company_name

And this one for undefined contstant

PHP Notice:  Use of undefined constant account_type - assumed 'account_type'

 

I am putting a piece of code from each so that hopefully someone can explain
what I need to do to correct this, I know it still runs OK, but want to
eliminate error/warnings as much as possible.

 

 

CONSTANT CODE:

if($_POST) {

 

 

   if($username  $password)

  {

  f_db_open();

  $q = mysql_query(SELECT * FROM uas_users WHERE
user_email='$username');

  $auth = mysql_fetch_array($q);

 

  if($auth['user_password'] == $password  $auth['user_email'] ==
$username  $auth['account_status'] == Approved)

 {

 

 

 $type = $auth['account_type'];

 

   mysql_query(INSERT INTO logon_log (user, date, time)
VALUES ('$username', NOW(), NOW()));

 

 
f_put_cookie($auth[user_name],$auth[user_email],$auth[account_type],$auth[co
mpany_name]);

 

 

VARIABLE CODE:

function f_option_menu($status_message ) {

global $s_url, $s_logo, $s_logo_h, $s_logo_w;

 

echo 

table border='0' width='100%' cellpadding='0' cellspacing='0'

  tr

td

  img border=0 src='images/.$s_logo.' width=.$s_logo_w.
height=.$s_logo_h.

  font face='Verdana, Arial' size='3'b.$s_company_name.
.$status_message./b/font

 

 

THANKS

 

 

 

Thanks!

Jack

 



Re: [PHP] contant /

2010-04-08 Thread Dan Joseph
On Thu, Apr 8, 2010 at 12:26 PM, Jack jacklistm...@gmail.com wrote:

 I get a couple of errors like this one for undefined variable:

 PHP Notice:  Undefined variable: s_company_name

 And this one for undefined contstant

 PHP Notice:  Use of undefined constant account_type - assumed
 'account_type'


f_put_cookie($auth[user_name],$auth[user_email],$auth[account_type],$auth[co
mpany_name]);

That's your culprit.  You'll need quotes around those.  $auth[username],
user_email, account_type, company_name

Otherwise, it thinks they are constants that haven't been defined:
php.net/define

-- 
-Dan Joseph

www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
Code NEWTHINGS for 10% off initial order

http://www.facebook.com/canishosting
http://www.facebook.com/originalpoetry


Re: [PHP] contant /

2010-04-08 Thread Ashley Sheridan
On Thu, 2010-04-08 at 12:26 -0400, Jack wrote:

 I get a couple of errors like this one for undefined variable:
 
 PHP Notice:  Undefined variable: s_company_name
 
 And this one for undefined contstant
 
 PHP Notice:  Use of undefined constant account_type - assumed 'account_type'
 
  
 
 I am putting a piece of code from each so that hopefully someone can explain
 what I need to do to correct this, I know it still runs OK, but want to
 eliminate error/warnings as much as possible.
 
  
 
 
 
 CONSTANT CODE:
 
 if($_POST) {
 
  
 
 
 
if($username  $password)
 
   {
 
   f_db_open();
 
   $q = mysql_query(SELECT * FROM uas_users WHERE
 user_email='$username');
 
   $auth = mysql_fetch_array($q);
 
  
 
   if($auth['user_password'] == $password  $auth['user_email'] ==
 $username  $auth['account_status'] == Approved)
 
  {
 
  
 
 
 
  $type = $auth['account_type'];
 
  
 
mysql_query(INSERT INTO logon_log (user, date, time)
 VALUES ('$username', NOW(), NOW()));
 
  
 
 
 f_put_cookie($auth[user_name],$auth[user_email],$auth[account_type],$auth[co
 mpany_name]);
 
  
 
 
 
 VARIABLE CODE:
 
 function f_option_menu($status_message ) {
 
 global $s_url, $s_logo, $s_logo_h, $s_logo_w;
 
  
 
 echo 
 
 table border='0' width='100%' cellpadding='0' cellspacing='0'
 
   tr
 
 td
 
   img border=0 src='images/.$s_logo.' width=.$s_logo_w.
 height=.$s_logo_h.
 
   font face='Verdana, Arial' size='3'b.$s_company_name.
 .$status_message./b/font
 
  
 
 
 
 THANKS
 
  
 
 
 
 
 
 Thanks!
 
 Jack
 
  
 

Your function f_option_menu() includes some global variables but nowhere
in that function is s_company_name ever declared, so PHP is throwing an
undefined warning at you.

Also, it appears that you are referencing $_POST variables as globals.
It's recommended that you turn off register_globals, as this can be a
massive security risk if someone overrides one of your variables by
sending their own data at your form. The preferred way is to reference
the variables as $_POST['variable_name']

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] contant /

2010-04-08 Thread Andre Polykanine
Hello Jack,

I have tons of errors like this and now I'm eliminating them, so I'll
tell what to do:
1. Put apostrophes (single quotes) around the array item:
$auth['company_name'] instead of $auth[company_name];
2. (Just a suggestion) It's better to put the SQL tables and
fields between grave accents (backquotes).

-- 
With best regards from Ukraine,
Andre
Skype: Francophile; WlmMSN: arthaelon @ yandex.ru; Jabber: arthaelon @ 
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: m_elensule

- Original message -
From: Jack jacklistm...@gmail.com
To: php-general@lists.php.net php-general@lists.php.net
Date: Thursday, April 8, 2010, 7:26:56 PM
Subject: [PHP] contant /

I get a couple of errors like this one for undefined variable:

PHP Notice:  Undefined variable: s_company_name

And this one for undefined contstant

PHP Notice:  Use of undefined constant account_type - assumed 'account_type'

 

I am putting a piece of code from each so that hopefully someone can explain
what I need to do to correct this, I know it still runs OK, but want to
eliminate error/warnings as much as possible.

 

 

CONSTANT CODE:

if($_POST) {

 

 

   if($username  $password)

  {

  f_db_open();

  $q = mysql_query(SELECT * FROM uas_users WHERE
user_email='$username');

  $auth = mysql_fetch_array($q);

 

  if($auth['user_password'] == $password  $auth['user_email'] ==
$username  $auth['account_status'] == Approved)

 {

 

 

 $type = $auth['account_type'];

 

   mysql_query(INSERT INTO logon_log (user, date, time)
VALUES ('$username', NOW(), NOW()));

 

 
f_put_cookie($auth[user_name],$auth[user_email],$auth[account_type],$auth[co
mpany_name]);

 

 

VARIABLE CODE:

function f_option_menu($status_message ) {

global $s_url, $s_logo, $s_logo_h, $s_logo_w;

 

echo 

table border='0' width='100%' cellpadding='0' cellspacing='0'

  tr

td

  img border=0 src='images/.$s_logo.' width=.$s_logo_w.
height=.$s_logo_h.

  font face='Verdana, Arial' size='3'b.$s_company_name.
.$status_message./b/font

 

 

THANKS

 

 

 

Thanks!

Jack

 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] contant /

2010-04-08 Thread John Black

On 04/08/2010 06:51 PM, Andre Polykanine wrote:
 2. (Just a suggestion) It's better to put the SQL tables and
 fields between grave accents (backquotes).

But if you do that then you will have to remove them again when you 
decide to switch or support PostgreSQL.


--
John
After coming into contact with a religious man I always feel I must wash 
my hands.

[Friedrich Nietzsche]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php