Re: [PHP] Array keys referencing value from another array key???

2004-06-06 Thread Marek Kilimajer
Gerard Samuel wrote:
Not sure if the subject was worded correctly, but
I was looking to see if this (or something like it) is possible.
$array = array('key_1' = 'This is some text',
'key_2' = 'b' .  $array['key_1'] . '/b'
  );
And the array structure would be something like -
array('key_1' = 'This is some text',
 'key_2' = 'bThis is some text/b')
Just wanted to see if it were possible, as my attempts were futile.
Its not a requirement on my end, just wanted to see if it were possible... :)
Thanks
It is possible in 2 steps:
1. create the array:
$array = array('key_1' = 'This is some text');
2. Add the second key:
$array['key_2'] = 'b' .  $array['key_1'] . '/b';
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] array key starting with digit ending with string

2004-05-27 Thread Larry Brown
I have an unusual situation where I have to communicate with an MS based
soap server.  They have named one of their variables with a name leading
with a 1 such as 1variable.  Nusoap loads the variable descriptions from the
wsdl document and compares the variable names I am trying to send with the
ones listed in the wsdl.  In this process my sent to the function is
something like $data =
array('thisvar'=$myFirstVar,'thatvar'=$mySecondVar,'1othervar'=$myLastVar
).  Later when the variable names are cycled through on a loop the following
test is used...

if($data[$currentVarNameInCycle])
{
do something
}

Is there some way force the recognition of the key when it leads with a
digit?

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



Re: [PHP] array key starting with digit ending with string

2004-05-27 Thread Matt Matijevich
[snip]
if($data[$currentVarNameInCycle])
{
do something
}

Is there some way force the recognition of the key when it leads with
a
digit?
[/snip]


not sure I follow 100% but you could use a regular expression to
detemine if it starts with a string.

if (preg_match('/^\d/',$array_key)) {
//do something
}

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



Re: [PHP] array key starting with digit ending with string

2004-05-27 Thread Matt Matijevich
[snip]
not sure I follow 100% but you could use a regular expression to
detemine if it starts with a string.

if (preg_match('/^\d/',$array_key)) {
//do something
}
[/snip]

I mean starts with a digit, sorry for 2 emails.  I should proofread.

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



[PHP] Array Question

2004-05-02 Thread Jason Williard
I am using the following array and function in the template for my website.
It works great, but I want to to be better.  I would to make it so the last
item displayed looks differently than the others, but I have been unable to
figure out how to distinguish the last item.

When displayed, the crumbs look like:

SITENAME » RANDOM » ITEM

I would like ITEM to look differently.  Can anyone tell me how to modify the
select ITEM?

// CRUMBS ARRAY
$crumbs = array(
  array( RANDOM, RANDOM_URL ),
  array( ITEM, ITEM_URL )
  );

// CRUMBS FUNCTION
function breadCrumbs($crumbs) {

 if ( count($crumbs)  0 ) {
  $spacer   =  span
style=\color:#94cf42;font-size:15px;font-weight:bold;\raquo;/span ;
  $breadCrumbs  = a href=\URL/\SITE_NAME/a\n;

   foreach( $crumbs as $crumb ) {
   if ( count($crumb) == 2 ) {
$breadCrumbs .=  $spacera href=\$crumb[1]\$crumb[0]/a\n;
   }

  }

 echo !-- ### BREADCRUMBS STARTS HERE
### --\n;
 echo span class=\breadcrumbs\\n;
 echo $breadCrumbs;
 echo /span\n;
 echo !--  BREADCRUMBS ENDS HERE
 --\n;
 }
}

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



Re: [PHP] Array Problem

2004-04-18 Thread Don Read

On 16-Apr-2004 Flavio Fontana wrote:
 Hi
 
 I have i Problem i got a variable a=2351 now i need to create an
 array out of this variable 
 a[0]=1
 a[1]=3
 a[2]=5
 a[3]=1
 
 I have an idea to use the modulo function an do some Math but im sure
 there is a nicer way of solving my prob
 

$a = preg_split('||', $a, -1, PREG_SPLIT_NO_EMPTY);

Regards,
-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



[PHP] Array Sorting Headaches

2004-04-18 Thread Burhan Khalid
Greetings everyone :

  Having a hard time with this one. I have a multi-dim array 
$foo[$x][$y]['key'], where $x and $y are numeric. Here is some sample data :

Array
(
[$x] = Array
(
[0] = Array
(
[invoiceid] = 11842
[product] = myproduct
[domain] = foo.net
[expires] = February 28, 2004
)
[1] = Array
(
[invoiceid] = 10295
[product] = myotherproduct
[domain] = foo.net
[expires] = December 9, 2003
)
[2] = Array
(
[invoiceid] = 10202
[product] = product1
[domain] = foo.bar
[expires] = January 19, 2003
)
[3] = Array
(
[invoiceid] = 10005
[product] = product2
[domain] = foo.bar
[expires] = December 11, 2002
)
)
)
I need to filter the results so that I get the latest expiry date for 
each product.  The expires field actually contains a timestamp.  So for 
the sample array above, the resultant array would have only keys 0 and 
2, filtering out all the rest.  There are around 180+ main entries, with 
any number of sub entries, but each sub entry has the same four keys.

Any ideas? Getting a rather large headache mulling over this.

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


[PHP] Array Problem

2004-04-17 Thread Flavio Fontana
Hi

I have i Problem i got a variable a=2351 now i need to create an array out of this 
variable 
a[0]=1
a[1]=3
a[2]=5
a[3]=1

I have an idea to use the modulo function an do some Math but im sure there is a nicer 
way of solving my prob

thx Flavio

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



Re: [PHP] Array Problem

2004-04-17 Thread Richard Harb
That's how you could do it ...

$ar = array();

$len = strlen($a);
for ($i = 0; $i  $len; ++$i) {
$ar[] = $a{$i};
}

HTH

Richard



Friday, April 16, 2004, 11:00:49 PM, you wrote:

 Hi

 I have i Problem i got a variable a=2351 now i need to create an array out of this 
 variable
 a[0]=1
 a[1]=3
 a[2]=5
 a[3]=1

 I have an idea to use the modulo function an do some Math but im
 sure there is a nicer way of solving my prob

 thx Flavio

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



Re: [PHP] Array Problem

2004-04-17 Thread Arthur Radulescu
 That's how you could do it ...
 
 $ar = array();
 
 $len = strlen($a);
 for ($i = 0; $i  $len; ++$i) {
 $ar[] = $a{$i};
 }

If I remember well strlen is used for checking the length of a string...


Arthur



Looking for a job!? Use the smart search engine!!
Find a Job from Millions WorldWide... 
http://search.jobsgrabber.com


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



Re: [PHP] Array Problem

2004-04-17 Thread Daniel Clark
How about count()

That's how you could do it ...

$ar = array();

$len = strlen($a);
for ($i = 0; $i  $len; ++$i) {
$ar[] = $a{$i};
}

HTH

Richard

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



Re: [PHP] Array Problem

2004-04-17 Thread Richard Harb
Saturday, April 17, 2004, 7:38:46 PM, Arthur Radulescu wrote:

 That's how you could do it ...
 
 $ar = array();
 
 $len = strlen($a);
 for ($i = 0; $i  $len; ++$i) {
 $ar[] = $a{$i};
 }

 If I remember well strlen is used for checking the length of a string...

It does ...
I didn't look closely enough :(
So .. the var has to be converted to str first ... or use a temp var
converted to string ...

except of course someone comes up with a better method of solving the
problem at hand.



just for reference: the original problem (as I now understand it) was
how to 'convert' a number into an array ...


Friday, April 16, 2004, 11:00:49 PM, Flavio Fontana wrote:

 Hi

 I have i Problem i got a variable a=2351 now i need to create an array out of this 
 variable
 a[0]=1
 a[1]=3
 a[2]=5
 a[3]=1

 I have an idea to use the modulo function an do some Math but im
 sure there is a nicer way of solving my prob

 thx Flavio

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



Re: [PHP] Array Problem

2004-04-17 Thread Tom Rogers
Hi,

Saturday, April 17, 2004, 7:00:49 AM, you wrote:
FF Hi

FF I have i Problem i got a variable a=2351 now i need to create an array out of this 
variable
FF a[0]=1
FF a[1]=3
FF a[2]=5
FF a[3]=1

FF I have an idea to use the modulo function an do some Math but
FF im sure there is a nicer way of solving my prob

FF thx Flavio


If you treat the variable as a string it is already an array of
characters

try echo $a{0};

-- 
regards,
Tom

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



Re: [PHP] Array problem

2004-03-22 Thread Firman Wandayandi
Hi noginn,

$columntotals[$count] = $columntotals[$count] + $sum;
 ^-^
   ERROR HERE

Seem you tried to assign columntotal[index]  with itself and you never
defined it. You should tried this one.

= $columntotals[$count] = $sum;

Is right?

Sorry, I confuse with your words total of totals?

Good Luck,
Firman

- Original Message -
From: noginn [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 22, 2004 12:33 AM
Subject: [PHP] Array problem


 This has been confusing me a little for a few hours now.

 Heres a snip of my code which is causing the problem:

 $content = table border='0' cellspacing='0' cellpadding='5'\n;
 $content .= tr\n;
 $content .= tdnbsp;/td\n;

 $tasks = new dbconnect;
 $tasks-connect();
 $tasks-query(SELECT tid, tname FROM tasks);
 while(list($tid, $tname) = $tasks-fetch_rows()) {
 $content .= td valign='top' align='center'span
 class='highlight'$tname/span/td\n;
 }
 $content .= tdnbsp;/td\n;
 $content .= /tr\n;

 $projects = new dbconnect;
 $projects-connect();
 $projects-query(SELECT pid, pname FROM projects);

* $columntotals = array();*
 $colour = 0;

 while(list($pid, $pname) = $projects-fetch_rows()) {
 $tasks-data_seek(0);
 $rowtotal = 0;
 $count = 0;
 if ($colour % 2) {
 $bgcolour = #FF;
 }
 else {
 $bgcolour = #F9F9F9;
 }
 $colour++;
 $content .= tr\n;
 $content .= td valign='top' align='center'span
 class='highlight'$pname/span/td\n;

 while(list($tid, $tname) = $tasks-fetch_rows()) {
 $logs = new dbconnect;
 $logs-connect();
 $logs-query(SELECT SUM(hours) from logs WHERE pid = '$pid'
 AND tid = '$tid' AND date = '$sdate' AND date = '$edate');
 list($sum) = $logs-fetch_rows();

 if (!$sum) {
 $sum = 0;
 }

 $rowtotal = $rowtotal + $sum;
 *$columntotals[$count] = $columntotals[$count] + $sum;*
 $count++;

 $content .= td bgcolor='$bgcolour'
 align='center'$sum/td\n;
 }
 $content .= td align='center'b$rowtotal/b/td\n;
 }
 $content .= /tr\n;
 $content .= tr\n;
 $content .= tdnbsp;/td\n;

 $sumofcolumntotals = 0;

 for ($i=0; $isizeof($columntotals); $i++)
 {
 $sumofcolumntotals = $sumofcolumntotals + $columntotals[$i];
 $content .= td align='center'b$columntotals[$i]/b/td\n;
 }

 $content .= td align='center'b$sumofcolumntotals/b/td\n;
 $content .= /tr\n;
 $content .= /table\n;

 I have made the lines inwhich I know are causing problems in bold.
 Basicly, I am creating a report of some data and need to count up totals
 of each column and then again total the totals if you get me.
 Here is the errors I am getting.
 *Notice*: Undefined offset: 0 in
 *C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
 *Notice*: Undefined offset: 1 in
 *C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
 *Notice*: Undefined offset: 2 in
 *C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
 *Notice*: Undefined offset: 3 in
 *C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58

 *Now I understand in a way why its happening, because im trying to
 insert into $columntotals something which isnt valid, but I can't think
 of a way to stop this at the moment.
 Hope to hear soon, thanks in advance guys.

 -noginn

 --
 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] Array problem

2004-03-22 Thread noginn
Ye that is true, however to create the totals of each columns I had to 
somehow do this.
I have fixed the problem in a way, but it was probably a very crude way 
of doing so.

   $rowtotal = $rowtotal + $sum;
   if(!empty($columntotals[$count])) {
   $columntotals[$count] = $columntotals[$count] + $sum;
   }
   else {
   $columntotals[$count] = $sum;
   }
   $count++;
So now it won't try and add itself if it is empty.
But if anyone has more ideas of how I can create a cleaner piece of code 
then please let me know! :)

