Re: [PHP] Undefined index....

2013-03-15 Thread Jay Blanchard

[snip]

function includeXML($file, $locale, $url, $level = 1) {
 // stuff


$xml = '';
Should work here ...
Since the call below is ADDING to $xml you do need something existing 
to add to so what does that give?

[/snip]

Thanks Lester, that worked. I had just put that in the wrong place. 
*slaps forehead*


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



Re: [PHP] Undefined index....

2013-03-15 Thread Lester Caine

Jay Blanchard wrote:

I have inherited a mess of a home-grown PHP framework that literally fills the
error_log with 100's of thousands of messages each day. First order of business
was rotating the logs, now we are working through each error to solve them. This
is a fairly basic error, but I for the life of me cannot remember what the
solution is.

I have a recursive function that reads from XML files and replaces xi: include
directives. It looks like this -

function includeXML($file, $locale, $url, $level = 1) {
 // stuff


$xml = '';
Should work here ...
Since the call below is ADDING to $xml you do need something existing to add to 
so what does that give?



 while(($line = fgets($fp)) !== false) {
 if($pos === false) {
 $xml .= $line;
 } else {
 includeXML('repository/' . $included, $locale, (int)$level + $pos -
1);
 }
 }
}

Why do I get the notice that $xml is an undefined index? I do not want to
suppress the notice, I just want to take care of it properly. I attempted
setting $xml within the function but then the whole function fails for some
reason in the depths of this hideous framework. Can anyone provide any insight?
TVMIA!


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

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



Re: [PHP] Undefined index....

2013-03-15 Thread Serge Fonville
So basically, $xml is out of scope for this function and you are appending
to a nonexisting variable?

Kind regards/met vriendelijke groet,

Serge Fonville

http://www.sergefonville.nl

Convince Microsoft!
They need to add TRUNCATE PARTITION in SQL Server
https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table


2013/3/15 Jay Blanchard 

> [snip]
>
>  Two questions:
>> Where is $xml defined and where is $pos defined?
>>
>>  [/snip]
>
> $xml is defined in other functions, just not in this function. $pos is
> irrelevant to the question - it is just the string position within the file.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Undefined index....

2013-03-15 Thread Jay Blanchard

[snip]

Two questions:
Where is $xml defined and where is $pos defined?


[/snip]

$xml is defined in other functions, just not in this function. $pos is 
irrelevant to the question - it is just the string position within the 
file.


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



Re: [PHP] Undefined index....

2013-03-15 Thread Serge Fonville
Hi,

Two questions:
Where is $xml defined and where is $pos defined?

HTH

Kind regards/met vriendelijke groet,

Serge Fonville

http://www.sergefonville.nl

Convince Microsoft!
They need to add TRUNCATE PARTITION in SQL Server
https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table


2013/3/15 Jay Blanchard 

> I have inherited a mess of a home-grown PHP framework that literally fills
> the error_log with 100's of thousands of messages each day. First order of
> business was rotating the logs, now we are working through each error to
> solve them. This is a fairly basic error, but I for the life of me cannot
> remember what the solution is.
>
> I have a recursive function that reads from XML files and replaces xi:
> include directives. It looks like this -
>
> function includeXML($file, $locale, $url, $level = 1) {
> // stuff
> while(($line = fgets($fp)) !== false) {
> if($pos === false) {
> $xml .= $line;
> } else {
> includeXML('repository/' . $included, $locale, (int)$level +
> $pos - 1);
> }
> }
> }
>
> Why do I get the notice that $xml is an undefined index? I do not want to
> suppress the notice, I just want to take care of it properly. I attempted
> setting $xml within the function but then the whole function fails for some
> reason in the depths of this hideous framework. Can anyone provide any
> insight? TVMIA!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] Undefined index....

2013-03-15 Thread Jay Blanchard
I have inherited a mess of a home-grown PHP framework that literally 
fills the error_log with 100's of thousands of messages each day. First 
order of business was rotating the logs, now we are working through each 
error to solve them. This is a fairly basic error, but I for the life of 
me cannot remember what the solution is.


I have a recursive function that reads from XML files and replaces xi: 
include directives. It looks like this -


function includeXML($file, $locale, $url, $level = 1) {
// stuff
while(($line = fgets($fp)) !== false) {
if($pos === false) {
$xml .= $line;
} else {
includeXML('repository/' . $included, $locale, (int)$level 
+ $pos - 1);

}
}
}

Why do I get the notice that $xml is an undefined index? I do not want 
to suppress the notice, I just want to take care of it properly. I 
attempted setting $xml within the function but then the whole function 
fails for some reason in the depths of this hideous framework. Can 
anyone provide any insight? TVMIA!


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



Re: [Fwd: Re: [PHP] Undefined Index ...confusion] (RESOLVED)

2009-07-23 Thread Miller, Terion
Thanks


On 7/23/09 9:52 AM, "Kyle Smith"  wrote:

Sorry, list, I did a reply instead of a reply-to-all.  This is what I
sent to "Miller, Terion"

Miller, Terion wrote:
> Thanks for the link Kyle!! Great thing there...(seriously I didn't know...I 
> learn something everyday)
>
> Anyways the link to my script is:  http://pastebin.ca/1504393
>
Your email client is annoying, it doesn't quote.  Haha.

Anyway, so, you're loading up that array with arrays of arrays, here:

   1.
  $position = 1;
   2.

   3.
  while ($row = mysql_fetch_array
  
($result))
   4.
{
   5.
$_SESSION['fullRestaurantList'][$position] = $row;
   6.
$position++;
   7.
}
   8.

   9.
$_SESSION['totalNumberOfRestaurants'] = $position;

So, if you get 7 rows.  Your array will have:

Array => (Row 1 Data)
Array => (Row 2 Data)

.. etc

You do not have ['fullRestaurantList']['ID'].  In the page you're
referencing you use something like
$_SESSION['fullRestaurantList'][$i]['SomeValue'].  I assume $i is the
"Position" in the array, so you likely want to use
$_SESSION['fullRestaurantList'][$i]['ID'] to get the ID field from that row.

If you need a quick dump to better understand what data you have in your
session, try making a page called session_dump.php in the same directory
with this source:



That will give you a good idea of what your session array looks like,
and you should see clearly that ['fullRestaurantList']['ID'] does not exist.

Hope this helps!

- Kyle



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



[Fwd: Re: [PHP] Undefined Index ...confusion]

2009-07-23 Thread Kyle Smith
Sorry, list, I did a reply instead of a reply-to-all.  This is what I 
sent to "Miller, Terion"


Miller, Terion wrote:

Thanks for the link Kyle!! Great thing there...(seriously I didn't know...I 
learn something everyday)

Anyways the link to my script is:  http://pastebin.ca/1504393
  

Your email client is annoying, it doesn't quote.  Haha.

Anyway, so, you're loading up that array with arrays of arrays, here:

  1.
 $position = 1;
  2.
  
  3.

 while ($row = mysql_fetch_array
 ($result))
  4.
   {
  5.
   $_SESSION['fullRestaurantList'][$position] = $row;
  6.
   $position++;
  7.
   }
  8.
   
  9.

   $_SESSION['totalNumberOfRestaurants'] = $position;

So, if you get 7 rows.  Your array will have:

Array => (Row 1 Data)
Array => (Row 2 Data)

.. etc

You do not have ['fullRestaurantList']['ID'].  In the page you're 
referencing you use something like 
$_SESSION['fullRestaurantList'][$i]['SomeValue'].  I assume $i is the 
"Position" in the array, so you likely want to use 
$_SESSION['fullRestaurantList'][$i]['ID'] to get the ID field from that row.


If you need a quick dump to better understand what data you have in your 
session, try making a page called session_dump.php in the same directory 
with this source:




That will give you a good idea of what your session array looks like, 
and you should see clearly that ['fullRestaurantList']['ID'] does not exist.


Hope this helps!

- Kyle


Re: [PHP] Undefined Index ...confusion

2009-07-23 Thread Kyle Smith



Miller, Terion wrote:


On 7/23/09 9:24 AM, "Kyle Smith"  wrote:

Miller, Terion wrote:

I keep getting this error while trying to use the field 'ID' to pass in a url.. 
And it's odd because the query is pulling everything BUT the ID which is the 
first field...

code:



We're going to need to know how the $_SESSION['fullRestaurantList'] gets 
populated.  Also, where do you define $i?  Is $i the ID?  Seemed like you've 
built an array of arrays and you may want 
$_SESSION['fullRestaurantList'][$i]['ID'], or just $i.  This is all speculation 
from the 2 lines of code I've seen though.

- Kyle



The full script is (I have my Entourage email settings on html so I hope this 
displays ok for you all---seems I've been told it turns into a mess in some 
views) :

  
It sure did turn into a big mess.  Could you try using a pastebin 
service?  You should do this as a general best-practice anyway.  Long 
email threads tend to turn people off to helping you.


Go here:
http://pastebin.ca/

Paste your code and select "PHP" for Syntax Highlighting, then click 
submit.  You'll be given a short URL to share with the thread that will 
bring us to an easy-to-read version of your code.


