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