-noginn

Firman Wandayandi wrote:

Hi noginn,

$columntotals[$count] = $columntotals[$count] + $sum;
^-^
  ERROR HERE
Seem you tried to assign columntotal[index]  with itself and you never
defined it. You should tried this one.
= $columntotals[$count] = $sum;

Is right?

Sorry, I confuse with your words total of totals?

Good Luck,
   Firman
- Original Message -
From: noginn [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 22, 2004 12:33 AM
Subject: [PHP] Array problem
 

This has been confusing me a little for a few hours now.

Heres a snip of my code which is causing the problem:

   $content = table border='0' cellspacing='0' cellpadding='5'\n;
   $content .= tr\n;
   $content .= tdnbsp;/td\n;
   $tasks = new dbconnect;
   $tasks-connect();
   $tasks-query(SELECT tid, tname FROM tasks);
   while(list($tid, $tname) = $tasks-fetch_rows()) {
   $content .= td valign='top' align='center'span
class='highlight'$tname/span/td\n;
   }
   $content .= tdnbsp;/td\n;
   $content .= /tr\n;
   $projects = new dbconnect;
   $projects-connect();
   $projects-query(SELECT pid, pname FROM projects);
  * $columntotals = array();*
   $colour = 0;
   while(list($pid, $pname) = $projects-fetch_rows()) {
   $tasks-data_seek(0);
   $rowtotal = 0;
   $count = 0;
   if ($colour % 2) {
   $bgcolour = #FF;
   }
   else {
   $bgcolour = #F9F9F9;
   }
   $colour++;
   $content .= tr\n;
   $content .= td valign='top' align='center'span
class='highlight'$pname/span/td\n;
   while(list($tid, $tname) = $tasks-fetch_rows()) {
   $logs = new dbconnect;
   $logs-connect();
   $logs-query(SELECT SUM(hours) from logs WHERE pid = '$pid'
AND tid = '$tid' AND date = '$sdate' AND date = '$edate');
   list($sum) = $logs-fetch_rows();
   if (!$sum) {
   $sum = 0;
   }
   $rowtotal = $rowtotal + $sum;
   *$columntotals[$count] = $columntotals[$count] + $sum;*
   $count++;
   $content .= td bgcolor='$bgcolour'
align='center'$sum/td\n;
   }
   $content .= td align='center'b$rowtotal/b/td\n;
   }
   $content .= /tr\n;
   $content .= tr\n;
   $content .= tdnbsp;/td\n;
   $sumofcolumntotals = 0;

   for ($i=0; $isizeof($columntotals); $i++)
   {
   $sumofcolumntotals = $sumofcolumntotals + $columntotals[$i];
   $content .= td align='center'b$columntotals[$i]/b/td\n;
   }
   $content .= td align='center'b$sumofcolumntotals/b/td\n;
   $content .= /tr\n;
   $content .= /table\n;
I have made the lines inwhich I know are causing problems in bold.
Basicly, I am creating a report of some data and need to count up totals
of each column and then again total the totals if you get me.
Here is the errors I am getting.
*Notice*: Undefined offset: 0 in
*C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
*Notice*: Undefined offset: 1 in
*C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
*Notice*: Undefined offset: 2 in
*C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
*Notice*: Undefined offset: 3 in
*C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58
*Now I understand in a way why its happening, because im trying to
insert into $columntotals something which isnt valid, but I can't think
of a way to stop this at the moment.
Hope to hear soon, thanks in advance guys.
-noginn

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





 




[PHP] Array problem

2004-03-21 Thread noginn
This has been confusing me a little for a few hours now.

Heres a snip of my code which is causing the problem:

   $content = table border='0' cellspacing='0' cellpadding='5'\n;
   $content .= tr\n;
   $content .= tdnbsp;/td\n;
  
   $tasks = new dbconnect;
   $tasks-connect();
   $tasks-query(SELECT tid, tname FROM tasks);
   while(list($tid, $tname) = $tasks-fetch_rows()) {
   $content .= td valign='top' align='center'span 
class='highlight'$tname/span/td\n;
   }
   $content .= tdnbsp;/td\n;
   $content .= /tr\n;
  
   $projects = new dbconnect;
   $projects-connect();
   $projects-query(SELECT pid, pname FROM projects);
  
  * $columntotals = array();*
   $colour = 0;
  
   while(list($pid, $pname) = $projects-fetch_rows()) {
   $tasks-data_seek(0);
   $rowtotal = 0;
   $count = 0;
   if ($colour % 2) {
   $bgcolour = #FF;
   }
   else {
   $bgcolour = #F9F9F9;
   }
   $colour++;
   $content .= tr\n;
   $content .= td valign='top' align='center'span 
class='highlight'$pname/span/td\n;
  
   while(list($tid, $tname) = $tasks-fetch_rows()) {
   $logs = new dbconnect;
   $logs-connect();
   $logs-query(SELECT SUM(hours) from logs WHERE pid = '$pid' 
AND tid = '$tid' AND date = '$sdate' AND date = '$edate');
   list($sum) = $logs-fetch_rows();
  
   if (!$sum) {
   $sum = 0;
   }
  
   $rowtotal = $rowtotal + $sum;
   *$columntotals[$count] = $columntotals[$count] + $sum;*
   $count++;
  
   $content .= td bgcolor='$bgcolour' 
align='center'$sum/td\n;
   }
   $content .= td align='center'b$rowtotal/b/td\n;
   }
   $content .= /tr\n;
   $content .= tr\n;
   $content .= tdnbsp;/td\n;
  
   $sumofcolumntotals = 0;
  
   for ($i=0; $isizeof($columntotals); $i++)
   {
   $sumofcolumntotals = $sumofcolumntotals + $columntotals[$i];
   $content .= td align='center'b$columntotals[$i]/b/td\n;
   }

   $content .= td align='center'b$sumofcolumntotals/b/td\n;
   $content .= /tr\n;
   $content .= /table\n;
I have made the lines inwhich I know are causing problems in bold. 
Basicly, I am creating a report of some data and need to count up totals 
of each column and then again total the totals if you get me.
Here is the errors I am getting.
*Notice*: Undefined offset: 0 in 
*C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
*Notice*: Undefined offset: 1 in 
*C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
*Notice*: Undefined offset: 2 in 
*C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
*Notice*: Undefined offset: 3 in 
*C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58

*Now I understand in a way why its happening, because im trying to 
insert into $columntotals something which isnt valid, but I can't think 
of a way to stop this at the moment.
Hope to hear soon, thanks in advance guys.

-noginn

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


Re: [PHP] array $_POST problem

2004-03-17 Thread Joey Kelly
On Tuesday 16 March 2004 12:16, thou spake:
 You're the Joey Kelly who runs the LUG in NoLA, yes?

Yes, that's me. Have you been to one of our meetings lately? We redid our 
website recently: http://www.nolug.org

Thanks for saying hi :-)

snip

 Upon post, you need to get materials as such:

 $materials = $_POST['materials'];

That looks interesting (using the , etc.) I'll have to look into that.

What the problem ended up being was bad syntax. I was using 

$materials[quantity][1] = $_POST[$materials][quantity][1];

instead of

$materials[quantity][1] = $_POST[materials][quantity][1];

...using a variable instead of a string to reference the array.

snip
 Personally, I'd rename your form elements to:

 $materials[$item][quantity]
 $materials[$item][price]
 $materials[$item][description]

 Chris

Excellent idea. In truth, I just picked up this project again after 1.5 years, 
so I expect to find other newbie mistakes in it.

FYI, the project (WebInvoicer) is listed on my projects page, and I expect 
to release a new version of it (I'm refactoring it completely, and it will 
have the MySQL backend, etc.) in a few weeks. I'll probably post it on 
freshmeat, as well.

Thanks to all who offered their suggestions :-)

-- 


Joey Kelly
 Minister of the Gospel | Linux Consultant 
http://joeykelly.net


I may have invented it, but Bill made it famous.
 --- David Bradley, the IBM employee that invented CTRL-ALT-DEL

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



[PHP] Array to String conversion error

2004-03-16 Thread Alex Hogan
Hi All,

 

I have a function that gets a single field from a mssql db. That field
contains data that is then parsed out to represent a survey's results.

 

The function;

function quesresults(){

$query = SELECT sur_ans

   FROM au_survey;

$result = MSSQL_QUERY($query) or die(Can not execute query
$query. );

$row = mssql_fetch_array($result);

$thearray = explode('__', $row); - This is line 40

$i = 1;

foreach($thearray as $topelement){

foreach(explode('--', $topelement) as $element){

echo $element;

echo br;

}

echo question $i; 

echo br;

$i++;

}

}

 

When I call the function I get;

Notice: Array to string conversion in \WWW\mypath\srvyclass.inc.php on line
40
Array
question 1

 

What am I missing?

 

 

alex hogan

 



** 
The contents of this e-mail and any files transmitted with it are 
confidential and intended solely for the use of the individual or 
entity to whom it is addressed.  The views stated herein do not 
necessarily represent the view of the company.  If you are not the 
intended recipient of this e-mail you may not copy, forward, 
disclose, or otherwise use it or any part of it in any form 
whatsoever.  If you have received this e-mail in error please 
e-mail the sender. 
** 




RE: [PHP] Array to String conversion error

2004-03-16 Thread Chris W. Parker
Alex Hogan mailto:[EMAIL PROTECTED]
on Tuesday, March 16, 2004 9:48 AM said:

 $row = mssql_fetch_array($result);
 
 $thearray = explode('__', $row); - This is line 40

$row is an entire array. you don't explode an entire array, you only
explode the contents of an element of an array.

print_r($row) will give you some clues.

you'll need to access a specific element within the array. like:

$thearray = explode('__', $row[0][0]);

 What am I missing?

unless i'm wrong, the above.



chris.

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



[PHP] array $_POST problem

2004-03-16 Thread Joey Kelly
Hello,