- Kyle


Re: [PHP] Undefined Index ...confusion

2009-07-23 Thread Miller, Terion



On 7/23/09 9:24 AM, "Kyle Smith"  wrote:

Miller, Terion wrote:

I keep getting this error while trying to use the field 'ID' to pass in a url.. 
And it's odd because the query is pulling everything BUT the ID which is the 
first field...

code:



We're going to need to know how the $_SESSION['fullRestaurantList'] gets 
populated.  Also, where do you define $i?  Is $i the ID?  Seemed like you've 
built an array of arrays and you may want 
$_SESSION['fullRestaurantList'][$i]['ID'], or just $i.  This is all speculation 
from the 2 lines of code I've seen though.

- Kyle



The full script is (I have my Entourage email settings on html so I hope this 
displays ok for you all---seems I've been told it turns into a mess in some 
views) :

No values were submitted for the 
search.";  // Unset it so a reload 
of page doesn't redisplay the error  
unset($_SESSION['noVarsSent']);  // 
unset($_SESSION['results']);}   

 // Check if full list of restaurants has been created and stored 
yet// Store full results in $_SESSION to 
limit database hits
if(!isset($_SESSION['fullRestaurantList']))
{  // List not grabbed yet, so run query 
and store in $_SESSION  
//check for rangeif 
(!(isset($rangenum)))  {
  $rangenum = 1;  } 
 // Grab all restaurants in alphabetical order  
$sql = "SELECT restaurants.ID, name, address, 
inDate, inType, notes, critical, cviolations, noncritical FROM restaurants, 
inspections WHERE restaurants.name != '' AND restaurants.ID = inspections.ID 
ORDER BY name;";   $result = 
mysql_query($sql) or die(mysql_error());
//trying to grab it by ranges from the db?  
   $rows = mysql_num_rows($result); 
 $page_rows = 100;  
$last_row = ceil($rows/$page_rows); 
   if ($rangenum < 1)   
 {  $rangenum = 1;  
}  elseif ($rangenum > 
$last_row)  {   
   $rangenum = $last_row;  }
//This sets the 
range to display in our query  $max = 
'limit ' .($rangenum - 1) * $page_rows .',' .$page_rows;

// Process all results into 
$_SESSION array 
   $position = 1;   
 while ($row = mysql_fetch_array($result))  
{  
$_SESSION['fullRestaurantList'][$position] = $row;  
$position++;  } 
   
$_SESSION['totalNumberOfRestaurants'] = $position;  
}  
?> 
   
http://www.news-leader.com/graphics/pixelclear.gif"; width="400" height="1" 
/>
   
   
  Name: 
 
>  

   
Address:  

Re: [PHP] Undefined Index ...confusion

2009-07-23 Thread Kyle Smith

Miller, Terion wrote:

I keep getting this error while trying to use the field 'ID' to pass in a url.. 
And it's odd because the query is pulling everything BUT the ID which is the 
first field...

code:


  
We're going to need to know how the $_SESSION['fullRestaurantList'] gets 
populated.  Also, where do you define $i?  Is $i the ID?  Seemed like 
you've built an array of arrays and you may want 
$_SESSION['fullRestaurantList'][$i]['ID'], or just $i.  This is all 
speculation from the 2 lines of code I've seen though.


- Kyle



[PHP] Undefined Index ...confusion

2009-07-23 Thread Miller, Terion
I keep getting this error while trying to use the field 'ID' to pass in a url.. 
And it's odd because the query is pulling everything BUT the ID which is the 
first field...

code:


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



Re: [PHP] Undefined index error

2009-01-19 Thread Daniel Brown
On Mon, Jan 19, 2009 at 15:39, Jason Pruim  wrote:
>
> Only when you log into certain accounts and view the file after I had made
> changes :P

I figured you had already changed it, but when you're root, you
don't have to log in to other accounts.  ;-P

> What I'm really going for is given this URL:
>
> purl.mysupersite.com/test/mail
>
> "test" refers to a record in the database.
> "mail" refers to a file on the server which is included when "mail" is
> present. Otherwise the main page is used.

So then you'll use mod_rewrite, since Apache needs to tell PHP how
to parse it.  Otherwise, Apache is going to be looking for /test/mail.

#.htaccess:
#
Options -MultiViews

RewriteEngine On

#
## Redirect to remove trailing slashes on extensionless URL requests
# If requested URL ending with slash does not resolve to an existing
directory
RewriteCond %{REQUEST_FILENAME} !-d

#  externally redirect to remove trailing slash.
RewriteRule ^(.+)/$ /index.php?s=$1 [QSA,L]


#
## Externally redirect clients directly requesting .php page URIs to
extensionless URIs
# If client request header contains php file extension
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /[^.]+\.php\ HTTP

# externally redirect to extensionless URI.
RewriteRule ^([^.]+)\.php$ /index.php?s=$1 [QSA,R=301,L]


#
## Internally rewrite extensionless file requests to .php files ##
# If the requested URI does not contain a period in the final path-part
RewriteCond %{REQUEST_URI} !(\.[^./]+)$

#  and if it does not exist as a directory
RewriteCond %{REQUEST_FILENAME} !-d

#  and if it does not exist as a file
RewriteCond %{REQUEST_FILENAME} !-f

#  then add .php to get the actual filename.
RewriteRule (.+) /index.php?s=$1 [QSA,L]

# End .htaccess


You can figure out the rest yourself.  ;-P

-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] Undefined index error

2009-01-19 Thread Jason Pruim


On Jan 19, 2009, at 3:28 PM, Daniel Brown wrote:


On Mon, Jan 19, 2009 at 14:32, Richard Heyes  wrote:
Notice: Undefined index: 2 in /home/raosetc/public_html/purl/p.php  
on line

19

and here is Line 19:

$data = explode("/", $_SERVER['REQUEST_URI']);


   When I view that file, on line 19, I see:

echo <<

Only when you log into certain accounts and view the file after I had  
made changes :P





Are you sure it's an array? Use print_r() or var_dump() on
$_SERVER['REQUEST_URI'] on the preceding line. Just for testing, you
could do this too:

$_SERVER['REQUEST_URI'] = 'It/Works';

...on the preceding line.


   Well, that wouldn't address the issue of the code he gave on the
line reported, but I know what you mean, Richy.  He's turning
$_SERVER['REQUEST_URI'] into an array with explode() if it contains a
forward-slash ("/").

   What would be better in that case would be:

 0 ?
explode('/',$_SERVER['REQUEST_URI']) : $_SERVER['REQUEST_URI'];

if(is_array($data)) {
   // Handle as appropriate.
}
?>

   However, that's not the best option as:

   1.) REQUEST_URI may not (though it should) have *any* forward
slashes in the URI passed to PHP by the HTTP server.
   2.) It leaves too much other stuff to be done.

   Instead, check out:





I'm not positive that does exactly what I want... What I'm really  
going for is given this URL:


purl.mysupersite.com/test/mail

"test" refers to a record in the database.
"mail" refers to a file on the server which is included when "mail" is  
present. Otherwise the main page is used.




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



Re: [PHP] Undefined index error

2009-01-19 Thread ceo

There is no reference to index '2' in that line 19.



What is the next line?



Something which expects at least 3 elements in the URI, perhaps?...

[Hint, hint]



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



Re: [PHP] Undefined index error

2009-01-19 Thread Daniel Brown
On Mon, Jan 19, 2009 at 14:32, Richard Heyes  wrote:
>> Notice: Undefined index: 2 in /home/raosetc/public_html/purl/p.php on line
>> 19
>>
>> and here is Line 19:
>>
>> $data = explode("/", $_SERVER['REQUEST_URI']);

When I view that file, on line 19, I see:

echo << Are you sure it's an array? Use print_r() or var_dump() on
> $_SERVER['REQUEST_URI'] on the preceding line. Just for testing, you
> could do this too:
>
> $_SERVER['REQUEST_URI'] = 'It/Works';
>
> ...on the preceding line.

Well, that wouldn't address the issue of the code he gave on the
line reported, but I know what you mean, Richy.  He's turning
$_SERVER['REQUEST_URI'] into an array with explode() if it contains a
forward-slash ("/").

What would be better in that case would be:

 0 ?
explode('/',$_SERVER['REQUEST_URI']) : $_SERVER['REQUEST_URI'];

if(is_array($data)) {
// Handle as appropriate.
}
?>

However, that's not the best option as:

1.) REQUEST_URI may not (though it should) have *any* forward
slashes in the URI passed to PHP by the HTTP server.
2.) It leaves too much other stuff to be done.

Instead, check out:



-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] Undefined index error

2009-01-19 Thread Jason Pruim


On Jan 19, 2009, at 2:32 PM, Richard Heyes wrote:

Notice: Undefined index: 2 in /home/raosetc/public_html/purl/p.php  
on line

19

and here is Line 19:

$data = explode("/", $_SERVER['REQUEST_URI']);


Hi,

Are you sure it's an array? Use print_r() or var_dump() on
$_SERVER['REQUEST_URI'] on the preceding line. Just for testing, you
could do this too:

$_SERVER['REQUEST_URI'] = 'It/Works';

...on the preceding line.


actually at that point it's not an array... it's just loading  
purl.mysupersite.com/test so REQUEST_URI just contains "test" I just  
want to squash that error until they go to a page in the site :)


I'm thinking I just need to think this one through a little bit and  
I'm sure the solution ill come to me.


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



Re: [PHP] Undefined index error

2009-01-19 Thread Richard Heyes
> Notice: Undefined index: 2 in /home/raosetc/public_html/purl/p.php on line
> 19
>
> and here is Line 19:
>
> $data = explode("/", $_SERVER['REQUEST_URI']);

Hi,

Are you sure it's an array? Use print_r() or var_dump() on
$_SERVER['REQUEST_URI'] on the preceding line. Just for testing, you
could do this too:

$_SERVER['REQUEST_URI'] = 'It/Works';

...on the preceding line.

-- 
Richard Heyes

HTML5 Graphing for Firefox, Chrome, Opera and Safari:
http://www.rgraph.org (Updated January 17th)

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



[PHP] Undefined index error

2009-01-19 Thread Jason Pruim
So sometimes I end up with issues that are so simple I should be able  
to fix it but for some reason I end up asking a stupid question to  
the list... So... Here goes :)


Here is the error:

Notice: Undefined index: 2 in /home/raosetc/public_html/purl/p.php on  
line 19


and here is Line 19:

$data = explode("/", $_SERVER['REQUEST_URI']);


When you first hit the site you to go something like:  
purl.mysupersite.com/YourNameHere


If you went to: purl.mysupersite.com/YourNameHere/ (Notice the  
trailing /) there would be no error...


Now I know it's just a undefined index error and I can safely ignore  
it since it works just fine. All I have to do is turn off the error  
reporting and it's gone... But I want to write good code...


Any Suggestions?


--
Jason Pruim
japr...@raoset.com
616.399.2355





Re: [PHP] Undefined index:

2007-06-16 Thread Stut

WeberSites LTD wrote:
I'm using this code to check if a cookie has a value : 
 
If(!IsSet($HTTP_COOKIE_VARS["LoggedIn"])) 
 
 
In case that this cookie is not set, how can i avoid the 
Undefined index: line in the error log?


The isset function does not give an error if you pass it a non-existant 
variable. Are you sure it's this line that's causing the undefined index 
error?


-Stut

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



Re: [PHP] Undefined index:

2007-06-16 Thread tedd

At 2:37 PM +0200 6/16/07, WeberSites LTD wrote:

I'm using this code to check if a cookie has a value :

If(!IsSet($HTTP_COOKIE_VARS["LoggedIn"])) 


In case that this cookie is not set, how can i avoid the
Undefined index: line in the error log?

berber


berber:

Try this:

$loggedIn = isset($HTTP_COOKIE_VARS["LoggedIn"]) ? 
($HTTP_COOKIE_VARS["LoggedIn"]) : "not logged in";

echo($loggedIn);

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] Undefined index:

2007-06-16 Thread WeberSites LTD
I'm using this code to check if a cookie has a value : 
 
If(!IsSet($HTTP_COOKIE_VARS["LoggedIn"])) 
 
 
In case that this cookie is not set, how can i avoid the 
Undefined index: line in the error log?
 
berber


Re: [PHP] Undefined index error

2007-06-10 Thread Richard Lynch


On Sat, June 9, 2007 11:53 pm, Christian Cantrell wrote:
> I'm getting this error in my Apache log file, and I can't figure out
> why:
>
> Undefined index:  password in /path/to/file.php on line 82
>
> Some searching on Google turned up a bunch of questions, but no
> answers.
> Any idea what this warning message is referring to?

If you use something like:
$_POST['password']
$_COOKIE['password'] // this is a REALLY Bad Idea
$_GET['password'] //bad idea
$_SESSION['password']
.
.
.

but you don't actually *HAVE* a 'password' in the array, then you will
get that error message.

Your assumption that you have some kind of password is invalid.

Check first:

if (isset($whatever['password'])){
  //rest of your code in here.
}

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Undefined index error

2007-06-10 Thread Christian Cantrell

Ah, you're right.  Thanks, Tijnema.

I'm just getting my feet wet with PHP, and you guys are a great help!

Christian

On 6/10/07, Tijnema <[EMAIL PROTECTED]> wrote:


On 6/10/07, Christian Cantrell <[EMAIL PROTECTED]> wrote:
> I'm getting this error in my Apache log file, and I can't figure out
why:
>
> Undefined index:  password in /path/to/file.php on line 82
>
> Some searching on Google turned up a bunch of questions, but no answers.
> Any idea what this warning message is referring to?
>
> Thanks,
> Christian

Yes, you're probably trying to get a value from an array by using a
key that isn't in the array.
Something like this:
 "test", "foo"=>"bar");
$value = $array['password']; // Key "password" doesn't exist!
?>

Check the line number and print out the array with var_dump/print_r to
see what's in the array..

Tijnema
>



Re: [PHP] Undefined index error

2007-06-10 Thread Tijnema

On 6/10/07, Christian Cantrell <[EMAIL PROTECTED]> wrote:

I'm getting this error in my Apache log file, and I can't figure out why:

Undefined index:  password in /path/to/file.php on line 82

Some searching on Google turned up a bunch of questions, but no answers.
Any idea what this warning message is referring to?

Thanks,
Christian


Yes, you're probably trying to get a value from an array by using a
key that isn't in the array.
Something like this:
 "test", "foo"=>"bar");
$value = $array['password']; // Key "password" doesn't exist!
?>

Check the line number and print out the array with var_dump/print_r to
see what's in the array..

Tijnema




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



Re: [PHP] Undefined index error

2007-06-09 Thread Robert Cummings
On Sun, 2007-06-10 at 00:53 -0400, Christian Cantrell wrote:
> I'm getting this error in my Apache log file, and I can't figure out why:
> 
> Undefined index:  password in /path/to/file.php on line 82

Please post the code on that line of the file indicated.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



[PHP] Undefined index error

2007-06-09 Thread Christian Cantrell

I'm getting this error in my Apache log file, and I can't figure out why:

Undefined index:  password in /path/to/file.php on line 82

Some searching on Google turned up a bunch of questions, but no answers.
Any idea what this warning message is referring to?

Thanks,
Christian


Re: [PHP] undefined index and php

2005-11-10 Thread Richard Lynch
On Thu, November 10, 2005 5:54 am, Ross wrote:
> Before someone advises me to 'google' my question. I have and can't
> find a
> PHP.net example either.
>
> I have turned off registered globals and am updating my scripts so
> they work
> but I keep getting an undefined index problem using $_POST
>
> I tried this to set the value...
>
> if (!isset($_POST['heading'])) {
> $_POST ['heading'] = "";
> }
>
> because the following line give the notice 'undefined index'  BEFORE
> the
> submit button has been pressed..
>
> 

This bit of code is getting run BEFORE the submit button has been
pressed.

In that case, $_POST itself is not defined, much less $_POST['heading']

You really shouldn't be stuffing values into $_POST.  Think of it as a
read-only variable that the browser sends TO you.

Here are some options:

OPTION 1:


OPTION 2:


Some people think the ternary operator is "confusing" or "obscure" or
whatever.  Others think it's a perfectly natural operator.  YMMV

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] undefined index and php

2005-11-10 Thread Gustavo Narea

Hello.

[EMAIL PROTECTED] wrote:

why the question mark and the colon? What is the long hang eqivalent.


That's the Ternary operator. Whether you want to get further 
information, go to: 
http://php.net/manual/en/language.operators.comparison.php


Regards.

--
Gustavo Narea.
PHP Documentation - Spanish Translation Team.
Valencia, Venezuela.

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



Re: [PHP] undefined index and php

2005-11-10 Thread Jochem Maas

Robbert van Andel wrote:

The question mark and colon is the equivalent for the iif function.  It's a


'if () ...' is not a function it's a language construct. they are different :-)
for instance 'echo' is also a language construct which is why it does not 
require
brackets e.g.

$space = ' ';
echo "hello",$space,"world";


short hand for if/else.  You start with the expression, and if true, do
what's after the question mark and if false, after the column.

Robbert

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 10, 2005 4:58 AM

To: php-general@lists.php.net
Subject: Re: [PHP] undefined index and php

I have never really used this abreviated format before

why the question mark and the colon? What is the long hang eqivalent.

I turned magic quotes off too.

thanks.

R.
- Original Message - 
From: "Jasper Bryant-Greene" <[EMAIL PROTECTED]>

To: "Ross" <[EMAIL PROTECTED]>
Cc: 
Sent: Thursday, November 10, 2005 12:19 PM
Subject: Re: [PHP] undefined index and php




Ross wrote:


because the following line give the notice 'undefined index'  BEFORE  the




submit button has been pressed..




That's because before the submit button has been pressed, $_POST is empty 
and so 'heading' is indeed an undefined index. Try:


$heading_insert = isset( $_POST['heading'] ) ? stripslashes( 
$_POST['heading'] ) : '';


By the way, while you're switching register_globals off, it might be a 
good idea to also switch off magic_quotes_gpc (the reason you need 
stripslashes() above) and short_open_tag (judging by your use of the 
non-portable 

Jasper








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



RE: [PHP] undefined index and php

2005-11-10 Thread Robbert van Andel
The question mark and colon is the equivalent for the iif function.  It's a
short hand for if/else.  You start with the expression, and if true, do
what's after the question mark and if false, after the column.

Robbert

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 10, 2005 4:58 AM
To: php-general@lists.php.net
Subject: Re: [PHP] undefined index and php

I have never really used this abreviated format before

why the question mark and the colon? What is the long hang eqivalent.

I turned magic quotes off too.

thanks.

R.
- Original Message - 
From: "Jasper Bryant-Greene" <[EMAIL PROTECTED]>
To: "Ross" <[EMAIL PROTECTED]>
Cc: 
Sent: Thursday, November 10, 2005 12:19 PM
Subject: Re: [PHP] undefined index and php


> Ross wrote:
>> because the following line give the notice 'undefined index'  BEFORE  the

>> submit button has been pressed..
>>
>> 
>
> That's because before the submit button has been pressed, $_POST is empty 
> and so 'heading' is indeed an undefined index. Try:
>
> $heading_insert = isset( $_POST['heading'] ) ? stripslashes( 
> $_POST['heading'] ) : '';
>
> By the way, while you're switching register_globals off, it might be a 
> good idea to also switch off magic_quotes_gpc (the reason you need 
> stripslashes() above) and short_open_tag (judging by your use of the 
> non-portable 
> Jasper
>
>
> 

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

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



Re: [PHP] undefined index and php

2005-11-10 Thread ross

I have never really used this abreviated format before

why the question mark and the colon? What is the long hang eqivalent.

I turned magic quotes off too.

thanks.

R.
- Original Message - 
From: "Jasper Bryant-Greene" <[EMAIL PROTECTED]>

To: "Ross" <[EMAIL PROTECTED]>
Cc: 
Sent: Thursday, November 10, 2005 12:19 PM
Subject: Re: [PHP] undefined index and php



Ross wrote:
because the following line give the notice 'undefined index'  BEFORE  the 
submit button has been pressed..





That's because before the submit button has been pressed, $_POST is empty 
and so 'heading' is indeed an undefined index. Try:


$heading_insert = isset( $_POST['heading'] ) ? stripslashes( 
$_POST['heading'] ) : '';


By the way, while you're switching register_globals off, it might be a 
good idea to also switch off magic_quotes_gpc (the reason you need 
stripslashes() above) and short_open_tag (judging by your use of the 
non-portable 

Jasper





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



Re: [PHP] undefined index and php

2005-11-10 Thread Jasper Bryant-Greene

Ross wrote:
because the following line give the notice 'undefined index'  BEFORE  the 
submit button has been pressed..





That's because before the submit button has been pressed, $_POST is 
empty and so 'heading' is indeed an undefined index. Try:


$heading_insert = isset( $_POST['heading'] ) ? stripslashes( 
$_POST['heading'] ) : '';


By the way, while you're switching register_globals off, it might be a 
good idea to also switch off magic_quotes_gpc (the reason you need 
stripslashes() above) and short_open_tag (judging by your use of the 
non-portable 

Jasper

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



[PHP] undefined index and php

2005-11-10 Thread Ross

Before someone advises me to 'google' my question. I have and can't find a 
PHP.net example either.

I have turned off registered globals and am updating my scripts so they work 
but I keep getting an undefined index problem using $_POST

I tried this to set the value...

if (!isset($_POST['heading'])) {
$_POST ['heading'] = "";
}

because the following line give the notice 'undefined index'  BEFORE  the 
submit button has been pressed..



R. 

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



RE: [PHP] undefined index

2005-06-17 Thread Kim Madsen

> -Original Message-
> From: Ross [mailto:[EMAIL PROTECTED]
> Sent: Thursday, June 16, 2005 8:51 PM


> if ($quantity == 0){
> 
> }
>else {
> 
>  $pieces = explode(" ", $quantity);
>$formatted_price = sprintf('%0.2f', $pricecode);
>   echo " cellspacing=\"5\"> width=\"40\">$pieces[0] align=\"left\" width=\"200\">$pieces[1] $pieces[2] $pieces[3]
> $pieces[4] width=\"80\">$formatted_price";
> 
>}
>}
> 
> The trouble is I get a NOTICE that tells me the indexes 1 to 4 have
not
> been defined. how do I do this.

Probably because $quantity IS 0, then the vars used in the else {} is
never set, but still in the script.

Try setting these before the if statement:

$pieces = array(); 
$formatted_price = 0;
$pricecode = 0; // this one is never set? Or set earlier in the script?


--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



Re: [PHP] undefined index

2005-06-16 Thread Philip Hallstrom

I have a bit of code that splices up a cookie into 4 bits so the information
can be displayedin a neat way in a table



if ($quantity == 0){

   }
  else {

$pieces = explode(" ", $quantity);
  $formatted_price = sprintf('%0.2f', $pricecode);
 echo "$pieces[0]$pieces[1] $pieces[2] $pieces[3]
$pieces[4]$formatted_price";

  }
  }

The trouble is I get a NOTICE that tells me the indexes 1 to 4 have not been
defined. how do I do this.


What is the output of:

print_r($pieces) if placed right after the explode() line?  Maybe 
$quantity isn't what you think it is...


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



[PHP] undefined index

2005-06-16 Thread Ross
I have a bit of code that splices up a cookie into 4 bits so the information 
can be displayedin a neat way in a table



if ($quantity == 0){

}
   else {

 $pieces = explode(" ", $quantity);
   $formatted_price = sprintf('%0.2f', $pricecode);
  echo "$pieces[0]$pieces[1] $pieces[2] $pieces[3] 
$pieces[4]$formatted_price";

   }
   }

The trouble is I get a NOTICE that tells me the indexes 1 to 4 have not been 
defined. how do I do this.

R. 

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



Re: [PHP] undefined index: $_FILES || $HTTP_POST_FILES

2004-11-08 Thread Tobias Neumann
On Mon, 08 Nov 2004 15:52:53 +0600, Raditha Dissanayake wrote:

> Quick question: is file uploads enabled on this server and is the 
> temporary directory writable?

Hmm. upload_tmp_dir was unset. The php.ini says that in this case the
systems default tempoary directory is used. So I guessed it would be
/tmp, because php also saves the session data there. Now I set the
upload_tmp_dir explicit to /tmp and it works.

So where on linux systems is the default tempoary directory set?

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



Re: [PHP] undefined index: $_FILES || $HTTP_POST_FILES

2004-11-08 Thread Jason Wong
On Monday 08 November 2004 09:07, Tobias Neumann wrote:

> I have the same script on two webservers with php 4.3.9 and apache 2, both
> with the same php configurations. On one server I can not access
> $_FILES or $HTTP_POST_FILES, although a form with a file has been
> correctly submitted.

Are the httpd.conf config the same as well?

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
"I go on working for the same reason a hen goes on laying eggs."
- H. L. Mencken
*/

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



Re: [PHP] undefined index: $_FILES || $HTTP_POST_FILES

2004-11-08 Thread raditha dissanayake
Tobias Neumann wrote:
Hello!
I have the same script on two webservers with php 4.3.9 and apache 2, both
with the same php configurations. On one server I can not access
$_FILES or $HTTP_POST_FILES, although a form with a file has been
correctly submitted.
 

Quick question: is file uploads enabled on this server and is the 
temporary directory writable?

apache_request_headers() contains:
[Content-Type] => multipart/form-data;
boundary=---207315575716727585901748724465
[Content-Length] => 5779
So php should have received the form data. I can access $_GET and $_POST
without any problem.
$_FILES and $HTTP_POST_FILES do simply not exist, and when I try
to access them I just get an undefined index error, or with print_r() an
empty array.
Regards,
 Tobias Neumann
 


--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] undefined index: $_FILES || $HTTP_POST_FILES

2004-11-08 Thread Marek Kilimajer
Tobias Neumann wrote:
Hello!
I have the same script on two webservers with php 4.3.9 and apache 2, both
with the same php configurations. On one server I can not access
$_FILES or $HTTP_POST_FILES, although a form with a file has been
correctly submitted.
apache_request_headers() contains:
[Content-Type] => multipart/form-data;
boundary=---207315575716727585901748724465
[Content-Length] => 5779
So php should have received the form data. I can access $_GET and $_POST
without any problem.
$_FILES and $HTTP_POST_FILES do simply not exist, and when I try
to access them I just get an undefined index error, or with print_r() an
empty array.
Regards,
  Tobias Neumann
http://sk2.php.net/manual/en/features.file-upload.php
Read the Related Configurations Note and also check enctype attribute of 
your 

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


[PHP] undefined index: $_FILES || $HTTP_POST_FILES

2004-11-08 Thread Tobias Neumann
Hello!

I have the same script on two webservers with php 4.3.9 and apache 2, both
with the same php configurations. On one server I can not access
$_FILES or $HTTP_POST_FILES, although a form with a file has been
correctly submitted.

apache_request_headers() contains:

[Content-Type] => multipart/form-data;
boundary=---207315575716727585901748724465
[Content-Length] => 5779

So php should have received the form data. I can access $_GET and $_POST
without any problem.

$_FILES and $HTTP_POST_FILES do simply not exist, and when I try
to access them I just get an undefined index error, or with print_r() an
empty array.

Regards,
  Tobias Neumann

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



[PHP] Undefined index ????

2004-06-09 Thread Michael Jonsson
Hi
Why do I get an error if the $_SESSION['user_status'] is emty (it's not 
set to anything) ???
in my redhat 9 it did mork, but when I moved to Fedora Core 2 it's not 
working...

Script##
session_start();
echo $_SESSION['user_status'];
#error##
Notice: Undefined index: user_status in 
/var/www/itmdata/include/include.php on line 13


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


Re: [PHP] Undefined index ???

2004-06-09 Thread Torsten Roehr
"John Nichel" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Michael Jonsson wrote:
> > Hi
> >
> > Why do I get an error if the $_SESSION['user_status'] is NULL ???
> >
> >
> > Script##
> > session_start();
> > echo $_SESSION['user_status'];
> >
> >
> > #error##
> > Notice: Undefined index: user_status in
> > /var/www/itmdata/include/include.php on line 13
> >
> >
> >
> > Regards
> > Micke
> >
>
>
> That's not an error.  Three ways to solve this...
>
> 1)  Turn down your error reporting level.
> 2)  Declare your variables before using them
>
> $_SESSION['user_status'] = NULL;
> echo ( $_SESSION['user_status'] );
>
> 3)  Code for variables that may not exist
>
> if ( isset ( $_SESSION['user_status'] ) ) {
> echo ( $_SESSION['user_status'] );
> }
>
> Or any combination of the three.