I have a SuSE 9.0 Linux server running PHP and Apache2 (my phpinfo() data is 
at http://redfishnetworks.com/~jkelly/test.php), and my problem is this:

I've got a sticky problem that I need to solve. I've just turned on 
register_globals in my PHP php.ini file, and therefore have to run my form 
variables through $_POST:

$variable = $_POST[$variable];
echo $variable;

The problem I'm having is that the script Im trying to refactor worked great 
before I turned register_globals off. The script posts an array, and I can't 
seem to figure out how to $_POST the array.

Here is the script with register_globals OFF (this is on my old server, by the 
way, running SuSE 7.3), as you can see the script works fine with 
register_globals off:
http://joeykelly.net/materials.php

Here is the script with register_globals ON:
http://redfishnetworks.com/~jkelly/materials.php
Notice the huge nested array at the bottom when you click [SUBMIT]? That's my 
trouble.

In both cases, changing the extension from .php to .phps shows you the source 
code. As you can see, above the form I've tried several attempts to access 
the data, all of which seem to fail.

My question: What am I doing wrong? I suspect that I'm having trouble with 
nested arrays, etc.. The thing that bothers me is that the data is available 
(see the array printout at the bottom?).

If I can't make this work, I'm going to have to resort to munging a bunch of 
scalars ($quantity1, $quantity2, etc.), which to me is an awful kludge that 
I'd rather not sign my name to.

Thanks for any help.




-- 


Joey Kelly
 Minister of the Gospel | Linux Consultant 
http://joeykelly.net


I may have invented it, but Bill made it famous.
 --- David Bradley, the IBM employee that invented CTRL-ALT-DEL

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



Re: [PHP] array $_POST problem

2004-03-16 Thread Richard Davey
Hello Joey,

Tuesday, March 16, 2004, 6:16:34 PM, you wrote:

JK I have a SuSE 9.0 Linux server running PHP and Apache2 (my phpinfo() data is
JK at http://redfishnetworks.com/~jkelly/test.php), and my problem is this:

JK I've got a sticky problem that I need to solve. I've just turned on
JK register_globals in my PHP php.ini file, and therefore have to run my form
JK variables through $_POST:

If you don't know in what way PHP sends the POST data, then the best
solution is simply to view it:

?
  echo pre;
  print_r($_POST);
  echo /pre;
?

(Or you can var_dump the whole thing)

By looking at the structure like this you'll soon see how to access
the values inside of it rather than second-guessing all the time.

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

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



RE: [PHP] array $_POST problem

2004-03-16 Thread Chris W. Parker
Joey Kelly mailto:[EMAIL PROTECTED]
on Tuesday, March 16, 2004 10:17 AM said:

 The problem I'm having is that the script Im trying to refactor
 worked great before I turned register_globals off. The script posts
 an array, and I can't seem to figure out how to $_POST the array.

the script posts an array, and you can't figure out how to $_POST the
array?



 Here is the script with register_globals OFF (this is on my old
 server, by the way, running SuSE 7.3), as you can see the script
 works fine with register_globals off:
 http://joeykelly.net/materials.php

why don't you just turn register_globals off again?




chris.

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



Re: [PHP] array $_POST problem

2004-03-16 Thread Chris Boget
You're the Joey Kelly who runs the LUG in NoLA, yes?

 I've got a sticky problem that I need to solve. I've just turned on
 register_globals in my PHP php.ini file, and therefore have to run my form
 variables through $_POST:
 $variable = $_POST[$variable];
 echo $variable;

Or you can use extract();

 The problem I'm having is that the script Im trying to refactor worked
great
 before I turned register_globals off. The script posts an array, and I
can't
 seem to figure out how to $_POST the array.

It seems like the array is posted just fine.

 In both cases, changing the extension from .php to .phps shows you the
source
 code. As you can see, above the form I've tried several attempts to access
 the data, all of which seem to fail.

How is it failing?  Looking at the source, you are definitely on the right
track.

 My question: What am I doing wrong? I suspect that I'm having trouble with
 nested arrays, etc.. The thing that bothers me is that the data is
available
 (see the array printout at the bottom?).

Upon post, you need to get materials as such:

$materials = $_POST['materials'];

to list out the quantity, you can do any the following:

foreach( $materials['quantity'] as $quantity ) {
  echo $quantity . 'br';
}
foreach( $materials['description'] as $description ) {
  echo $description . 'br';
}

for( $i = 0; $i  5; $i++ ) {
  echo $materials['description'][$i] . '::' . $materials['quantity'][$i] .
'br';
}

Personally, I'd rename your form elements to:

$materials[$item][quantity]
$materials[$item][price]
$materials[$item][description]

Chris

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



RE: [PHP] Array to String conversion error

2004-03-16 Thread Alex Hogan
 $row is an entire array. you don't explode an entire array, you only
 explode the contents of an element of an array.
 
 print_r($row) will give you some clues.
 
 you'll need to access a specific element within the array. like:
 
 $thearray = explode('__', $row[0][0]);

That was it... Thanks Chris.


alex


** 
The contents of this e-mail and any files transmitted with it are 
confidential and intended solely for the use of the individual or 
entity to whom it is addressed.  The views stated herein do not 
necessarily represent the view of the company.  If you are not the 
intended recipient of this e-mail you may not copy, forward, 
disclose, or otherwise use it or any part of it in any form 
whatsoever.  If you have received this e-mail in error please 
e-mail the sender. 
** 




[PHP] Array Question

2004-02-28 Thread Jason Williard
I would like to be able to search an array for a match the a specific
variable.  So far, I have been trying to use preg_grep but am not getting
the results that I want.

Basically, I would have a variable: $url = domain.com

I would like to search an array to see if the value of the variable $url
exists in this array.  The array would look like:

$archives = array( domain.com,domain2.com);

As for the results of the search, I just need a simple yes/no 1/0 response.
What would be the best method of handling this?


Thank You,
Jason Williard

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



Re: [PHP] Array Question

2004-02-28 Thread Michal Migurski
I would like to search an array to see if the value of the variable $url
exists in this array.  The array would look like:

in_array()

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] array data

2004-02-11 Thread Richard Davey
Hello Imran,

Wednesday, February 11, 2004, 8:17:11 PM, you wrote:

IA Is not working, is it correct way

IA File1.php
IA? $colors = array('red','blue','green','yellow'); ?
IAform action=file2.php method=post
IA   input type=hidden type name=colors value=?=$colors?
IA   /fomr 

You can't do it like this. Rather, do the following:

form action=whatever.php method=post

input type=hidden name=colors[] value=red
input type=hidden name=colors[] value=blue
input type=hidden name=colors[] value=green

Or if you prefer you can use some PHP code to write out the input tags
based on a colors array:

?
$colors = array('red','blue','green','yellow');

foreach ($colors as $color)
{
echo input type=hidden name=colors[] value=\$color\;
}
?

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



RE: [PHP] array data

2004-02-11 Thread Shaunak Kashyap
It is not the correct way because $colors being an array, the HTML code for
the hidden input element will look like this (once the HTML has been
generated by PHP):

[code]
input type=hidden name=colors value=Array
[/code]

What you probably want to do instead is something like this:

[code]
?

foreach ($colors as $color) {

?
input type=hidden name=colors[] value=?= $color ?
?

}

? // close loop
[/code]

This will create the following HTML (for the given example)...

[code]
input type=hidden name=colors[] value=red
input type=hidden name=colors[] value=blue
input type=hidden name=colors[] value=green
input type=hidden name=colors[] value=yellow
[/code]

... and File2.php will do its job as desired.

Shaunak

 -Original Message-
 From: Imran Asghar [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, February 11, 2004 3:17 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] array data


 Hi,

 Is not working, is it correct way

 File1.php
? $colors = array('red','blue','green','yellow'); ?
form action=file2.php method=post
   input type=hidden type name=colors value=?=$colors?
   /fomr

 File2.php

 ?
  echo $colors[0];
  echo $colors[1];
  echo $colors[2];
  echo $colors[4];
 ?



 imee


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



[PHP] array data

2004-02-10 Thread Imran Asghar
Hi,
 
Is not working, is it correct way

File1.php
   ? $colors = array('red','blue','green','yellow'); ?
   form action=file2.php method=post
  input type=hidden type name=colors value=?=$colors?
  /fomr 

File2.php
 
? 
 echo $colors[0];
 echo $colors[1];
 echo $colors[2];
 echo $colors[4];
?



imee


[PHP] array block

2004-01-30 Thread Brian V Bonini
I'm having array block, trying to format the data in a two dimensional
associative array.

$menu = array (
'link1' = array(
'url' = 'foo',
'title' = 'bar'
),
'link2' = array(
'url' = 'foo',
'title' = 'bar'
)
);

foreach($menu as $k = $v) { etc..

need to end up with
a href=url title=titlelink(x)/a

Can't seem to put this together in my head. Long day I guess.

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



[PHP] Array Key Test

2004-01-12 Thread Cameron B. Prince
Hi,

How would I go about determining if a specific key exists in an array?

I want to see if $conf['hOpt'] is defined. is_array only works at the $conf
level.

I tried count(array_keys($conf, 'hOpt')), but always get 0.

What am I doing wrong here?


Thanks,
Cameron

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



Re: [PHP] Array Key Test

2004-01-12 Thread Stuart
Cameron B. Prince wrote:
How would I go about determining if a specific key exists in an array?
http://php.net/isset

I want to see if $conf['hOpt'] is defined. is_array only works at the $conf
level.
I tried count(array_keys($conf, 'hOpt')), but always get 0.
if (isset($conf['h0pt']))

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


[PHP] Array into $_SESSION

2004-01-02 Thread Cesar Aracena
Hi all,

can somebody remind me how to propperly insert not just one but many
variables into a $_SESSION handle? php manual doesn't explain it very well.
It just says that it can be done.

Thanks in advanced,

Cesar Aracena

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



Re: [PHP] Array into $_SESSION

2004-01-02 Thread Gerard Samuel
On Friday 02 January 2004 02:11 am, Cesar Aracena wrote:
 Hi all,

 can somebody remind me how to propperly insert not just one but many
 variables into a $_SESSION handle? php manual doesn't explain it very well.
 It just says that it can be done.


$_SESSION['foo'] = array('a', 'b', 'c', 'd', 'e');

var_dump($_SESSION['foo'][3]);  = 'd'

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



Re: [PHP] Array into $_SESSION

2004-01-02 Thread Cesar Aracena
Thanks a lot :)

Gerard Samuel [EMAIL PROTECTED] escribió en el mensaje
news:[EMAIL PROTECTED]
 On Friday 02 January 2004 02:11 am, Cesar Aracena wrote:
  Hi all,
 
  can somebody remind me how to propperly insert not just one but many
  variables into a $_SESSION handle? php manual doesn't explain it very
well.
  It just says that it can be done.
 

 $_SESSION['foo'] = array('a', 'b', 'c', 'd', 'e');

 var_dump($_SESSION['foo'][3]);  = 'd'

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



RE: [PHP] Array into $_SESSION

2004-01-02 Thread Larry Brown
session_register(user);
session_register(authLevel);
session_register(sessionExpire);

$user=$userDataFromForm;
$authLevel = $authLevelFromDB;
$sessionExpire = time() + 3600;

etc...

-Original Message-
From: Cesar Aracena [mailto:[EMAIL PROTECTED]
Sent: Friday, January 02, 2004 2:11 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Array into $_SESSION


Hi all,

can somebody remind me how to propperly insert not just one but many
variables into a $_SESSION handle? php manual doesn't explain it very well.
It just says that it can be done.

Thanks in advanced,

Cesar Aracena

-- 
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] Array into $_SESSION

2004-01-02 Thread Larry Brown
Sorry, my bad.  This is the Register Globals on version...

with RegisterGlobals off you would simply use..

$_SESSION['user'] = $userDataFromForm;
$_SESSION['authLevel'] 



-Original Message-
From: Larry Brown [mailto:[EMAIL PROTECTED]
Sent: Friday, January 02, 2004 11:33 AM
To: Cesar Aracena; PHP List
Subject: RE: [PHP] Array into $_SESSION


session_register(user);
session_register(authLevel);
session_register(sessionExpire);

$user=$userDataFromForm;
$authLevel = $authLevelFromDB;
$sessionExpire = time() + 3600;

etc...

-Original Message-
From: Cesar Aracena [mailto:[EMAIL PROTECTED]
Sent: Friday, January 02, 2004 2:11 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Array into $_SESSION


Hi all,

can somebody remind me how to propperly insert not just one but many
variables into a $_SESSION handle? php manual doesn't explain it very well.
It just says that it can be done.

Thanks in advanced,

Cesar Aracena

-- 
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

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



[PHP] array data to XML

2003-12-24 Thread Chakravarthy Cuddapah
newbie ...
 
Is it possible to format data in array to XML and display ?
 
Thanks !


Re: [PHP] Array problem....

2003-12-11 Thread Jas
Well just so you understand why I needed something like that here is 
the finished result below

?php
function show() {
	require 'path/to/dbconnector.inc';
	$sql_subs = mysql_query(SELECT * FROM $t_02,$db)or die(mysql_error());		
	   $i = 0;
	   while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) = 
mysql_fetch_row($sql_subs)) {
		   $_SESSION[$i] = subnet $subbrnetmask $msk {broption 
domain-name-servers $dns01, $dns02;broption routers $rtrs;brrange 
$rnge;br}br;
		   $i++; }
?

Then ...
?php
call_user_func(show);
echo $_session['0'];
echo $_session['1'];
...
?
And you get...
subnet 128.110.22.110
netmask 255.255.255.0 {
option domain-name-servers 128.110.22.4, 128.110.29.3;
option routers 128.110.22.1;
range ;
}
Which allows for easy reading of configuration variables and the ability 
to modify the individual vars using a form etc.

Thanks again for all who gave me some pointers on using numbers instead 
of names for my session vars.
Jas

Chris W. Parker wrote:
Jas mailto:[EMAIL PROTECTED]
on Wednesday, December 10, 2003 3:44 PM said:

having no idea you could use numbers as session variable names I kinda
feel like a retard right now.  You solution worked, thank you very
much.


It's an array just like any other which you probably realize now. ;)

Also, unless you're doing some math or something with those variables
you might to split them up into their own cells (I don't really know if
this is going to be useful for you or not):
{
$_SESSION[$iCtr]['var1'] = $var1;
$_SESSION[$iCtr]['var2'] = $var2;
$_SESSION[$iCtr]['var3'] = $var3;
$_SESSION[$iCtr]['var4'] = $var4;
$_SESSION[$iCtr]['var5'] = $var5;
...
}


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


RE: [PHP] Array problem....

2003-12-11 Thread Chris W. Parker
Jas mailto:[EMAIL PROTECTED]
on Thursday, December 11, 2003 7:21 AM said:

 Well just so you understand why I needed something like that here is
 the finished result below

[snip]

 $i = 0;
 while(list(...) = mysql_fetch_row(...)) {
 $_SESSION[$i] = ...;
 $i++;
 }

I want to change my suggestion and recommend that you go along with what
John Holmes suggested a little after my post. Read his post again and
see if it is helpful to you. Keep note of the following aspect:

You can remove the $i = 0; and the $i++; by changing $_SESSION[$i] =
...; to $_SESSION[] = ...;.

i.e. The following two code blocks perform the same task:

Current:
$i = 0;
while(list(...) = mysql_fetch_row(...)) {
$_SESSION[$i] = ...;
$i++;
}

New:
while(list(...) = mysql_fetch_row(...)) {
$_SESSION[] = ...;
}



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



Re: [PHP] Array problem....

2003-12-11 Thread Jas
Yeah I understand that and it would be perfect if I only had to call 
this type of function once on a page... and on any other pages that need 
something like this I will do it that way but with the counter set to 0 
or whatever number I choose which is a sort of view all page so your 
solutions works better for this page.  Thanks again.
Jas

Chris W. Parker wrote:

Jas mailto:[EMAIL PROTECTED]
on Thursday, December 11, 2003 7:21 AM said:

Well just so you understand why I needed something like that here is
the finished result below


[snip]


$i = 0;
while(list(...) = mysql_fetch_row(...)) {
   $_SESSION[$i] = ...;
   $i++;
}


I want to change my suggestion and recommend that you go along with what
John Holmes suggested a little after my post. Read his post again and
see if it is helpful to you. Keep note of the following aspect:
You can remove the $i = 0; and the $i++; by changing $_SESSION[$i] =
...; to $_SESSION[] = ...;.
i.e. The following two code blocks perform the same task:

Current:
$i = 0;
while(list(...) = mysql_fetch_row(...)) {
$_SESSION[$i] = ...;
$i++;
}
New:
while(list(...) = mysql_fetch_row(...)) {
$_SESSION[] = ...;
}


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] ARRAY

2003-12-10 Thread Brian Sutton
I am trying to read in a text file to an array using the following code, 
however everytime I try and print the contents of the $table array, it 
always says ARRAY.  Why won't it show me the actual contents of the file?

$row = 1;
$handle = fopen (seclog.txt,r);
while ($data = fgetcsv ($handle, 1000, ,)) {
   $num = count ($data);
   print p $num fields in line $row: br\n;
   $row++;
   for ($c=0; $c  $num; $c++) {
   print $data[$c] . br\n;
   $table[] = $data;
   }
}
fclose ($handle);
print $table;
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] ARRAY