I would not recommend turning down the error reporting level. This might
lead to unexpected behaviour in your application and makes it hard to back
track errors.

Always develop with error reporting set to E_ALL. You may set a lower level
for your production environment and disable the display of errors:
ini_set('display_errors', 0);

Regards, Torsten Roehr

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



Re: [PHP] Undefined index ???

2004-06-09 Thread John Nichel
Michael Jonsson wrote:
Hi
Why do I get an error if the $_SESSION['user_status'] is NULL ???
Script##
session_start();
echo $_SESSION['user_status'];
#error##
Notice: Undefined index: user_status in 
/var/www/itmdata/include/include.php on line 13


Regards
Micke

That's not an error.  Three ways to solve this...
1)  Turn down your error reporting level.
2)  Declare your variables before using them
$_SESSION['user_status'] = NULL;
echo ( $_SESSION['user_status'] );
3)  Code for variables that may not exist
if ( isset ( $_SESSION['user_status'] ) ) {
echo ( $_SESSION['user_status'] );
}
Or any combination of the three.
--
John C. Nichel
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Undefined index ???

2004-06-09 Thread Michael Jonsson
Hi
Why do I get an error if the $_SESSION['user_status'] is NULL ???
Script##
session_start();
echo $_SESSION['user_status'];
#error##
Notice: Undefined index: user_status in 
/var/www/itmdata/include/include.php on line 13


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


Re: [PHP] undefined index -------- please help !!!!!!!!

2004-03-08 Thread Dominique ANOKRE
OK, but when i use "isset" my request is not executed normally.
I wonder if the fact i use the frames is the problem because with no
changement and without using "isset"
my request run correctly.

Thanks !

- Original Message -
From: "John Nichel" <[EMAIL PROTECTED]>
To: "Dominique ANOKRE" <[EMAIL PROTECTED]>
Cc: "Php List" <[EMAIL PROTECTED]>
Sent: Saturday, March 06, 2004 12:15 PM
Subject: Re: [PHP] undefined index  please help 


> Dominique ANOKRE wrote:
> > on line 66 there is :
> >
> > $date=$_POST["date"];
> >
> > Thanks
>
> $_POST['date'] isn't set.
>
> if ( isset ( $_POST['date'] ) ) {
> $date = $_POST['date'];
> }
>
> --
> By-Tor.com
> It's all about the Rush
> http://www.by-tor.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

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



Re: [PHP] undefined index -------- please help !!!!!!!!

2004-03-06 Thread John Nichel
Dominique ANOKRE wrote:
on line 66 there is :

$date=$_POST["date"];

Thanks
$_POST['date'] isn't set.

if ( isset ( $_POST['date'] ) ) {
$date = $_POST['date'];
}
--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] undefined index -------- please help !!!!!!!!

2004-03-06 Thread Dominique ANOKRE
on line 66 there is :

$date=$_POST["date"];

Thanks

- Original Message -
From: "Chris W. Parker" <[EMAIL PROTECTED]>
To: "Dominique ANOKRE" <[EMAIL PROTECTED]>; "Php List"
<[EMAIL PROTECTED]>
Sent: Friday, March 05, 2004 8:20 PM
Subject: RE: [PHP] undefined index  please help 


Dominique ANOKRE <mailto:[EMAIL PROTECTED]>
on Friday, March 05, 2004 12:19 PM said:

> Undefined index: numcpte in c:\inetpub\wwwroot\rech_haut.php on line
> 66
>
> For information, i have not this error when the file recherche.php is
> a simple file without frames !!!
>
> Please help!!

what is on line 66!?!?

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

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



RE: [PHP] undefined index -------- please help !!!!!!!!

2004-03-05 Thread Chris W. Parker
Dominique ANOKRE 
on Friday, March 05, 2004 12:19 PM said:

> Undefined index: numcpte in c:\inetpub\wwwroot\rech_haut.php on line
> 66 
> 
> For information, i have not this error when the file recherche.php is
> a simple file without frames !!! 
> 
> Please help!!

what is on line 66!?!?

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



[PHP] undefined index -------- please help !!!!!!!!

2004-03-05 Thread Dominique ANOKRE
I have a form which call a php file when click on the submit button :



First this runs correctly when i click on the submit buttom then the file 
recherche.php is executed and the result is displayed.
I modify the design of my pages in order to display result into frames. So i create a 
frameset named recherche.php which contains
two frames "rech_haut.php" and "rech_bas.php".

And when i click on buttom submit in order to display the result i have this notice 
message : 

Undefined index: numcpte in c:\inetpub\wwwroot\rech_haut.php on line 66

For information, i have not this error when the file recherche.php is a simple file 
without frames !!!

Please help!!



RE: [PHP] Undefined Index Errors

2004-02-06 Thread Cameron B. Prince
> 1. put @ in front of each variable, e.g.
>   $adminID = @$_ENV['HTTP_REMOTE_USER'];

This worked very nicely...

Thank you!



> > Hey guys,
> >
> > Here's a chunk of code from the top of a multi-function page I converted
> > from Perl to PHP:
> >
> > $userid   = $_REQUEST['USERID'];# USERID = selected userid
> > $dlist= $_REQUEST['DLIST']; # DLIST = indicates who
> to display
> > $action   = $_REQUEST['ACTION'];# ACTION = indicates approval or
> > denial
> > $more = $_REQUEST['MORE'];  # MORE = ID of person to show
> > details
> > $delete   = $_REQUEST['DELETE'];# DELETE = indicates to
> delete user
> > $ltr  = $_REQUEST['LTR'];   # LTR = start ltr of last name
> > $modpwd   = $_REQUEST['MODPWD'];# MODPWD = indicates
> modifying pwd
> > $expire   = $_REQUEST['EXPIRE'];# EXPIRE = indicates to
> expire pwd
> > $upduser  = $_REQUEST['UPDUSER'];   # UPDUSER = indicates user info
> > updated
> > $denyuser = $_REQUEST['DENYUSER'];  # DENYUSER = indicates user was
> > denied
> > $reason   = $_REQUEST['REASON'];# REASON = Reason user
> was denied
> >
> > $adminID = $_ENV['HTTP_REMOTE_USER'];
> >
> > I'm creating some strings from array elements obviously. The
> issue is, the
> > array elements don't always exist depending on which function you are
> > running. And when they don't, the server log is full of undefined index
> > errors. Is there a way I can avoid these errors without adding a
> > "if(isset(...))" around each one?
> >
> > Thanks,
> > Cameron
> >

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



Re: [PHP] Undefined Index Errors

2004-02-06 Thread John W. Holmes
From: "Cameron B. Prince" <[EMAIL PROTECTED]>

> I'm creating some strings from array elements obviously. The issue is, the
> array elements don't always exist depending on which function you are
> running. And when they don't, the server log is full of undefined index
> errors. Is there a way I can avoid these errors without adding a
> "if(isset(...))" around each one?

Adjust your error_reporting() level so these notices don't show up.

---John Holmes...

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



Re: [PHP] Undefined Index Errors

2004-02-06 Thread Adam Bregenzer
On Fri, 2004-02-06 at 10:51, Cameron B. Prince wrote:
> I'm creating some strings from array elements obviously. The issue is, the
> array elements don't always exist depending on which function you are
> running. And when they don't, the server log is full of undefined index
> errors. Is there a way I can avoid these errors without adding a
> "if(isset(...))" around each one?

If you know which variables are required per 'function' that is being
called wrap an if around these variable declarations in blocks.  You
will still have ifs, but you should have a lot fewer.  If by function
you mean actual functions then you could move these lines to the top of
their respective functions.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Undefined Index Errors

2004-02-06 Thread Marek Kilimajer
You can either:

1. put @ in front of each variable, e.g.
$adminID = @$_ENV['HTTP_REMOTE_USER'];
2. change your error reporting level:
error_reporting(E_ALL ^ E_NOTICE);
Cameron B. Prince wrote:

Hey guys,

Here's a chunk of code from the top of a multi-function page I converted
from Perl to PHP:
$userid   = $_REQUEST['USERID'];# USERID = selected userid
$dlist= $_REQUEST['DLIST']; # DLIST = indicates who to display
$action   = $_REQUEST['ACTION'];# ACTION = indicates approval or
denial
$more = $_REQUEST['MORE'];  # MORE = ID of person to show
details
$delete   = $_REQUEST['DELETE'];# DELETE = indicates to delete user
$ltr  = $_REQUEST['LTR'];   # LTR = start ltr of last name
$modpwd   = $_REQUEST['MODPWD'];# MODPWD = indicates modifying pwd
$expire   = $_REQUEST['EXPIRE'];# EXPIRE = indicates to expire pwd
$upduser  = $_REQUEST['UPDUSER'];   # UPDUSER = indicates user info
updated
$denyuser = $_REQUEST['DENYUSER'];  # DENYUSER = indicates user was
denied
$reason   = $_REQUEST['REASON'];# REASON = Reason user was denied
$adminID = $_ENV['HTTP_REMOTE_USER'];

I'm creating some strings from array elements obviously. The issue is, the
array elements don't always exist depending on which function you are
running. And when they don't, the server log is full of undefined index
errors. Is there a way I can avoid these errors without adding a
"if(isset(...))" around each one?
Thanks,
Cameron
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Undefined Index Errors

2004-02-06 Thread Cameron B. Prince

Hey guys,

Here's a chunk of code from the top of a multi-function page I converted
from Perl to PHP:

$userid   = $_REQUEST['USERID'];# USERID = selected userid
$dlist= $_REQUEST['DLIST']; # DLIST = indicates who to display
$action   = $_REQUEST['ACTION'];# ACTION = indicates approval or
denial
$more = $_REQUEST['MORE'];  # MORE = ID of person to show
details
$delete   = $_REQUEST['DELETE'];# DELETE = indicates to delete user
$ltr  = $_REQUEST['LTR'];   # LTR = start ltr of last name
$modpwd   = $_REQUEST['MODPWD'];# MODPWD = indicates modifying pwd
$expire   = $_REQUEST['EXPIRE'];# EXPIRE = indicates to expire pwd
$upduser  = $_REQUEST['UPDUSER'];   # UPDUSER = indicates user info
updated
$denyuser = $_REQUEST['DENYUSER'];  # DENYUSER = indicates user was
denied
$reason   = $_REQUEST['REASON'];# REASON = Reason user was denied

$adminID = $_ENV['HTTP_REMOTE_USER'];

I'm creating some strings from array elements obviously. The issue is, the
array elements don't always exist depending on which function you are
running. And when they don't, the server log is full of undefined index
errors. Is there a way I can avoid these errors without adding a
"if(isset(...))" around each one?

Thanks,
Cameron

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



Re: [PHP] Undefined index???

2003-12-12 Thread Marek Kilimajer
[EMAIL PROTECTED] wrote:
On Friday 12 December 2003 15:43, [EMAIL PROTECTED] wrote: 


I keep getting this error: 

Notice: Undefined index: tutor_id in /usr/local/.. 

What does "undefined index" exactly mean?? I did a search on the web but 
couldn't find any solutions. 


Basically it means you're trying to access a non-existent item in the array. 


The line that cause this error is as follow: 

$tutor_id = $_POST["tutor_id"]; 


  print_r($_POST) 

will show all the items in $_POST. Is your form set to use the "post" method? 
If not then look in $_GET for your form input data. 

---
yah my form has been set to use the POST method:
Are you sure? You print out this form in this script, but that is not 
how you got here.

echo "";

What could be the problem???Or it could be related to "quoting" problem:

Not at all, remember the notice is displayed before you run this query. 
But always make sure user input is ALWAYS quoted and properly escaped in 
sql queries. The second form is vulnerable in this case.

$sql = mysql_query ("SELECT * FROM tutor WHERE tutor_id='$tutor_id'");
or
$sql = mysql_query ("SELECT * FROM tutor WHERE tutor_id=$tutor_id");


What is the right way to define the variable "$tutor_id" 

--
For reference, I have copied the block of code below:
$dsn = "mysql://root:[EMAIL PROTECTED]/tablename";

//connect to DB
$db = DB::connect ($dsn);
//check for any DB connection errors
   if (DB::isError ($db))
   die ($db->getMessage());
$action = $_GET["action"];

$tutor_id = $_POST['tutor_id'];

print_r($_POST);

if($action == "delete")
{
$sql = mysql_query ("DELETE FROM tutor WHERE tutor_id='$tutor_id'");
$result = $db->query($sql);

if( DB::isError($result) ) {
die ($result->getMessage());
}
echo "Back to main";
}
if($action == "edit")
{
$sql = mysql_query ("SELECT * FROM tutor WHERE tutor_id='$tutor_id'");
$row = mysql_fetch_array($sql);

echo "";
echo "Tutor ID : ".$row['tutor_id']."";
echo "";
echo "Name : ";
echo "Contact No : ";
echo "E-mail : ";
echo "Profile : ";
echo "";
echo "";
}
?>
echo "The entry has been deleted ";

For reference, i have copied the block of code below:

Irin.
 

Jason has explained it to you: you are accessing a variable or an array 
index that has not been defined. Rethink your logic.

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


Re: [PHP] Undefined index???

2003-12-12 Thread irinchiang


On Friday 12 December 2003 15:43, [EMAIL PROTECTED] wrote: 

> I keep getting this error: 
> 
> Notice: Undefined index: tutor_id in /usr/local/.. 
> 
> What does "undefined index" exactly mean?? I did a search on the web but 
> couldn't find any solutions. 

Basically it means you're trying to access a non-existent item in the array. 

> The line that cause this error is as follow: 
> 
> $tutor_id = $_POST["tutor_id"]; 

  print_r($_POST) 

will show all the items in $_POST. Is your form set to use the "post" method? 
If not then look in $_GET for your form input data. 

---
yah my form has been set to use the POST method:

echo "";

What could be the problem???Or it could be related to "quoting" problem:

$sql = mysql_query ("SELECT * FROM tutor WHERE tutor_id='$tutor_id'");
or
$sql = mysql_query ("SELECT * FROM tutor WHERE tutor_id=$tutor_id");



What is the right way to define the variable "$tutor_id" 

--
For reference, I have copied the block of code below:

$dsn = "mysql://root:[EMAIL PROTECTED]/tablename";

//connect to DB
$db = DB::connect ($dsn);
//check for any DB connection errors
   if (DB::isError ($db))
   die ($db->getMessage());

$action = $_GET["action"];

$tutor_id = $_POST['tutor_id'];

print_r($_POST);

if($action == "delete")
{
$sql = mysql_query ("DELETE FROM tutor WHERE tutor_id='$tutor_id'");

$result = $db->query($sql);

if( DB::isError($result) ) {
die ($result->getMessage());
}

echo "Back to main";
}

if($action == "edit")
{
$sql = mysql_query ("SELECT * FROM tutor WHERE tutor_id='$tutor_id'");

$row = mysql_fetch_array($sql);

echo "";
echo "Tutor ID : ".$row['tutor_id']."";
echo "";
echo "Name : ";
echo "Contact No : ";
echo "E-mail : ";
echo "Profile : ";
echo "";
echo "";

}
?>

echo "The entry has been deleted ";


For reference, i have copied the block of code below:


Irin.
 

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



Re: [PHP] Undefined index???

2003-12-12 Thread Jason Wong
On Friday 12 December 2003 15:43, [EMAIL PROTECTED] wrote:

> I keep getting this error:
>
> Notice: Undefined index: tutor_id in /usr/local/..
>
> What does "undefined index" exactly mean?? I did a search on the web but
> couldn't find any solutions.

Basically it means you're trying to access a non-existent item in the array.

> The line that cause this error is as follow:
>
> $tutor_id = $_POST["tutor_id"];

  print_r($_POST)

will show all the items in $_POST. Is your form set to use the "post" method? 
If not then look in $_GET for your form input data.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
No snowflake in an avalanche ever feels responsible.
*/

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



[PHP] Undefined index???

2003-12-12 Thread irinchiang

Hi all, 

I keep getting this error:

Notice: Undefined index: tutor_id in /usr/local/..