2003-12-10 Thread ROBERT MCPEAK
Because it's and array!  print and echo take strings, not arrays, I believe.  Anyway, 
print_r() or a foreach loop will do it for you.

?php 
print_r($table);
//or
foreach ($table as $atable){
echo $tableBr;
}
?

Something like that.

 Brian Sutton [EMAIL PROTECTED] 12/10/03 01:26PM 
I am trying to read in a text file to an array using the following code, 
however everytime I try and print the contents of the $table array, it 
always says ARRAY.  Why won't it show me the actual contents of the file?

$row = 1;
$handle = fopen (seclog.txt,r);
while ($data = fgetcsv ($handle, 1000, ,)) {
$num = count ($data);
print p $num fields in line $row: br\n;
$row++;
for ($c=0; $c  $num; $c++) {
print $data[$c] . br\n;
$table[] = $data;
}
}
fclose ($handle);
print $table;

-- 
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[2]: [PHP] ARRAY

2003-12-10 Thread Richard Davey
Hi,

Wednesday, December 10, 2003, 6:29:43 PM, you wrote:

RM Because it's and array!  print and echo take strings, not
RM arrays, I believe.  Anyway, print_r() or a foreach loop will do it
RM for you.

Agreed.. print_r() is the best, but if you're outputting all of this
text into the browser (which is quite common) then I strongly suggest
you wrap it with some PRE tags. You'll understand why when you try
it.

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



Re: [PHP] ARRAY

2003-12-10 Thread Justin Patrin
Richard Davey wrote:

Hi,

Wednesday, December 10, 2003, 6:29:43 PM, you wrote:

RM Because it's and array!  print and echo take strings, not
RM arrays, I believe.  Anyway, print_r() or a foreach loop will do it
RM for you.
Agreed.. print_r() is the best, but if you're outputting all of this
text into the browser (which is quite common) then I strongly suggest
you wrap it with some PRE tags. You'll understand why when you try
it.
You can always use var_dump, too. Not a pretty as print_r, but it gives 
you more info (mostly for debugging). And don't forget var_export. ;-)

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


[PHP] Array problem....

2003-12-10 Thread Jas
Not very good at arrays so I figured i would look here

?php
$sql_subs = mysql_query(SELECT * FROM $t_02,$db)or 
die(mysql_error());	 
while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) = 
mysql_fetch_row($sql_subs)) {
	print $sub;
	print br;
	print $msk;
	print br;
	print $dns01;
	print br;
	print $dns02;
	print brbr; }
?

This pulls each row form a table and assigns a variable to each field, 
but what I need to do is something like this...

?php
$sql_subs = mysql_query(SELECT * FROM $t_02,$db)or 
die(mysql_error());	 
while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) = 
mysql_fetch_row($sql_subs)) {
	$_session['something to automaticly increment session var'] = 
$sub+$msk+$dns01...
}

I have been scouring the various functions and as of yet have yet to 
accomplish what I need.  Any help would be great.
Thanks in advance,
jas

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


RE: [PHP] Array problem....

2003-12-10 Thread Chris W. Parker
Jas mailto:[EMAIL PROTECTED]
on Wednesday, December 10, 2003 3:21 PM said:

 while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) =
 mysql_fetch_row($sql_subs)) {
   $_session['something to automaticly increment session var'] =
 $sub+$msk+$dns01...
 }

No exactly sure what you mean but here goes:

$iCtr = 0;

while(list(...)) = mysql_fetch_row(...))
{
$_SESSION[$iCtr] = $sub+$msk...;
$iCtr++;
}


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



RE: [PHP] Array problem....

2003-12-10 Thread Chris W. Parker
Chris W. Parker 
on Wednesday, December 10, 2003 3:27 PM said:

 while(list(...)) = mysql_fetch_row(...))
 {

Got one too many ) in there. Should be:

while(list(...) = mysql_fetch_row(...))
{



Chris.

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



Re: [PHP] Array problem....

2003-12-10 Thread Jas
having no idea you could use numbers as session variable names I kinda 
feel like a retard right now.  You solution worked, thank you very much.
Jas

Chris W. Parker wrote:

Jas mailto:[EMAIL PROTECTED]
on Wednesday, December 10, 2003 3:21 PM said:

while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) =
mysql_fetch_row($sql_subs)) {
$_session['something to automaticly increment session var'] =
$sub+$msk+$dns01...
}


No exactly sure what you mean but here goes:

$iCtr = 0;

while(list(...)) = mysql_fetch_row(...))
{
$_SESSION[$iCtr] = $sub+$msk...;
$iCtr++;
}
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


RE: [PHP] Array problem....

2003-12-10 Thread Chris W. Parker
Jas mailto:[EMAIL PROTECTED]
on Wednesday, December 10, 2003 3:44 PM said:

 having no idea you could use numbers as session variable names I kinda
 feel like a retard right now.  You solution worked, thank you very
 much.

It's an array just like any other which you probably realize now. ;)

Also, unless you're doing some math or something with those variables
you might to split them up into their own cells (I don't really know if
this is going to be useful for you or not):

{
$_SESSION[$iCtr]['var1'] = $var1;
$_SESSION[$iCtr]['var2'] = $var2;
$_SESSION[$iCtr]['var3'] = $var3;
$_SESSION[$iCtr]['var4'] = $var4;
$_SESSION[$iCtr]['var5'] = $var5;
...
}



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



Re: [PHP] Array problem....

2003-12-10 Thread John W. Holmes
Jas wrote:

but what I need to do is something like this...

?php
$sql_subs = mysql_query(SELECT * FROM $t_02,$db)or 
die(mysql_error()); 
while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) = 
mysql_fetch_row($sql_subs)) {
$_session['something to automaticly increment session var'] = 
$sub+$msk+$dns01...
}
How about:

$sql_subs = mysql_query(SELECT * FROM $t_02,$db) or die(mysql_error());
while($row = mysql_fetch_row($sql_subs))
{ $_SESSION['data'][] = $row; }
and you can use $_SESSION['data'][1]['id'], $_SESSION['data'][1]['sub'], 
etc...

If you really want a + delimited string in the session, then you can use:

$_SESSION['data'][] = implode('+',$row);

Then row 1 is $_SESSION['data'][0], row 2 is $_SESSION['data'][1], etc.

Kind of begs the question of why you're doing all this, though

--
---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] array problems

2003-11-28 Thread SLanger
$city = Ipswitch;
$city_found = 0;
$contentfile = fopen(content.txt, r);
while (!feof($contentfile)  $city_found == 0);
  {
$my_line = fgets($contentfile, 16384);
$content_array = explode(\t,$my_line);
if ($content_array[0] == $city)
 {
$city_found = 1;
print(Matched on $content_aray[0]br\n);
 }
  }
print($content_array[0]\n);

I think what you got is a scope problem. You are creating $content_array 
in your while loop so its scope is limited to the while loop. To test this 
simply do a var_dump or print_r on $content_array outside your loop and 
see if it actually is an array, which I guess it won't it will either be 
null or an empty string. 

To solve simply do an initialisation of the variable before the while loop 
like $content_array = ''.

Regards
Stefan

Re: [PHP] array problems

2003-11-28 Thread Jason Wong
On Friday 28 November 2003 16:03, [EMAIL PROTECTED] wrote:

 I think what you got is a scope problem. You are creating $content_array
 in your while loop so its scope is limited to the while loop. To test this
 simply do a var_dump or print_r on $content_array outside your loop and
 see if it actually is an array, which I guess it won't it will either be
 null or an empty string.

 To solve simply do an initialisation of the variable before the while loop
 like $content_array = ''.

So that people don't get misled, the above is completely wrong. WHILE loops do 
not have their own scope.

The correct answer (or the most plausible) was given in an earlier response by 
Marek, which pointed out that the last line(s) of the file may have just 
contained a CR and/or LF.

-- 
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
--
/*
Marriage is the waste-paper basket of the emotions.
*/

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



Re: [PHP] array problems

2003-11-28 Thread Marek Kilimajer
Curtis Maurand wrote:
OK.  That worked, thanks.  

Is it me, or is that rather odd behavior?
It is you ;)

Shouldn't array elements 
set within a loop be available to me outside the loop if the loop 
exits normally?  A loop is not a function (well it is, sort of.)  
Should I declare the variable as global?
You are in a loop, so the variable is overwriten by new value in each 
iteration.