What does "undefined index" exactly mean?? I did a search on the web but 
couldn't find any solutions. 

The line that cause this error is as follow:

$tutor_id = $_POST["tutor_id"];

.
.
.
.if($action == "edit")
{
$sql = mysql_query ("SELECT * FROM tutor WHERE tutor_id='$tutor_id'");

$row = mysql_fetch_array($sql);

etc.

Hope to get some help here soon...thanks in advance.

Irin.

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



Re: [PHP] Undefined Index - is this how you "declare" get & post?

2003-10-29 Thread John W. Holmes
Terence wrote:

Since I started using error_reporting(E_ALL), I havent found (in my opinion)
a good way to declare GET and POST variables when getting them from a form
or querystring. I have searched google and the docs for several hours now
without much luck.

if ($HTTP_GET_VARS["i"] == "") {
 include("myfile.php");
}
?>
Is there a better way?
I have tried var $i (only for classes I've discovered)
settype($i, "integer")
Thanks in advance.

isset() is your friend.

if(isset($HTTP_GET_VARS['i']) && $HTTP_GET_VARS['i'] == '')
{ include('myfile.php'); }
This will not trigger any warning, even under E_ALL.

In response to some of the other posts, developing at E_ALL is a good 
idea as it'll help you spot potential problem areas.

Also, even though you have a form element defined, it may not always 
appear in $HTTP_GET_VARS/$_GET (post, etc). One example are checkboxes. 
If no boxes are checked, the variable is never created and this is the 
way to check.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


Re: [PHP] Undefined Index - is this how you "declare" get & post?

2003-10-29 Thread Terence

- Original Message - 
From: "Chris W. Parker" <[EMAIL PROTECTED]>


> Terence 
> on Wednesday, October 29, 2003 4:40 PM said:
>
> > Since I started using error_reporting(E_ALL), I havent found (in my
> > opinion) a good way to declare GET and POST variables when getting
> > them from a form or querystring. I have searched google and the docs
> > for several hours now without much luck.
>
> Why would you want to declare a GET or POST variable in the first place?
> You'd be overwriting whatever value was stored from the form.

error_reporting(E_ALL) tells me that I have an indefined index, but as Jon
Kriek pointed out,
perhaps reporting "all" the errors is not such a "good thing".

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



RE: [PHP] Undefined Index - is this how you "declare" get & post?

2003-10-29 Thread Chris W. Parker
Terence 
on Wednesday, October 29, 2003 4:40 PM said:

> Since I started using error_reporting(E_ALL), I havent found (in my
> opinion) a good way to declare GET and POST variables when getting
> them from a form or querystring. I have searched google and the docs
> for several hours now without much luck.

Why would you want to declare a GET or POST variable in the first place?
You'd be overwriting whatever value was stored from the form.

Also, depending on your version of PHP you should be using $_GET and
$_POST and not $HTTP_GET_VARS or $HTTP_POST_VARS.


hth,
Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

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



[PHP] Undefined Index - is this how you "declare" get & post?

2003-10-29 Thread Terence
Hi List,

Since I started using error_reporting(E_ALL), I havent found (in my opinion)
a good way to declare GET and POST variables when getting them from a form
or querystring. I have searched google and the docs for several hours now
without much luck.



Is there a better way?
I have tried var $i (only for classes I've discovered)
settype($i, "integer")

Thanks in advance.

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



RE: [PHP] Undefined index a different problem

2003-01-07 Thread Matt Schroebel
Try:
echo($GLOBALS[$i]);

Or
echo "{$GLOBALS[$i]}";

This times it's the array in the double quoted strings ...

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




Re: [PHP] Undefined index a different problem

2003-01-07 Thread Marek Kilimajer
These are not errors, but notices, you can get around it using:
if(isset($i) && array_key_exists($GLOBALS, $i)) echo $GLOBALS[$i];

or you might prefer setting error_reporting to not display notices

Mekrand wrote:


thanks but this time it gives 2 error,
undefined variable i,
undefined index i for
$GLOBALS[$i]
"Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 

Mekrand wrote:

   

my problem is,
i have a script that works well before php 4.2.3

its sth like that
{..

for($i=0; $i
...
}

//2nd part
{
echo ("$i");
}

now i changed second part as;

echo("$GLOBALS[i]");

 

should not be

echo("$GLOBALS[$i]");


   

and it gives me notice that undefined index i.
how can i solve this problem?
thanks






 




 



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




Re: [PHP] Undefined index a different problem

2003-01-07 Thread Mekrand
thanks but this time it gives 2 error,
undefined variable i,
undefined index i for
$GLOBALS[$i]
"Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
>
> Mekrand wrote:
>
> >my problem is,
> >i have a script that works well before php 4.2.3
> >
> >its sth like that
> >{..
> >
> > for($i=0; $i >...
> >}
> >
> >//2nd part
> >{
> >echo ("$i");
> >}
> >
> >now i changed second part as;
> >
> >echo("$GLOBALS[i]");
> >
> should not be
>
> echo("$GLOBALS[$i]");
>
>
> >
> >and it gives me notice that undefined index i.
> >how can i solve this problem?
> >thanks
> >
> >
> >
> >
> >
> >
>



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




Re: [PHP] Undefined index a different problem

2003-01-07 Thread Marek Kilimajer


Mekrand wrote:


my problem is,
i have a script that works well before php 4.2.3

its sth like that
{..

for($i=0; $i
should not be

echo("$GLOBALS[$i]");




and it gives me notice that undefined index i.
how can i solve this problem?
thanks




 



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




[PHP] Undefined index a different problem

2003-01-07 Thread Mekrand
my problem is,
i have a script that works well before php 4.2.3

its sth like that
{..

 for($i=0; $ihttp://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] undefined index....property.

2002-12-16 Thread Martin Towell
you didn't send the code snippet for "Undefined index"
however, I think the reason you're getting these errors at home is because
you have a different error_reporting level.

HTH a bit
Martin

[snip]

//filled out info and clicked send.

Notice: Undefined index: license in c:\inetpub\wwwroot\php\config.php on
line 51

Notice: Undefined property: num_rows in
c:\inetpub\wwwroot\php\adcjoin.php on line 67


//

[snip]

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




[PHP] undefined index....property.

2002-12-16 Thread Bruce Levick

Sorry I did not mention.
My local machine is WinXP pro, running php 4.2 and mysql 3.23.

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




[PHP] undefined index....property.

2002-12-16 Thread Bruce Levick
I have just setup my localmachine to see how our site runs on php 4.2.
It currently runs on 4.1 on the server. I am only fairly new to this so
I have come across a slight hurdle.

At first logging in as a user to the database was giving "undefined
variable" error. Have read up on this and fixed it by turning on
register_globals. So that's sweet. Although my other form page is for
joining up, which sends variables to another page and then in turn sends
the info to the database. The info that the user fills out gets passed
ok cept  I get two errors output to the page.

//filled out info and clicked send.

Notice: Undefined index: license in c:\inetpub\wwwroot\php\config.php on
line 51

Notice: Undefined property: num_rows in
c:\inetpub\wwwroot\php\adcjoin.php on line 67


//

This is my action on the submit page






The undefined property is in the
adcjoinpage.php

$db->query("SELECT Username FROM global WHERE
(Username='".$Username."')");

if ($db->num_rows>0){

array_push($error,"Choose another username, this
name is reserved\n");

$flag = 1;

}


///attatched to adcjoin.php

require("connect.php");


//
Config file called on by connect.php contains a license variable.
//

I Am not quite sure why it is outputting these two errors. I have not
changed anything from downloading it off the serverapart from
targeting the database on my local machine now. Is it possibly a session
error??

If anybody has any thoughts please pass them on.

Cheers Bruce

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




[PHP] Undefined index:

2002-10-01 Thread Voisine

Hi,

I'm learning php from a book but because of global off I have have
several "Undefined index" message! I don't want to change the default
setting in my php.ini because I want to learn the good way.
What I'm doing wrong?

Undefined index: categorie
if ($_POST['categorie'] == "New") {

Undefined index: categorie
$query = "SELECT DISTINCT animalName FROM animal WHERE
animalType='{$_REQUEST['categorie']}' ORDER BY animalName";


Undefined index: categorie
echo "No name in {$_POST['categorie']}\n";

Undefined index: categorie
echo "\n";

Regards!



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




Re: [PHP] Undefined index, Undefined variable, Undefined constant....

2002-09-06 Thread Meltem Demirkus

I had the say problem,
try this
if($_POST['update'] == "Update")
{
someting to do...

}

- Original Message -
From: "Jay Blanchard" <[EMAIL PROTECTED]>
To: "'Jens Winberg'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, September 06, 2002 5:12 PM
Subject: RE: [PHP] Undefined index, Undefined variable, Undefined
constant


> [snip]
> I'm having trouble with the newest version of PHP (4.2.2).
> For example in a page I'm using the following code:
> if ($_GET['action'] == "logout") {
>file://do something
> }
> [/snip]
>
> As a quick troubleshooting method echo or print $_GET['action'] to see
what,
> if anything, is contained there. I would also like to see more than;
>
> ...log_message reports: PHP Notice:  Undefined index:  action in
>
> HTH!
>
> Jay
>
> Here I am. Now what were your other two wishes?
>
> *
> * Texas PHP Developers Conf  Spring 2003*
> * T Bar M Resort & Conference Center*
> * New Braunfels, Texas  *
> * Contact [EMAIL PROTECTED]   *
> *   *
> * Want to present a paper or workshop? Contact now! *
> *
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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




RE: [PHP] Undefined index, Undefined variable, Undefined constant....

2002-09-06 Thread Jay Blanchard

[snip]
I'm having trouble with the newest version of PHP (4.2.2).
For example in a page I'm using the following code:
if ($_GET['action'] == "logout") {
   //do something
}
[/snip]

As a quick troubleshooting method echo or print $_GET['action'] to see what,
if anything, is contained there. I would also like to see more than;

...log_message reports: PHP Notice:  Undefined index:  action in

HTH!

Jay

Here I am. Now what were your other two wishes?

*
* Texas PHP Developers Conf  Spring 2003*
* T Bar M Resort & Conference Center*
* New Braunfels, Texas  *
* Contact [EMAIL PROTECTED]   *
*   *
* Want to present a paper or workshop? Contact now! *
*



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




[PHP] Undefined index, Undefined variable, Undefined constant....

2002-09-06 Thread Jens Winberg


I'm having trouble with the newest version of PHP (4.2.2).
For example in a page I'm using the following code:
if ($_GET['action'] == "logout") {
   //do something
}

But I'm getting an error message that says:
...log_message reports: PHP Notice:  Undefined index:  action in

Ealier (other versions of PHP) I have succesfully used the above code, but do 
I now have to rewrite the code like this:
if (isset($_GET['action']) AND $_GET['action'] == "logout") {
   //do something
}

Or am I totally wrong?
This was just one example when I'm getting the message "Undefined index" or " 
Undefined variable" etc. A lot of code which has previously worked is now 
giving me loads of headache since I have to rewrite everything.

Please, I need some help.


my email: [EMAIL PROTECTED]


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




Re: [PHP] Undefined index error

2002-08-19 Thread Michael Sweeney

If you try to access a form variable that hasn't been set, you get an
undefined index. Try checking with something like 
if(isset($_POST['SortBy'])) {
   // do something with 'SortBy'
}

In any case, you'll get the undefined index warning anytime you try to
read an array index that hasn't been set.

..michael..

On Mon, 2002-08-19 at 14:49, Shu Chow wrote:
> I'm using the superglobal $_POST array to access URL 
> parameters passed to my page. I was getting undefined 
> constant errors in my error_log file, and found that I 
> needed to quote the variables in the array. 
>   $_POST['SortBy'] etc. Now, it appears that I've just 
> traded the undefined constant errors for undefined index 
> warnings. Everytime a page hits a page with url 
> parameters, it triggers a warning in the error_log file. 
> What's triggering these undefined index errors? I suppose 
> I could lower the logging level in php.ini, but I'd rather 
> code properly than to hide the problem. Thanks!




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




[PHP] Undefined index error

2002-08-19 Thread Shu Chow

I'm using the superglobal $_POST array to access URL 
parameters passed to my page. I was getting undefined 
constant errors in my error_log file, and found that I 
needed to quote the variables in the array. 
  $_POST['SortBy'] etc. Now, it appears that I've just 
traded the undefined constant errors for undefined index 
warnings. Everytime a page hits a page with url 
parameters, it triggers a warning in the error_log file. 
What's triggering these undefined index errors? I suppose 
I could lower the logging level in php.ini, but I'd rather 
code properly than to hide the problem. Thanks!

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




Re: [PHP] Undefined Index

2002-08-02 Thread Chris Hewitt

Jrgen wrote:

>
>$op = $_GET['op'];
>switch ( $op )
>
>PHP shoots a Notice Message telling me that there is an undefined index
>Undefined index: act in g:\apache_web\intern\looney\index.php on line 177
>
If there is not a get variable in the url you will get the warning.

>Ok, am i correct in assuming that it pops this message because $op is not
>defined as anything yet?
>
Yes,

>
>If so,should i always just do this
>
>$_POST['op'] = '';
>$op = $_GET['op'];
>switch ( $op )
>{
>//Code here
>}
>
If there is not a get variable callled "op" you should still get the 
warning.

>$op = isset($_GET['op']);
>switch ( $op )
>{
>//Code here
>}
>
Now $op will be a boolean assigned the value true (if there is a get 
variable called "op" in the url) or false if not. As $op will have a 
value then there is no warning.

What I tend to do when I have an optional item of data is:

if (isset($_GET["op"])) [
$op = $_GET["op"];
}
else
{
$op = "no value";// set to something you can test for in 
your switch statement.
}
though there may be a better way.

>
>Best regards from Vienna,
>Jrgen
>
.. thanks, and best regards to you from Essex, England.

HTH
Chris



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




[PHP] Undefined Index

2002-08-02 Thread Jürgen

It's me again, i don't mean to be a bugger, but i really like to learn as
much as possible, that's why i ask (or will ask so many questions).

Consider the following (i shortened this a lot, but it will do the trick)

$op = $_GET['op'];
switch ( $op )
{
 case "admin":
  DoLogin();
  break;

 default:
  ShowHomepage();
  break;
}

PHP shoots a Notice Message telling me that there is an undefined index
Undefined index: act in g:\apache_web\intern\looney\index.php on line 177

This accects the code shown above.

Ok, am i correct in assuming that it pops this message because $op is not
defined as anything yet?

If so,should i always just do this

$_POST['op'] = '';
$op = $_GET['op'];
switch ( $op )
{
//Code here
}

Or would it be better and more space efficient to do this
$op = isset($_GET['op']);
switch ( $op )
{
//Code here
}
Cause if i do that the Notice Message dissapears for some reason i yet fail
to grab.
I would really appreciate if somebody could explain to me why the Notice
dissapears when using isset(), and also what is the best method to use
rather then the two shown above?
How do you guys&girls handle this?

Thanks a lot in advance for your time and patience!

Best regards from Vienna,
Jürgen




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




RE: [PHP] Undefined index?

2001-07-11 Thread Philip Olson


If one has :

  $arr = array('a','b','c');

And calls upon the following :

  $arr[b]   (as opposed to $arr['b'])

Then the following will result :

Warning: Use of undefined constant b - assumed 'b' in ./tmp.php on line 13
Warning: Undefined index: b in ./tmp.php on line 13

Always use quotes around the keys/indexes within associative arrays
otherwise the constant is looked for first and unexpected results are
possible.  Now if we have (which you most likely did) :

  $arr['d']

Then we get the following as index 'd' does not exist within the array :

Warning: Undefined index: d in ./tmp.php on line 13

A similar error is created when doing this :

  echo $iamnotset;

  if ($iamnotset) {

Which results in :

Warning: Undefined variable: iamnotset in ./tmp.php on line 11

Using something similar to isset() helps combat that :

  if (isset($iamnotset)) {


All of the above errors (Notices) are of the E_NOTICE type.  If E_NOTICE
is turned on within the error_reporting setting within php.ini (or via a
call to the error_reporting() function or ...), then you'll see it
otherwise you will not.  I'm not sure why Notices say "Warning: ..." but
they do :-)

Typically one turns errors up during development, and down during
production use.  And, it's not uncommon to see this question come about
within various support forums/lists for various PHP applications.

Regards,
Philip


> > -Original Message-
> > From: Ivo Stoykov [mailto:[EMAIL PROTECTED]]
> > Sent: 11 iulie 2001 17:21
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] Undefined index?
> > 
> > 
> > Hi everybody
> > 
> > Does anybody knows what means "Undefined index" error? I 
> > couldn't find it in
> > docs neither in php online doc site.
> > 
> > Thank you
> > 
> > Ivo
> > 
> > 
> > 
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: 
> > [EMAIL PROTECTED]
> > 
> > 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Undefined index?

2001-07-11 Thread Adrian Ciutureanu

If I know well, "Undefined index" is a warning, not an error.
If you have
error_reporting = E_ALL
in php.ini (not error_reporting = E_ALL & ~E_NOTICE)
$a = array('a' => 'xxx', 'b' => 'yyy');
and you try to access $a['c'], then PHP will report that you are trying
to access an undefined index array.


> -Original Message-
> From: Ivo Stoykov [mailto:[EMAIL PROTECTED]]
> Sent: 11 iulie 2001 17:21
> To: [EMAIL PROTECTED]
> Subject: [PHP] Undefined index?
> 
> 
> Hi everybody
> 
> Does anybody knows what means "Undefined index" error? I 
> couldn't find it in
> docs neither in php online doc site.
> 
> Thank you
> 
> Ivo
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: 
> [EMAIL PROTECTED]
> 
> 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Undefined index?

2001-07-11 Thread Ivo Stoykov

Hi everybody

Does anybody knows what means "Undefined index" error? I couldn't find it in
docs neither in php online doc site.

Thank you

Ivo



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]