global $content_array;
$city_found = 1;
while(!feof ...
When I was taking programming courses in college, I was taught that 
breaking out of a loop like that was bad practice; that it was better 
to leave a loop normally.
Depends. You could write

$continue=true;
while($continue  .. other conditions .. ) {
if(... another condition ...) {

$continue = false;
}
}
I don't think this is any better then breaking out, and is certainly 
slower. break and continue constructs are here for a reason and the use 
is right here.

I've never programmed in C other than to 
write a crude little dos2unix (actually mac2dos) utility.  Mosty 
i've written Perl, PHP Pascal and Basic.  Pascal, Perl and Basic 
don't exhibit this behavior.
All have this behavior.

 I never worked with arrays in C.  Am 
I wrong?

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


Re: [PHP] array problems

2003-11-28 Thread Eugene Lee
On Thu, Nov 27, 2003 at 08:19:02PM -0500, Curtis Maurand wrote:
: On Wednesday 26 November 2003 21:53, Marek Kilimajer mumble:
:  Curtis Maurand wrote:
:   Sorry, its a typo.  it should be:
:  
:   $city = Ipswitch;
:   $city_found = 0;
:   $contentfile = fopen(content.txt, r);
:   while (!feof($contentfile)  $city_found == 0);
: {
:   $my_line = fgets($contentfile, 16384);
:   $content_array = explode(\t,$my_line);
:   if ($content_array[0] == $city)
:{
: $city_found = 1;
:   print(Matched on $content_aray[0]br\n);
: 
:  /* Break out of the while loop */
:break;
: 
:}
: }
:   print($content_array[0]\n);
:  
:   //end
: 
: Is it me, or is that rather odd behavior?  Shouldn't array elements 
: set within a loop be available to me outside the loop if the loop 
: exits normally?

It should.  However, you must be sure to take the right action if the
loop exists unnormally.

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



Re: [PHP] array problems

2003-11-27 Thread Curtis Maurand

Thank you, I'll try that.

Curtis


On Wednesday 26 November 2003 21:53, the council of elders heard Marek 
Kilimajer mumble incoherently:
 Curtis Maurand wrote:
  Sorry, its a typo.  it should be:
 
  $city = Ipswitch;
  $city_found = 0;
  $contentfile = fopen(content.txt, r);
  while (!feof($contentfile)  $city_found == 0);
{
  $my_line = fgets($contentfile, 16384);
  $content_array = explode(\t,$my_line);
  if ($content_array[0] == $city)
   {
  $city_found = 1;
  print(Matched on $content_aray[0]br\n);

 /* Break out of the while loop */
 break;

   }
}
  print($content_array[0]\n);
 
  //end
 
  As I stated.  The match happens and the Matched on... message
  happens, but the print statement outside the while loop does
  not.  Its php-4.2.2 running on RedHat 8.0 (don't go there.)  Its
  the stock redhat php package. I don't trust redhat libraries for
  building php from scratch.  Of course, this might actually be the
  problem, too.  :-)
 
  Curtis

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



Re: [PHP] array problems

2003-11-27 Thread Curtis Maurand

OK.  That worked, thanks.  

Is it me, or is that rather odd behavior?  Shouldn't array elements 
set within a loop be available to me outside the loop if the loop 
exits normally?  A loop is not a function (well it is, sort of.)  
Should I declare the variable as global?

global $content_array;
$city_found = 1;
while(!feof ...

When I was taking programming courses in college, I was taught that 
breaking out of a loop like that was bad practice; that it was better 
to leave a loop normally.  I've never programmed in C other than to 
write a crude little dos2unix (actually mac2dos) utility.  Mosty 
i've written Perl, PHP Pascal and Basic.  Pascal, Perl and Basic 
don't exhibit this behavior.  I never worked with arrays in C.  Am 
I wrong?




On Wednesday 26 November 2003 21:53, the council of elders heard Marek 
Kilimajer mumble incoherently:
 Curtis Maurand wrote:
  Sorry, its a typo.  it should be:
 
  $city = Ipswitch;
  $city_found = 0;
  $contentfile = fopen(content.txt, r);
  while (!feof($contentfile)  $city_found == 0);
{
  $my_line = fgets($contentfile, 16384);
  $content_array = explode(\t,$my_line);
  if ($content_array[0] == $city)
   {
  $city_found = 1;
  print(Matched on $content_aray[0]br\n);

 /* Break out of the while loop */
 break;

   }
}
  print($content_array[0]\n);
 
  //end
 
  As I stated.  The match happens and the Matched on... message
  happens, but the print statement outside the while loop does
  not.  Its php-4.2.2 running on RedHat 8.0 (don't go there.)  Its
  the stock redhat php package. I don't trust redhat libraries for
  building php from scratch.  Of course, this might actually be the
  problem, too.  :-)
 
  Curtis

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



Re: [PHP] array problems

2003-11-26 Thread Jason Wong
On Wednesday 26 November 2003 04:45, Curtis Maurand wrote:

   consider the following code (content.txt is tab delimited).

 $city = Ipswitch;
 $content = fopen(content.txt, r);
 $city_found = 0;
 while (!feof($content)  $city_found == 0)
   {
 $my_line = fgets($content, r);
 $content_array = explode(\t,$my_line);
 if ($content_array == $city)

You can't do this comparison, $city is a string and $content_array is an 
array. It's meaningless to compare them.

   {
 print(Matched on $content_array[0]);
 $city_found = 1;
   }
   }
 print($content_array[0]br\n);

 Here's the trouble.

 inside the while loop $content_array is available to me.
 outside the loop $content_array is not available.  What
 am I doing wrong?

How did you confirm this observation?

-- 
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
--
/*
/* Fuck me gently with a chainsaw... */
2.0.38 /usr/src/linux/arch/sparc/kernel/ptrace.c
*/

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



Re: [PHP] array problems

2003-11-26 Thread Curtis Maurand

Sorry, its a typo.  it should be:

$city = Ipswitch;
$city_found = 0;
$contentfile = fopen(content.txt, r);
while (!feof($contentfile)  $city_found == 0);
  {
$my_line = fgets($contentfile, 16384);
$content_array = explode(\t,$my_line);
if ($content_array[0] == $city)
 {
$city_found = 1;
print(Matched on $content_aray[0]br\n);
 }
  }
print($content_array[0]\n);

//end

As I stated.  The match happens and the Matched on... message happens, 
but the print statement outside the while loop does not.  Its php-4.2.2 
running on RedHat 8.0 (don't go there.)  Its the stock redhat php package.  
I don't trust redhat libraries for building php from scratch.  Of course, 
this might actually be the problem, too.  :-)

Curtis

On Tue, 25 Nov 2003, Marek Kilimajer wrote:

 Curtis Maurand wrote:
  Hello,
consider the following code (content.txt is tab delimited).
  
  $city = Ipswitch;
  $content = fopen(content.txt, r);
  $city_found = 0;
  while (!feof($content)  $city_found == 0)
{
  $my_line = fgets($content, r);
  $content_array = explode(\t,$my_line);
  if ($content_array == $city)
 This will never be equal, $content_array is an array, $city is a string
 
{
  print(Matched on $content_array[0]);
  $city_found = 1;
}
}
  print($content_array[0]br\n);
  
  Here's the trouble.
  
  inside the while loop $content_array is available to me.
  outside the loop $content_array is not available.  What
  am I doing wrong?
 
 The file might end with an empty line, in that case $my_line in the last 
 iteration contains only the newline character.
 

-- 
--
Curtis Maurand
mailto:[EMAIL PROTECTED]
http://www.maurand.com

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



Re: [PHP] array problems

2003-11-26 Thread Marek Kilimajer
Curtis Maurand wrote:
Sorry, its a typo.  it should be:

$city = Ipswitch;
$city_found = 0;
$contentfile = fopen(content.txt, r);
while (!feof($contentfile)  $city_found == 0);
  {
$my_line = fgets($contentfile, 16384);
$content_array = explode(\t,$my_line);
if ($content_array[0] == $city)
 {
$city_found = 1;
print(Matched on $content_aray[0]br\n);
/* Break out of the while loop */
  break;
 }
  }
print($content_array[0]\n);
//end

As I stated.  The match happens and the Matched on... message happens, 
but the print statement outside the while loop does not.  Its php-4.2.2 
running on RedHat 8.0 (don't go there.)  Its the stock redhat php package.  
I don't trust redhat libraries for building php from scratch.  Of course, 
this might actually be the problem, too.  :-)

Curtis

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


[PHP] Array dimension

2003-11-26 Thread orlandopozo
I understand that in PHP there is only one dimension array, and in order to
create several dimensions, yo need to nested the same function array(), but
in conclusion you obtain n dimensions of the array whatever the
implementation, I have already figured it out the problem , thanks anyway
for all your help, bye.

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



[PHP] array problems

2003-11-25 Thread Curtis Maurand
Hello,
  consider the following code (content.txt is tab delimited).

$city = Ipswitch;
$content = fopen(content.txt, r);
$city_found = 0;
while (!feof($content)  $city_found == 0)
  {
$my_line = fgets($content, r);
$content_array = explode(\t,$my_line);
if ($content_array == $city)
  {
print(Matched on $content_array[0]);
$city_found = 1;
  }
  }
print($content_array[0]br\n);

Here's the trouble.

inside the while loop $content_array is available to me.
outside the loop $content_array is not available.  What
am I doing wrong?

Thanks in advance.

Curtis




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



Re: [PHP] array problems

2003-11-25 Thread Eugene Lee
On Tue, Nov 25, 2003 at 03:45:11PM -0500, Curtis Maurand wrote:
: 
: Hello,
:   consider the following code (content.txt is tab delimited).
: 
: $city = Ipswitch;
: $content = fopen(content.txt, r);
: $city_found = 0;
: while (!feof($content)  $city_found == 0)
:   {
: $my_line = fgets($content, r);
: $content_array = explode(\t,$my_line);
: if ($content_array == $city)
:   {
: print(Matched on $content_array[0]);
: $city_found = 1;
:   }
:   }
: print($content_array[0]br\n);
: 
: Here's the trouble.
: 
: inside the while loop $content_array is available to me.
: outside the loop $content_array is not available.  What
: am I doing wrong?

Your if statement is wrong.  You can't compare an array with a string.
And your $content_array is not guaranteed to exist when it reaches your
print() statement.  You can test for existence with is_array().  But you
already have this knowledge via your $city_found variable.  Use it.

Here's a revision (untested):

$city = Ipswitch;
$content = fopen(content.txt, r);
$city_found = false;
while (!feof($content))
  {
$my_line = fgets($content, r);
$content_array = explode(\t,$my_line);
if ($content_array[0] == $city)
  {
print(Matched on $content_array[0]);
$city_found = true;
break;
  }
  }
if ($city_found)
{
print($content_array[0]br\n);
}

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



Re: [PHP] array problems

2003-11-25 Thread Marek Kilimajer
Curtis Maurand wrote:
Hello,
  consider the following code (content.txt is tab delimited).
$city = Ipswitch;
$content = fopen(content.txt, r);
$city_found = 0;
while (!feof($content)  $city_found == 0)
  {
$my_line = fgets($content, r);
$content_array = explode(\t,$my_line);
if ($content_array == $city)
This will never be equal, $content_array is an array, $city is a string

  {
print(Matched on $content_array[0]);
$city_found = 1;
  }
  }
print($content_array[0]br\n);
Here's the trouble.

inside the while loop $content_array is available to me.
outside the loop $content_array is not available.  What
am I doing wrong?
The file might end with an empty line, in that case $my_line in the last 
iteration contains only the newline character.

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


[PHP] array confusion...

2003-11-24 Thread Dan Joseph
Hi,

I must be missing something in this array.  To me this makes no sense.
Here is it broken down...

Declartion:

$gtotals = array(
CO1 = 0,
CO2 = 0,
CO3 = 0,
CO4 = 0,
CO5 = 0,
CO6 = 0,
CO7 = 0
);

Code run:

while ( list( $action_code, $date_created, $date_letter_send ) =
mysql_fetch_row( $raw_res ) )
{
if ( $action_code == 'C01' || $action_code == 'C02' ||
 $action_code == 'C03' || $action_code == 'C04' ||
 $action_code == 'C05' || $action_code == 'C06' ||
 $action_code == 'C07' 
)
{

$totals[$date_created][$action_code]['created_count']++;
$gtotals[$action_code]++;
$dgtotals[$date_created]++;
$ggtt++;
$count++;
}
}

print_r results:

Array
(
[CO1] = 0
[CO2] = 0
[CO3] = 0
[CO4] = 0
[CO5] = 0
[CO6] = 0
[CO7] = 0
[C01] = 15
[C02] = 40
[C03] = 50
[C04] = 4
[C05] = 4
)

Now, the problem I'm having is that when I echo $array['C06'] and
$array['C07'] I'm getting  (nothing..).  Could someone point out how this
can be, and what I've done wrong?

-Dan Joseph

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



Re: [PHP] array confusion...

2003-11-24 Thread Brad Pauly
On Mon, 2003-11-24 at 13:42, Dan Joseph wrote:
 Hi,
 
   I must be missing something in this array.  To me this makes no sense.
 Here is it broken down...
 
   Declartion:
 
   $gtotals = array(
   CO1 = 0,
   CO2 = 0,
   CO3 = 0,
   CO4 = 0,
   CO5 = 0,
   CO6 = 0,
   CO7 = 0
   );
 

[snip]

 
   print_r results:
 
   Array
   (
   [CO1] = 0
   [CO2] = 0
   [CO3] = 0
   [CO4] = 0
   [CO5] = 0
   [CO6] = 0
   [CO7] = 0
   [C01] = 15
   [C02] = 40
   [C03] = 50
   [C04] = 4
   [C05] = 4
   )
 
   Now, the problem I'm having is that when I echo $array['C06'] and
 $array['C07'] I'm getting  (nothing..).  Could someone point out how this
 can be, and what I've done wrong?

I think you might have some letter 'O's instead of the number 0. Notice
that you have CO1 and C01 when you print_r. They are different keys.

- Brad

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



RE: [PHP] array confusion...

2003-11-24 Thread Dan Joseph
Hi,

 I think you might have some letter 'O's instead of the number 0. Notice
 that you have CO1 and C01 when you print_r. They are different keys.

I think you are correct!  hahaha...  oh man, one of those Mondays!  Thank
you sir!

-Dan Joseph

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



[PHP] Array + postgresql + braincramp

2003-11-18 Thread Roy Cabaniss
The problem is most likely that I have been looking at it for too long
and missed the obvious.  I know I can make multiple fields in the
database and work with it that way, but I'm sure an array is the proper
solution.

We have a form (and how many of our tales start off like that?  Bet it
beats once upon a time). which gathers data for work orders.  And we
want to assign multiple people to a particular job.


tdinput TYPE=checkbox NAME=workers[ ] VALUE=82Worker0
input TYPE=checkbox NAME=workers[ ] VALUE=83Worker1
input TYPE=checkbox NAME=workers[ ] VALUE=84Worker2
input TYPE=checkbox NAME=workers[ ] VALUE=85Worker3
/tdtr

With the values being the employee/student id number.  The values for
workers[ ] are passed along with the rest of the input from the form via
a post statement.

When I get to processing page I checked to see if there was data via
some echo's and it does indeed seem as though the data made it through.

echo $workers[0] br;
echo $workers[1] br; 

(each returns the values expected)

In the dataset (postgresql) I defined workers as integer [ ] so it
should be able to receive the data and it should be an array of
integers.

My update statement is as follows:

$update_now=UPDATE work_orders SET 
add_info2='$add_info2',
status='$status',
workers =$workers,  
when_assigned='$now'   
where work_order_id='$work_id'
;

which gives the following error message.

UPDATE work_orders SET add_info2='fagsh', status='Working', workers
=Array, when_assigned='1069188482' where work_order_id='1'
[nativecode=ERROR: Attribute array not found ].

When I try imploding $workers, converting it to a string and putting
that into workers it tells me the following.

UPDATE work_orders SET add_info2='qwer', status='Working', workers =83,
when_assigned='1069188871' where work_order_id='1' [nativecode=ERROR:
column workers is of type integer[] but expression is of type integer
You will need to rewrite or cast the expression ]

Any and all advice/help much appreciated.
-- 
Dr. Roy F. Cabaniss
Associate Professor of Marketing
University of Arkansas Monticello
http://cabanisspc.uamont.edu


signature.asc
Description: This is a digitally signed message part


RE: [PHP] Array + postgresql + braincramp

2003-11-18 Thread Giz
While you can use an array type in postgresql, in most cases I'd recommend
against it.  This is basically a repeating group, and in a relational
database the proper way to handle this type of need would be to have a
related table with a Many to 1 relationship back to the parent table.

If you are intent on using the array type, I believe your insert syntax
requires that the values be provided like so


In insert: values ('{value1, value2, .. value_n}' etc
In update: Set Columnname = '{value1, value2, .. value_n}'

-Original Message-
From: Roy Cabaniss [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 18, 2003 12:55 PM
To: List PHP General
Subject: [PHP] Array + postgresql + braincramp

The problem is most likely that I have been looking at it for too long

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



RE: [PHP] Array -- If

2003-11-07 Thread Erik Osterman
Sounds like what you want is the in_array function.

http://us4.php.net/manual/en/function.in-array.php

$cases = array( 5, 15, 30, 60, 90, 120 );

if ( in_array($count, $cases) ) {
EXECUTE PAGE
}

Regards,

Erik Osterman
http://osterman.com/


-Original Message-
From: Jason Williard [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, November 05, 2003 6:42 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Array -- If

I am building a script that I would like to have do a specific task
based on whether specific counts have been reached.

Basically, the script checks for connectivity in a specific port.  If
the connectivity fails, it increases the count by 1.  It does this every
minute.  I would like the script to page me at specific marker points
(i.e. 5, 15, 30, 60, 90, 120, etc).  Is there anyway to make an if
statement or something similar to run in any case where the COUNT value
equals one of the numbers in the array?

Example:

$cases = array( 5, 15, 30, 60, 90, 120 );

if ( $count = {ITEM IN $cases} ){
EXECUTE PAGE
}

Thanks,
Jason Williard

-- 
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



[PHP] Array -- If

2003-11-05 Thread Jason Williard
I am building a script that I would like to have do a specific task
based on whether specific counts have been reached.

Basically, the script checks for connectivity in a specific port.  If
the connectivity fails, it increases the count by 1.  It does this every
minute.  I would like the script to page me at specific marker points
(i.e. 5, 15, 30, 60, 90, 120, etc).  Is there anyway to make an if
statement or something similar to run in any case where the COUNT value
equals one of the numbers in the array?

Example:

$cases = array( 5, 15, 30, 60, 90, 120 );

if ( $count = {ITEM IN $cases} ){
EXECUTE PAGE
}

Thanks,
Jason Williard

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



Re: [PHP] Array maybe? Or many SQL insert queries

2003-11-01 Thread Burhan Khalid
Jake McHenry wrote:

Hi everyone, here's what I'm doing.

As of right now, I don't have anything implemented, but here's what I
need to do.
I have a web page, with a drop down list of hotels, an input box for
the users frequent hotel number, and a add button. At the bottom of
the page is a update and continue button to move the user to the next
page with more options.
What my boss wants is, when someone puts in a number, and clicks add,
he wants it to take that number and put it below the box, all on the
fly. I know I could do this through repeated sql insert querys, but I
was wondering if I could just put them into an array, then update the
database with one query after the user clicks the update and continue
button at the bottom, to get them to the next page?
This sounds like something javascript can fix. If you can be a bit more 
precise below the box doesn't mean much. What box? Is it a big green 
box? Blue box? Box of boxes?

If you want on the fly then its javascript. For php to work, you'd 
have to send a request to the server, which would kill your on the fly 
part.

--
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Array maybe? Or many SQL insert queries

2003-11-01 Thread Jake McHenry
 -Original Message-
 From: Burhan Khalid [mailto:[EMAIL PROTECTED] 
 Sent: Saturday, November 01, 2003 3:50 AM
 To: Jake McHenry; [EMAIL PROTECTED]
 Subject: Re: [PHP] Array maybe? Or many SQL insert queries
 
 
 Jake McHenry wrote:
 
  Hi everyone, here's what I'm doing.
  
  As of right now, I don't have anything implemented, but 
 here's what I 
  need to do.
  
  I have a web page, with a drop down list of hotels, an 
 input box for 
  the users frequent hotel number, and a add button. At the bottom
of 
  the page is a update and continue button to move the user 
 to the next 
  page with more options.
  
  What my boss wants is, when someone puts in a number, and 
 clicks add, 
  he wants it to take that number and put it below the box, 
 all on the 
  fly. I know I could do this through repeated sql insert 
 querys, but I 
  was wondering if I could just put them into an array, then 
 update the 
  database with one query after the user clicks the update 
 and continue 
  button at the bottom, to get them to the next page?
 
 This sounds like something javascript can fix. If you can be 
 a bit more 
 precise below the box doesn't mean much. What box? Is it a 
 big green 
 box? Blue box? Box of boxes?
 
 If you want on the fly then its javascript. For php to work, you'd

 have to send a request to the server, which would kill your 
 on the fly 
 part.
 
 
 -- 
 Burhan Khalid
 phplist[at]meidomus[dot]com
 http://www.meidomus.com
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


I don't know why I said on the fly.. Lol.. 

The box I'm referring to is the input field box. I just need what's
submitted via the input field and add button to show up in a list
below the input box, to show the account numbers that were entered. I
can either insert them into the database each time the add button is
clicked, or my preference if possible, put them in an array of some
kind then submit them all at once. To get a picture of what I want...:




   Site Logo
 __
|__| ADD


 Submit and Continue  Submit and Exit




That's basically what this page looks like. What I need is when the
person inputs the account number in the input box, and clicks add, it
needs to refresh the page with the added number below that box, then
again for each number they enter.

Like I said, I can do this with multiple accesses to the database, but
I would like to know of a way I could submit them all at once instead
of multiple accesses to the database.


Let me know if you need more info.



Thanks,

Jake McHenry
Nittany Travel MIS Coordinator
http://www.nittanytravel.com

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



Re: [PHP] Array maybe? Or many SQL insert queries

2003-11-01 Thread Burhan Khalid
Jake McHenry wrote:
-Original Message-
From: Burhan Khalid [mailto:[EMAIL PROTECTED] 
Sent: Saturday, November 01, 2003 3:50 AM
To: Jake McHenry; [EMAIL PROTECTED]
Subject: Re: [PHP] Array maybe? Or many SQL insert queries

Jake McHenry wrote:


Hi everyone, here's what I'm doing.

As of right now, I don't have anything implemented, but 
here's what I 

need to do.

I have a web page, with a drop down list of hotels, an 
input box for 

the users frequent hotel number, and a add button. At the bottom
of 

the page is a update and continue button to move the user 
to the next 

page with more options.

What my boss wants is, when someone puts in a number, and 
clicks add, 

he wants it to take that number and put it below the box, 
all on the 

fly. I know I could do this through repeated sql insert 
querys, but I 

was wondering if I could just put them into an array, then 
update the 

database with one query after the user clicks the update 
and continue 

button at the bottom, to get them to the next page?
This sounds like something javascript can fix. If you can be 
a bit more 
precise below the box doesn't mean much. What box? Is it a 
big green 
box? Blue box? Box of boxes?

If you want on the fly then its javascript. For php to work, you'd


have to send a request to the server, which would kill your 
on the fly 
part.

I don't know why I said on the fly.. Lol.. 

The box I'm referring to is the input field box. I just need what's
submitted via the input field and add button to show up in a list
below the input box, to show the account numbers that were entered. I
can either insert them into the database each time the add button is
clicked, or my preference if possible, put them in an array of some
kind then submit them all at once. To get a picture of what I want...:


   Site Logo
 __
|__| ADD
 Submit and Continue  Submit and Exit



That's basically what this page looks like. What I need is when the
person inputs the account number in the input box, and clicks add, it
needs to refresh the page with the added number below that box, then
again for each number they enter.
You can attach a javascript function to the onclick event of the Add 
button that populates your drop down. Of course, this assumes that you 
have a predefined array of all possible values (in javascript) that the 
user can enter.

However, if your user can arbitrarily enter values, and all you need to 
do is add them to the drop down list, then some simple javascript DOM 
is all you need. Then when the user clicks on the Submit and Continue 
button, use php to read the dropdown array (appending [] to the name 
attribute's value will help -- like this select name=foo[] then 
$_POST['foo'][0] would hold the value of your selected index).

If you are not a big fan of javascript + DOM (this is, after all, a PHP 
list) -- you can use PHP to dynamically populate the dropdown by 
appending the value of the entered box to the array. Something along the 
lines of (untested):

$textbx = isset($_POST['textbx']) ? $_POST['textbx'] : NULL;
$menu = array();
if ($textbx != NULL)
{
   $menu['somevalue'] = $textbx;
} else { echo select name=\chooser[]\option value=\NULL\ 
selected=\selected\Please enter a value/option/select;
}

/* we now assume that the array was populated */
echo select name=\chooser[]\\n;
echo option value=\NULL\ selected=\selected\Value Entered 
Below/option\n;
while(list($k,$v) = each($menu))
{
   echo option value=\.$k.\.$v./option\n;
}
echo /select;

Hope this helps.

--
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Array maybe? Or many SQL insert queries

2003-11-01 Thread Jake McHenry
 -Original Message-
 From: Burhan Khalid [mailto:[EMAIL PROTECTED] 
 Sent: Saturday, November 01, 2003 11:16 AM
 To: Jake McHenry; [EMAIL PROTECTED]
 Subject: Re: [PHP] Array maybe? Or many SQL insert queries
 
 
 Jake McHenry wrote:
 -Original Message-
 From: Burhan Khalid [mailto:[EMAIL PROTECTED]
 Sent: Saturday, November 01, 2003 3:50 AM
 To: Jake McHenry; [EMAIL PROTECTED]
 Subject: Re: [PHP] Array maybe? Or many SQL insert queries
 
 
 Jake McHenry wrote:
 
 
 Hi everyone, here's what I'm doing.
 
 As of right now, I don't have anything implemented, but
 
 here's what I
 
 need to do.
 
 I have a web page, with a drop down list of hotels, an
 
 input box for
 
 the users frequent hotel number, and a add button. At the bottom
  
  of
  
 the page is a update and continue button to move the user
 
 to the next
 
 page with more options.
 
 What my boss wants is, when someone puts in a number, and
 
 clicks add,
 
 he wants it to take that number and put it below the box,
 
 all on the
 
 fly. I know I could do this through repeated sql insert
 
 querys, but I
 
 was wondering if I could just put them into an array, then
 
 update the
 
 database with one query after the user clicks the update
 
 and continue
 
 button at the bottom, to get them to the next page?
 
 This sounds like something javascript can fix. If you can be
 a bit more 
 precise below the box doesn't mean much. What box? Is it a 
 big green 
 box? Blue box? Box of boxes?
 
 If you want on the fly then its javascript. For php to work,
you'd
  
  
 have to send a request to the server, which would kill your
 on the fly 
 part.
 
  I don't know why I said on the fly.. Lol..
  
  The box I'm referring to is the input field box. I just need
what's 
  submitted via the input field and add button to show up in a list 
  below the input box, to show the account numbers that were 
 entered. I 
  can either insert them into the database each time the add 
 button is 
  clicked, or my preference if possible, put them in an array of
some 
  kind then submit them all at once. To get a picture of what 
 I want...:
  
  
  
  
 Site Logo
   __
  |__| ADD
  
  
   Submit and Continue  
 Submit and Exit
  
  
  
  
  That's basically what this page looks like. What I need is when
the 
  person inputs the account number in the input box, and 
 clicks add, it 
  needs to refresh the page with the added number below that 
 box, then 
  again for each number they enter.
 
 You can attach a javascript function to the onclick event of the Add

 button that populates your drop down. Of course, this assumes 
 that you 
 have a predefined array of all possible values (in 
 javascript) that the 
 user can enter.
 
 However, if your user can arbitrarily enter values, and all 
 you need to 
 do is add them to the drop down list, then some simple 
 javascript DOM 
 is all you need. Then when the user clicks on the Submit and
Continue 
 button, use php to read the dropdown array (appending [] to the name

 attribute's value will help -- like this select name=foo[] then 
 $_POST['foo'][0] would hold the value of your selected index).
 
 If you are not a big fan of javascript + DOM (this is, after 
 all, a PHP 
 list) -- you can use PHP to dynamically populate the dropdown by 
 appending the value of the entered box to the array. 
 Something along the 
 lines of (untested):
 
 $textbx = isset($_POST['textbx']) ? $_POST['textbx'] : NULL; 
 $menu = array(); if ($textbx != NULL) {
 $menu['somevalue'] = $textbx;
 } else { echo select name=\chooser[]\option value=\NULL\ 
 selected=\selected\Please enter a value/option/select; }
 
 /* we now assume that the array was populated */
 echo select name=\chooser[]\\n;
 echo option value=\NULL\ selected=\selected\Value Entered 
 Below/option\n;
 while(list($k,$v) = each($menu))
 {
 echo option value=\.$k.\.$v./option\n;
 }
 echo /select;
 
 
 Hope this helps.
 
 -- 
 Burhan Khalid
 phplist[at]meidomus[dot]com
 http://www.meidomus.com
 

I'm not making a drop down box, I just want the contents of what is
added to be displayed on the page.

I got all of this done by creating an array and storing it in a
session variable.

Here's the code...

if ($_POST['2_Add'] != )
{
  if (($_POST['Frequent_Flyer_Program'] != ) 
($_POST['Frequent_Flyer_Number'] != ))
  {
$array = array();
$new =
{$_POST['Frequent_Flyer_Program']},{$_POST['Frequent_Flyer_Number']}
;
$old = $_SESSION['Frequent_Flyer'];
$array = array_merge($old, $new);
$_SESSION['Frequent_Flyer'] = $array;
  }
  header(Location: profile2.php);
}



The only dilema I have now is... How can I allow the user to remove
entries from this array if they make a mistake?

On the other pages where the add button is, and the list, I have a
foreach loop that explodes the array

[PHP] Array maybe? Or many SQL insert queries

2003-10-31 Thread Jake McHenry
Hi everyone, here's what I'm doing.

As of right now, I don't have anything implemented, but here's what I
need to do.

I have a web page, with a drop down list of hotels, an input box for
the users frequent hotel number, and a add button. At the bottom of
the page is a update and continue button to move the user to the next
page with more options.

What my boss wants is, when someone puts in a number, and clicks add,
he wants it to take that number and put it below the box, all on the
fly. I know I could do this through repeated sql insert querys, but I
was wondering if I could just put them into an array, then update the
database with one query after the user clicks the update and continue
button at the bottom, to get them to the next page?

I will need to use this same outline for the this page, plus the next
2 pages in sequence for car and flyer numbers.

Or, if anyone has a better way of an array or sql queries, that will
work as well. :-)

Thanks,

Jake McHenry
Nittany Travel MIS Coordinator
http://www.nittanytravel.com

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



[PHP] Array Hell

2003-10-23 Thread Richard Cook
Hi All,
Im having a headache trying to sort this out...

I have my array which is created each time a user adds an item to my basket,
this all works fine. The problem im having is that when the user adds the
item to the cart they have the option of selecting '0' as the quantity which
in effect removes it from the basket.

for example at position 0 on the array below the customer has product
22, the customer has ordered 6.

$array[0][0] = 22
$array[0][1] = 6

If the customer inputs the value 0 into quantity the array looks like this:

$array[0][0] = 22
$array[0][1] = 0


The question is who can i filter the array removing any values that have 0
in [x][1], i would also need to re-order the array from 0 to 'n'.



Hope that all makes sence


And before you ask i have looked everywhere at the manual (i got even more
lost)




Regards


R

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



[PHP] array of java-objects

2003-10-23 Thread Helke Schröder
Hi,

I'm trying to use our java-code in php.
But strange things happens
Maybe I did a simple mistake..

$MyInf=new Java(myUtil.myInfo);

This is inside of a loop through 3 items:

$MyAttributes=array();
$MyAttributes=$MyInf-MyAttrReader($v, ,, $item);
$c=null;
$c=count($MyAttributes);

so far ok, $c shows the correct number
but when doing this :

reset($MyAttributes);
$sa=$MyAttributes[0];  /* I can use 0 because there are always more than one
elements inside*/
var_dump($sa);

it comes up with a java-object only for the first entry

object(java)(1) { [0]= int(4) }
int(20)
int(36)

And then of course it's impossible to call methods on the objects because
they are no objects

Fatal error: Call to a member function on a non-object

Every hint woul'd be appreciated
thanks, Helke

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



Re: [PHP] Array Hell

2003-10-23 Thread Curt Zirzow
* Thus wrote Richard Cook ([EMAIL PROTECTED]):
 Hi All,
 Im having a headache trying to sort this out...
 
 If the customer inputs the value 0 into quantity the array looks like this:
 
 $array[0][0] = 22
 $array[0][1] = 0
 
 
 The question is who can i filter the array removing any values that have 0
 in [x][1], i would also need to re-order the array from 0 to 'n'.

foreach ($array as $i =$item) {
  if ( $item[1]) {
$new_array[] = $item;
  }
}
$array = $new_array;

There might be an elegant way with one of the functions in
  http://php.net/array


Curt
-- 
My PHP key is worn out

  PHP List stats since 1997: 
  http://zirzow.dyndns.org/html/mlists/

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



Re: [PHP] array of java-objects

2003-10-23 Thread Raditha Dissanayake
Hi,
please post your full code
Helke Schröder wrote:

Hi,

I'm trying to use our java-code in php.
But strange things happens
Maybe I did a simple mistake..
$MyInf=new Java(myUtil.myInfo);

This is inside of a loop through 3 items:

$MyAttributes=array();
$MyAttributes=$MyInf-MyAttrReader($v, ,, $item);
$c=null;
$c=count($MyAttributes);
so far ok, $c shows the correct number
but when doing this :
reset($MyAttributes);
$sa=$MyAttributes[0];  /* I can use 0 because there are always more than one
elements inside*/
var_dump($sa);
it comes up with a java-object only for the first entry

object(java)(1) { [0]= int(4) }
int(20)
int(36)
And then of course it's impossible to call methods on the objects because
they are no objects
Fatal error: Call to a member function on a non-object

Every hint woul'd be appreciated
thanks, Helke
 



--
Raditha Dissanayake.

http://www.radinks.com/sftp/  |  http://www.raditha/megaupload/
Lean and mean Secure FTP applet with  |  Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB  |  with progress bar.


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


Re: [PHP] array of java-objects

2003-10-23 Thread Helke Schröder
Hi,

thanks for the replay

the var_dump on the array of java-objects looks interesting:

the first, which is ok:

array(8) { [0]= object(java)(1) { [0]= int(3) } [1]= object(java)(1)
 [0]= int(4) } [2]= object(java)(1) { [0]= int(5) } [3]=
object(java)(1) { [0]= int(6) } [4]= object(java)(1) { [0]= int(7) }
[5]= object(java)(1) { [0]= int(8) } [6]= object(java)(1) { [0]=
int(9) } [7]= object(java)(1) { [0]= int(10) } }

but the second is strange:

array(8) { [0]= int(20) [1]= object(java)(1) { [0]= int(21) } [2]=
object(java)(1286082128) { } [3]= object(java)(1) { [0]= int(23) } [4]=
object(java)(1) { [0]= int(24) } [5]= object(java)(1) { [0]= int(25) }
[6]= object(java)(1) { [0]= int(26) } [7]= object(java)(1) { [0]=
int(27) } }

Why is that? The first element of that array is not a java-object.

The same with the third one:

array(9) { [0]= int(37) [1]= object(java)(1) { [0]= int(38) } [2]=
object(java)(1) { [0]= int(39) } [3]= object(java)(1) { [0]= int(40) }
[4]= object(java)(1) { [0]= int(41) } [5]= object(java)(1) { [0]=
int(42) } [6]= object(java)(1) { [0]= int(43) } [7]= object(java)(1)
 [0]= int(44) } [8]= object(java)(1) { [0]= int(45) } }



thanks in advance, Helke

here is the code:

?php

error_reporting(E_ALL);

echo(htmlheadtitletest ldx per php/title/headbody);

$ldaphost=195.180.92.49;

$such_art=inh;

$filter=cn=*;

$base=dc=schule,dc=de;

$LdxInf=null;

$LdxInf=new Java(ldxUtil.LdxInterface);

$ObjectDNs=null;

$ObjectDNs=$LdxInf-FindObjects($ldaphost, , , $filter, $base);

echo(hr);

array_walk($ObjectDNs, traverse_array);

echo(hr);

echo(table);

foreach ($ObjectDNs as $item)

{

$LdxAttributes=null;

echo(trtd bgcolor=\#FF8000\);

var_dump($LdxInf);

echo(/td/tr);

echo(trtd bgcolor=\#00\.$item./td);

$LdxAttributes=array();

$LdxAttributes=$LdxInf-InheritanceReader($ldaphost, ,, $item);

$c=null;

$c=count($LdxAttributes);

echo(td.$c./td/tr);

reset($LdxAttributes);

echo(trtd bgcolor=\#C0C0C0\);

var_dump($LdxAttributes);

echo(/td/tr);

$sa=null;

$sa=new Java('ldxUtil.LdxAttribute');

reset($LdxAttributes);

$sa=$LdxAttributes[0];

echo(trtd bgcolor=\#80\);

var_dump($sa); /*the first object comes as java-object, the both following
as int(20) and int(37)*/

echo(/td/tr);

$s=null;

/*$s=$sa-getAttribute();

echo(trtd bgcolor=\#80FF80\);

var_dump($s);

echo(/td/tr);

echo(trtd.$s./td/tr);*/

unset($s);

unset($sa);

reset($LdxAttributes);

for ($i=0;$i$c;$i++)

{

echo(trtdsome text/td/tr);

$a=null;

$a=new Java('ldxUtil.LdxAttribute');

/*echo(trtd.$LdxAttributes[$i]-getAttribute()./td/tr);*/

unset($a);

}

unset($LdxAttributes);

unset($c);

}

function traverse_array($value) {

print $value.br;

}

unset($ObjectDNs);

unset($LdxInf);

unset($base);

unset($filter);

unset($such_art);

unset($ldaphost);

echo(/table/body/html);

?

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



[PHP] Array in SQL-table

2003-10-23 Thread Reidar
I want to store an ARRAY in a SQL-table but don't know how to define it in
the table. The PHP-stuff is working OK but the DB-thing isn't.

Anyone tried this? Hopefully it is

Reidar Solberg

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



Re: [PHP] Array in SQL-table

2003-10-23 Thread Jordan S. Jones
If the field isn't required to be searchable, you could just serialize 
the array and shove that into a VARCHAR column.. Then unserialize the 
return value for that column.

Jordan S. Jones

Reidar wrote:

I want to store an ARRAY in a SQL-table but don't know how to define it in
the table. The PHP-stuff is working OK but the DB-thing isn't.
Anyone tried this? Hopefully it is

Reidar Solberg

 

--
I am nothing but a poor boy. Please Donate..
https://www.paypal.com/xclick/business=list%40racistnames.comitem_name=Jordan+S.+Jonesno_note=1tax=0currency_code=USD
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Array to string?

2003-10-14 Thread Douglas Douglas
Hello everybody.

Is there any built-in function to convert an array to
string?

Thanks.

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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



Re: [PHP] Array to string?

2003-10-14 Thread Douglas Douglas
I just found it: implode. Sorry to bother you.

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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



[PHP] Array of Classes

2003-10-06 Thread Rob Wiltbank
Greetings..

Doing some persistant connection socket-based PHP stuff and I'm trying to
figure out a few things:

1) How can I create an array of classes so they could be referenced, for
instance: $array[$uniqueID][$class-var] = 10; ?

2) Would it instantiate when that particular element was used and would the
constructor run at that point?

3) Any way to dispose/destroy of an object once it's done being used to free
up the resources?

Thanks,
Rob

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



Re: [PHP] Array of Classes

2003-10-06 Thread David Otton
On Mon, 6 Oct 2003 13:41:22 -0400, you wrote:

1) How can I create an array of classes so they could be referenced, for
instance: $array[$uniqueID][$class-var] = 10; ?

2) Would it instantiate when that particular element was used and would the
constructor run at that point?

3) Any way to dispose/destroy of an object once it's done being used to free
up the resources?

?

class A {
function A () {
echo (pCreated/p);
}

function B ($s = None) {
echo (pinput : $s/p);
}
}

$C = array();

for ($i = 0; $i  3; $i++)
{
$C[$i] = new A();
}

for ($i = 0; $i  3; $i++)
{
$C[$i]-B($i);
}

for ($i = 0; $i  3; $i++)
{
unset ($C[$i]);
}

?

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



Re: [PHP] Array of Classes

2003-10-06 Thread Rob Wiltbank
Cheers!  Just what I was looking for. :)

Rob
David Otton [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Mon, 6 Oct 2003 13:41:22 -0400, you wrote:

 1) How can I create an array of classes so they could be referenced, for
 instance: $array[$uniqueID][$class-var] = 10; ?
 
 2) Would it instantiate when that particular element was used and would
the
 constructor run at that point?
 
 3) Any way to dispose/destroy of an object once it's done being used to
free
 up the resources?

 ?

 class A {
 function A () {
 echo (pCreated/p);
 }

 function B ($s = None) {
 echo (pinput : $s/p);
 }
 }

 $C = array();

 for ($i = 0; $i  3; $i++)
 {
 $C[$i] = new A();
 }

 for ($i = 0; $i  3; $i++)
 {
 $C[$i]-B($i);
 }

 for ($i = 0; $i  3; $i++)
 {
 unset ($C[$i]);
 }

 ?

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



[PHP] Array question

2003-09-27 Thread Robin Kopetzky
Good morning all!!

Can you nest an array within an array??

Example: $paArgs['aCheckBoxes[$iIndex]['sName']']

Thank you in advance.

Robin 'Sparky' Kopetzky
Black Mesa Computers/Internet Service
Grants, NM 87020 

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



Re: [PHP] Array question

2003-09-27 Thread Robert Cummings
On Sat, 2003-09-27 at 12:18, Robin Kopetzky wrote:
 Good morning all!!
 
 Can you nest an array within an array??
 
 Example: $paArgs['aCheckBoxes[$iIndex]['sName']']

You mean can you retrieve an array entry by giving a key defined by a
value in another array? To do so remove the outer quotes in your above
statement and add a $ to the interior array.

Example: $paArgs[$aCheckBoxes[$iIndex]['sName']]

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



Re: [PHP] Array question

2003-09-27 Thread Jackson Miller
On Saturday 27 September 2003 11:18, Robin Kopetzky wrote:
 Good morning all!!

 Can you nest an array within an array??

 Example: $paArgs['aCheckBoxes[$iIndex]['sName']']

Yes, but like this
$array['aCheckBoxes'][] = $iIndex['sName']

This means:
$array is an array
aCheckBoxes is a item in $array
aCheckBoxes is also an array
$iIndex is an item in the aCheckBoxes array
$iIndex is an array.

Hope this helps.

-Jackson



 Thank you in advance.

 Robin 'Sparky' Kopetzky
 Black Mesa Computers/Internet Service
 Grants, NM 87020

-- 
jackson miller
 
cold feet creative
615.321.3300 / 800.595.4401
[EMAIL PROTECTED]
 
 
cold feet presents Emma
the world's easiest email marketing
Learn more @  http://www.myemma.com

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



Re: [PHP] Array question

2003-09-27 Thread Cristian Lavaque
http://www.php.net/manual/en/language.types.array.php

If you mean having an array inside an array, of course ? $arr =
array(array('data')); ?. There you have an array inside another
one, 'data' will be here $var['0']['0'].

If you meant using an array item as the key in another array,
then you do it as with a normal var ? $arr1[$arr2['0']]; ?.
Remember not to quote $arr2 just as you wouldn't a quote a var
when using it as the key.

In your question you're mixing both:
 Example: $paArgs['aCheckBoxes[$iIndex]['sName']']

Unquote 'aCheckBoxes[$iIndex]['sName']' and put the $ sign in
front:
$paArgs[$aCheckBoxes[$iIndex]['sName']]

I hope this helped.

Cristian



Robin Kopetzky wrote:
 Good morning all!!

 Can you nest an array within an array??

 Example: $paArgs['aCheckBoxes[$iIndex]['sName']']

 Thank you in advance.

 Robin 'Sparky' Kopetzky
 Black Mesa Computers/Internet Service
 Grants, NM 87020

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



[PHP] How to do Javascript for the HTML/PHP Array (See Below)

2003-09-17 Thread Scott Fletcher
Hi Fellas!

Here's the clipping of an article about putting HTML variables into a
PHP Array upon submission.  Right now, I'm having trouble getting Javascript
to do the error checking of each of the HTML variable if it's variable name
is treated as an array.  Anyone know of a workaround to it where Javascript
can detect and work with the HTML Array-like variable name???

--snip--

3. How do I create arrays in a HTML form?

To get your form result sent as an array to your PHP script you name the
input, select or textarea elements like this: input name=MyArray[]
input name=MyArray[]
input name=MyArray[]
input name=MyArray[]
Notice the square brackets after the variable name, that's what makes it an
array. You can group the elements into different arrays by assigning the
same name to different elements: input name=MyArray[]
input name=MyArray[]
input name=MyOtherArray[]
input name=MyOtherArray[]
This produces two arrays, MyArray and MyOtherArray, that gets sent to the
PHP script. It's also possible to assign specific keys to your arrays:
input name=AnotherArray[]
input name=AnotherArray[]
input name=AnotherArray[email]
input name=AnotherArray[phone]
The AnotherArray array will now contain the keys 0, 1, email and phone.


  Note: Specifying an arrays key is optional in HTML. If you do not specify
the keys, the array gets filled in the order the elements appear in the
form. Our first example will contain keys 0, 1, 2 and 3.


See also Array Functions and Variables from outside PHP.

--snip--

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



Re: [PHP] How to do Javascript for the HTML/PHP Array (See Below)

2003-09-17 Thread Marek Kilimajer
if f = your form then f.elements['MyArray[]'] is a javascript array of 
input elements.

Scott Fletcher wrote:

Hi Fellas!

Here's the clipping of an article about putting HTML variables into a
PHP Array upon submission.  Right now, I'm having trouble getting Javascript
to do the error checking of each of the HTML variable if it's variable name
is treated as an array.  Anyone know of a workaround to it where Javascript
can detect and work with the HTML Array-like variable name???
--snip--

3. How do I create arrays in a HTML form?

To get your form result sent as an array to your PHP script you name the
input, select or textarea elements like this: input name=MyArray[]
input name=MyArray[]
input name=MyArray[]
input name=MyArray[]
Notice the square brackets after the variable name, that's what makes it an
array. You can group the elements into different arrays by assigning the
same name to different elements: input name=MyArray[]
input name=MyArray[]
input name=MyOtherArray[]
input name=MyOtherArray[]
This produces two arrays, MyArray and MyOtherArray, that gets sent to the
PHP script. It's also possible to assign specific keys to your arrays:
input name=AnotherArray[]
input name=AnotherArray[]
input name=AnotherArray[email]
input name=AnotherArray[phone]
The AnotherArray array will now contain the keys 0, 1, email and phone.
  Note: Specifying an arrays key is optional in HTML. If you do not specify
the keys, the array gets filled in the order the elements appear in the
form. Our first example will contain keys 0, 1, 2 and 3.
See also Array Functions and Variables from outside PHP.

--snip--

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


Re: [PHP] How to do Javascript for the HTML/PHP Array (See Below)

2003-09-17 Thread Scott Fletcher
Ah!  So I do this to make it work where count can be any number...

 f.elements['MyArray[]'][count].value

That does work now.  It's been mind boggling to do the conversion between
JavaScript, HTML and PHP when it come to an array but I'm learning.  :-)

Thanks a million...
Scott F.

Marek Kilimajer [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 if f = your form then f.elements['MyArray[]'] is a javascript array of
 input elements.

 Scott Fletcher wrote:

  Hi Fellas!
 
  Here's the clipping of an article about putting HTML variables into
a
  PHP Array upon submission.  Right now, I'm having trouble getting
Javascript
  to do the error checking of each of the HTML variable if it's variable
name
  is treated as an array.  Anyone know of a workaround to it where
Javascript
  can detect and work with the HTML Array-like variable name???
 
  --snip--
 
  3. How do I create arrays in a HTML form?
 
  To get your form result sent as an array to your PHP script you name
the
  input, select or textarea elements like this: input
name=MyArray[]
  input name=MyArray[]
  input name=MyArray[]
  input name=MyArray[]
  Notice the square brackets after the variable name, that's what makes it
an
  array. You can group the elements into different arrays by assigning the
  same name to different elements: input name=MyArray[]
  input name=MyArray[]
  input name=MyOtherArray[]
  input name=MyOtherArray[]
  This produces two arrays, MyArray and MyOtherArray, that gets sent to
the
  PHP script. It's also possible to assign specific keys to your arrays:
  input name=AnotherArray[]
  input name=AnotherArray[]
  input name=AnotherArray[email]
  input name=AnotherArray[phone]
  The AnotherArray array will now contain the keys 0, 1, email and phone.
 
 
Note: Specifying an arrays key is optional in HTML. If you do not
specify
  the keys, the array gets filled in the order the elements appear in the
  form. Our first example will contain keys 0, 1, 2 and 3.
 
 
  See also Array Functions and Variables from outside PHP.
 
  --snip--
 

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



[PHP] array encapsulate

2003-09-12 Thread Bill
I'd like to do this, but it produces an error:

if ($_POST{[detail][11][116]}  !$_POST{[detailtext][19][114]}) {

so I'm left doing this

if ($_POST[detail][11][116]  !$_POST[detailtext][19][114]) {

How can I encapsulate the array so it is a multi-dimensional array and not just
a string length?

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



Re: [PHP] array encapsulate

2003-09-12 Thread Larry E . Ullman
if ($_POST[detail][11][116]  !$_POST[detailtext][19][114]) {

How can I encapsulate the array so it is a multi-dimensional array and 
not just
a string length?
I'm not exactly sure what you're array structure is but that syntax is 
correct.
$_POST['key1']['key2']...

Larry

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


Re: [PHP] array encapsulate

2003-09-12 Thread Bill
How do I know it won't just assume that $_POST[detail][11][116]  means the
116th character in the string $_POST[detail][11]?

Larry E . Ullman wrote:

  if ($_POST[detail][11][116]  !$_POST[detailtext][19][114]) {
 
  How can I encapsulate the array so it is a multi-dimensional array and
  not just
  a string length?

 I'm not exactly sure what you're array structure is but that syntax is
 correct.
 $_POST['key1']['key2']...

 Larry

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



Re: [PHP] array encapsulate

2003-09-12 Thread John W. Holmes
Bill wrote:
How do I know it won't just assume that $_POST[detail][11][116]  means the
116th character in the string $_POST[detail][11]?
Because $_POST['detail'][11] is an array (or it should be). If you're in 
doubt, make sure it is with is_array().

--
---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] Array Push and Keys

2003-08-29 Thread David Otton
On Thu, 28 Aug 2003 18:14:39 -0400, you wrote:

While($row=mysql_fetch_array($res) {

That *should* create the array above, but as I mentioned array_push does not
seem to be taking the keys  I just get a Parse error message for the
line. (the first array_push)

Ahem. Count the brackets? :)

(On a style point, your code would be easier to read for bugs like this if
you added some whitespace.)

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



<    2   3   4   5   6   7   8   9   10   11   >