php-general Digest 25 Dec 2006 08:04:24 -0000 Issue 4533

2006-12-25 Thread php-general-digest-help

php-general Digest 25 Dec 2006 08:04:24 - Issue 4533

Topics (messages 246195 through 246204):

calling a function in the same page
246195 by: Jahangir
246196 by: Jahangir
246204 by: Jahangir

Counting the occurences of items in an array
246197 by: Dotan Cohen
246198 by: Sumeet
246199 by: Myron Turner
246200 by: tedd
246201 by: Dotan Cohen

Odd behavior
246202 by: jekillen

New ImageMagick Extension
246203 by: Kevin Waterson

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
php-general@lists.php.net


--
---BeginMessage---
I am trying to call a function from a href inside the same page.
this is the code:
echo brbra href=\isearch($query)\More results from Mysite/a;
// calling the function isearch

function isearch($query)

{$query=urlencode($query);

$request='http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=Ja
hangirquery=' .urlencode($query). 'output=phpresults=100site=mysite.com;

$response=file_get_contents($request);

if ($response === false) {

die('Request failed');}

$phpobj=unserialize($response);

$count=$phpobj[ResultSet][totalResultsReturned];

if($phpobj[ResultSet][totalResultsAvailable]==0)

{echo brNO RESULTS TO DISPLAY; }

echo tr; echo h4 style=\color:#FF\ align=\center\Results from
Mysite/h4;

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

{ echo 'pre';

$no=$i+1;

$url=$phpobj[ResultSet][Result][$i][Url];

echo h3 .$no. . a href=\$url\ .
$phpobj[ResultSet][Result][$i][Title] . /a/h3; echo /tr;

echo tr; echo $phpobj[ResultSet][Result][$i][Summary]; echo
/tr;

echo br; echo tr; echo b
.$phpobj[ResultSet][Result][$i][Url] ./b; echo /tr;

echo br; $link=$phpobj[ResultSet][Result][$i][DisplayUrl];

echo tr; echo a href=\$url\$link/a; echo /tr;

echo '/pre'; }}



whenever i try to execute this function i either get an Object not found
error or Access Forbidden error.

Can someone tell me where am i going wrong here??

thanks in advance
---End Message---
---BeginMessage---
I am trying to call a function from a href inside the same page.
this is the code:
echo brbra href=\isearch($query)\More results from Mysite/a;
// calling the function isearch

function isearch($query)

{$query=urlencode($query);

$request='http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=Ja
hangirquery=' .urlencode($query). 'output=phpresults=100site=mysite.com;

$response=file_get_contents($request);

if ($response === false) {

die('Request failed');}

$phpobj=unserialize($response);

$count=$phpobj[ResultSet][totalResultsReturned];

if($phpobj[ResultSet][totalResultsAvailable]==0)

{echo brNO RESULTS TO DISPLAY; }

echo tr; echo h4 style=\color:#FF\ align=\center\Results from
Mysite/h4;

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

{ echo 'pre';

$no=$i+1;

$url=$phpobj[ResultSet][Result][$i][Url];

echo h3 .$no. . a href=\$url\ .
$phpobj[ResultSet][Result][$i][Title] . /a/h3; echo /tr;

echo tr; echo $phpobj[ResultSet][Result][$i][Summary]; echo
/tr;

echo br; echo tr; echo b
.$phpobj[ResultSet][Result][$i][Url] ./b; echo /tr;

echo br; $link=$phpobj[ResultSet][Result][$i][DisplayUrl];

echo tr; echo a href=\$url\$link/a; echo /tr;

echo '/pre'; }}



whenever i try to execute this function i either get an Object not found
error or Access Forbidden error.

Can someone tell me where am i going wrong here??

thanks in advance
---End Message---
---BeginMessage---
I am trying to call a function from a href inside the same page.
this is the code:
echo brbra href=\isearch($query)\More results from Mysite/a;
// calling the function isearch

function isearch($query)

{$query=urlencode($query);

$request='http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=Ja
hangirquery=' .urlencode($query). 'output=phpresults=100site=mysite.com;

$response=file_get_contents($request);

if ($response === false) {

die('Request failed');}

$phpobj=unserialize($response);

$count=$phpobj[ResultSet][totalResultsReturned];

if($phpobj[ResultSet][totalResultsAvailable]==0)

{echo brNO RESULTS TO DISPLAY; }

echo tr; echo h4 style=\color:#FF\ align=\center\Results from
Mysite/h4;

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

{ echo 'pre';

$no=$i+1;

$url=$phpobj[ResultSet][Result][$i][Url];

echo h3 .$no. . a href=\$url\ .
$phpobj[ResultSet][Result][$i][Title] . /a/h3; echo /tr;

echo tr; echo $phpobj[ResultSet][Result][$i][Summary]; echo
/tr;

echo br; echo tr; echo b
.$phpobj[ResultSet][Result][$i][Url] ./b; echo /tr;

echo br; $link=$phpobj[ResultSet][Result][$i][DisplayUrl];

echo tr; echo a href=\$url\$link/a; echo /tr;

echo '/pre'; }}



whenever i try to execute this function i either get an Object not found
error or Access Forbidden error.

Can someone tell me where am i going wrong here??

thanks in advance
---End Message---
---BeginMessage---

Has this wheel been 

[PHP] calling a function in the same page

2006-12-25 Thread Jahangir
I am trying to call a function from a href inside the same page.
this is the code:
echo brbra href=\isearch($query)\More results from Mysite/a;
// calling the function isearch

function isearch($query)

{$query=urlencode($query);

$request='http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=Ja
hangirquery=' .urlencode($query). 'output=phpresults=100site=mysite.com;

$response=file_get_contents($request);

if ($response === false) {

die('Request failed');}

$phpobj=unserialize($response);

$count=$phpobj[ResultSet][totalResultsReturned];

if($phpobj[ResultSet][totalResultsAvailable]==0)

{echo brNO RESULTS TO DISPLAY; }

echo tr; echo h4 style=\color:#FF\ align=\center\Results from
Mysite/h4;

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

{ echo 'pre';

$no=$i+1;

$url=$phpobj[ResultSet][Result][$i][Url];

echo h3 .$no. . a href=\$url\ .
$phpobj[ResultSet][Result][$i][Title] . /a/h3; echo /tr;

echo tr; echo $phpobj[ResultSet][Result][$i][Summary]; echo
/tr;

echo br; echo tr; echo b
.$phpobj[ResultSet][Result][$i][Url] ./b; echo /tr;

echo br; $link=$phpobj[ResultSet][Result][$i][DisplayUrl];

echo tr; echo a href=\$url\$link/a; echo /tr;

echo '/pre'; }}



whenever i try to execute this function i either get an Object not found
error or Access Forbidden error.

Can someone tell me where am i going wrong here??

thanks in advance

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



Re: [PHP] calling a function in the same page

2006-12-25 Thread Sumeet

Jahangir wrote:

I am trying to call a function from a href inside the same page.
this is the code:
echo brbra href=\isearch($query)\More results from Mysite/a;
// calling the function isearch

function isearch($query)

{$query=urlencode($query);

$request='http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=Ja
hangirquery=' .urlencode($query). 'output=phpresults=100site=mysite.com;

$response=file_get_contents($request);

if ($response === false) {

die('Request failed');}

$phpobj=unserialize($response);

$count=$phpobj[ResultSet][totalResultsReturned];

if($phpobj[ResultSet][totalResultsAvailable]==0)

{echo brNO RESULTS TO DISPLAY; }


add a 'die;' here.. like

{
echo brNO RESULTS TO DISPLAY;
die;
}

--
Thanking You

Sumeet Shroff
http://www.prateeksha.com
Web Designers and PHP / Mysql Ecommerce Development, Mumbai India

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



Re: [PHP] Clarification: Jump to a record/PHP paging...

2006-12-25 Thread Robert Cummings
On Sun, 2006-12-24 at 11:22 -0500, tedd wrote:
Again, in my opinion, that's fuzzy thinking. Sure, Yeti may be in the
   monster sub-set, but how much monster it is as compared to Lockness?
   You need a means, a yardstick, to compare the two with each other.
   Like, is Lockness bigger than the Yeti while monster-mouse is
   smaller, or what?
 
 Who the hell cares, I asked for any entry with monster in the
 description, I didn't say make higher level philosophical debate within
 your head as to the level of monsteriness. Quit trying to paint shades
 of gray when all that lies before you is black and white. We have an
 order, the order in the dictionary, we have a query for which results
 are returned using the same ordering criterion as in the dictionary.
 
 Rob:
 
 If YOU are doing a FULL TEXT search within a description field 
 looking for the word monster and reporting all those records that 
 fulfill the search, then I agree with YOU, but that's not what the 
 POSTER was asking. In fact, I already discussed a FULL TEXT search in 
 a previous post re this subject.
 
 The poster asked:
 
 ... my question is: how might I have MySQL tell me how many records 
 came BEFORE the found record?
 
 So, if he followed your advice/technique, then tell us how many 
 records came before monster?
 
 I claim you can't.

WRONG! See Martin Alterisio's post for the same thread. You must not
have understood the OP's requirements.

 He has already decided an order so your rebuttal is completely devoid of
 additional content.
 
 You are arbitrarily inferring that the order was alphabetical, but he 
 did not say that.
 
 However, if he had, then please explain how you would use a FULL TEXT 
 search to find the word that came BEFORE monster? I would be very 
 interested to see how that's done. We all can learn.

Yep, you definitely didn't understand the requirements. Tsk tsk.

BTW,
Merry Christmas :D

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

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



[PHP] Merry Christmas!

2006-12-25 Thread Robert Cummings
WhoooOO! Hope you all have a great Christmas day. If
you don't celebrate Christmas, then I hope you have a great Christmas
day anyways *lol*. If this post offends you due to it's promotion of
Christmas then I apologize and hope you have a great anal retentive
Christmas day!!! :B

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

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



[PHP] scripting process doesn't function

2006-12-25 Thread Geert T
Hi,
 
I have made some script that process the users input, and validates the input 
and sends it back. But it doesn't work very 
well, in fact it doesn't work at all. I am only able to see and input my name 
and such in the html form, but the php part doesn't do it's job.
I have looked over the scripts thousands of times, but couldn't find the 
problem, really.
 
Here is the script plus 2 .inc files; 
 
Hoping for some replies and answers,
Thanks in advance!
 
PS: if this script is a bit messy to read, I have included them in this mail 
seperately.
 
 
?php/* Script name:  addressForm.inc * Description: Script displays a form. */ 
echo htmlheadtitleCustomer Address/title/headbody; 
echo p align='center'form action='validateForm.php' method='POST'
table width='95%' border='0' cellspacing='0'cellpadding='2'\n; 
foreach($labels as $field=$value) {  if(isset($_POST[$field]))  {   $value = 
$_POST[$field];  }  else  {   $value = ;  }  echo trtd 
align='right'{$labels[$field]}/br/td tdinput type='text' 
name'$field' size='65'maxlength='65'  value='$value' /td /tr; 
} echo  /table div align='center'   pinput type='Submit' 
name='Submit'  value='Submit Address'/p/div 
/form;?/body/html
 
 
 
 
?php/* Script name:  info.inc * Description:  creates an array of labels for 
use in a  * form. */
 $labels = array( firstName=  First Name:,  midName=Middle Name:, 
 lastName=Last Name:,  street=Street Address:,  
city=City:,  state=State:,  zipcode=Zipcode:);  ?
 
 
 
?php/* Script name:  validateForm * Description: Displays and validates a form 
that * collects a name and address. */include(info.inc); #6  
#  ## First display of empty form ##  
#  if(!isset($_POST['Submit']))#10  {   
include(addressForm.inc);  }  
  ## Check information 
when form is submitted. Build ##  ## arrays of blank and incorrectly formatted 
fields. ##  ## If any errors are found, display error messages ##  ## and 
redisplay form. If no errors found, display ##  ## the submitted information.   
 ##     else   
#21   { foreach($_POST as $field=$value)  #23   {
if(empty($_POST[$field]))  #25  { if($field !=midName) {
$blanks[$field] = blank; #29 }  }  else #33  {   $value = 
trim($value);   if($field != zipcode)   {if(!ereg(^[A-Za-z0-9' 
.-]{1,65}$,$value)){ $formats[$field] = bad;}   }   
elseif($field == zipcode)   {if(!ereg(^[0-9]{5}(\-[0-9]{4})?,$value))   
 {  $formats[$field] = bad;}   }  } }  #51 ### if any fields 
were not okay, display error ### ### message and redisplay form ### if 
(@sizeof($blanks)  0 or @sizeof($formats)  0)#54 {   if (@size($blanks)  
0)   { echo bYou didn't fill in one or more required fields. You 
must enter:/bbr;  foreach($blanks as $field = $value)  {echo 
nbsp;nbsp;nbsp;{$labels[$field]}br;  } } if (@sizeof($formats)  0) {
echo bOne or more fields have information thatappears to be 
incorrect. Correct the  format for:/bbr;   foreach($formats as $field 
= $value)   { echo nbsp;nbsp;nbsp;{$labels[$field]}br;   } } echo 
hr; include(adressForm.inc);  }  else  { ### If no errors in the 
form, display the  ### ### name and address submitted by user ###  echo 
htmlheadtitleName and Address/title/headbody\n;  
foreach($_POST as $field=$value)  {   if($field != Submit)  {echo 
{$labels[$field]} $valuebr\n;   }  }  echo /body/html; }   } ?
 
_
Probeer Live.com: jouw leven online met nieuws, sport, weer en nog veel meer.
http://www.live.com/getstarted?php
/*  Script name:addressForm.inc
 *  Description:Script displays a form.
 */
  
echo html
  headtitleCustomer Address/title/head
  body;
echo p align='center'
  form action='validateForm.php' method='POST'
  table width='95%' border='0' cellspacing='0'
cellpadding='2'\n;
foreach($labels as $field=$value)
{
if(isset($_POST[$field]))
{
$value = $_POST[$field];
}
else
{
$value = ;
}
echo trtd align='right'{$labels[$field]}/br/td
  tdinput type='text' name'$field' size='65'
maxlength='65'
value='$value' /td /tr;
}
echo  /table
   div align='center'
 pinput type='Submit' name='Submit'
   

Re: [PHP] Odd behavior

2006-12-25 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-12-24 18:11:03 -0800:
 function display($list, $in, $out, $save, $req, $x)
  {
   for($i = 0; $i  count($in); $i++)
   {$j = $i + 1;
   // two sets of links displayed instead of one
  for($i = 0; $i  count($out); $i++)
   {$j = $i + 1;
 // two sets of links displayed instead of one
   for($i = 0; $i  count($save); $i++)
{$j = $i + 1;
  // two sets of links displayed instead of one
   for($i = 0; $i  count($req); $i++)
{$j = $i + 1;
  // two sets of links displayed instead of one

 The print lines above are supposed to produce a list of links to files.
 In the web display I get duplicate sets of links which seems to mean
 that the loops in the function are running twice, and in one instance
 three times instead of once.

Look at the variable names you use for iteration.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] scripting process doesn't function

2006-12-25 Thread Sancar Saran
On Monday 25 December 2006 13:35, Geert T wrote:
 Hi,

 I have made some script that process the users input, and validates the
 input and sends it back. But it doesn't work very well, in fact it doesn't
 work at all. I am only able to see and input my name and such in the html
 form, but the php part doesn't do it's job. I have looked over the scripts
 thousands of times, but couldn't find the problem, really.

 Here is the script plus 2 .inc files;

 Hoping for some replies and answers,
 Thanks in advance!

 PS: if this script is a bit messy to read, I have included them in this
 mail seperately.

I cannot get 3rd script. And this one may solve your problem in address form 
and info.inc..

?php
$labels = array( firstName=   First Name:,
 midName=Middle Name:,
 lastName=Last Name:,
 street=Street Address:,
 city=City:,
 state=State:,
 zipcode=Zipcode:);
$strLoop = '';
$intSize = sizeof($labels);
$arrKeys = arrayKeys($labels);
for($l=0;$l$intSize;$l++)
{
$value = '';
if(isset($_REQUEST[$labels[$arrKeys[$l]]]))
{
$value = $_REQUEST[$labels[$arrKeys[$l]]];  
}
$strLoop.=
   tr
td align='right'
.$labels[$arrKeys[$l]].br/
/td
td
input type='text' 
name='.$arrKeys[$l].' size='65' maxlength='65' 
value='.$value.' / 
/td 
/tr\n;
}

$strPage =
html
head
title
Customer Address
/title
/head
body
p align='center'
form action='validateForm.php' method='POST'
table width='95%' border='0' cellspacing='0' 
cellpadding='2'
.$strLoop.
tr
td align='center'
input type='Submit' name='Submit' 
value='Submit Address' /
/td
/tr
/table
/form
/p
/body
/html\n;

echo $strPage;
?

validateForm.php 
May Look like this

?php

$intSize = sizeof($_REQUEST);
$arrKeys = array_keys($_REQUEST)
// Or you may use $labels array again

if($intSize  0)
{
for($r=0;$r$intSize;$r++)
{
// do some global check for all $_REQUEST elements
// then do some conditional
switch ($_REQUEST[$arrKeys[$r]])
{
case firstName:
//do Someting
break;


}
}

}
?

Regards

Sancar

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



Re: [PHP] Odd behavior

2006-12-25 Thread jekillen


On Dec 25, 2006, at 7:21 AM, Roman Neuhauser wrote:


# [EMAIL PROTECTED] / 2006-12-24 18:11:03 -0800:

function display($list, $in, $out, $save, $req, $x)
 {
  for($i = 0; $i  count($in); $i++)
  {$j = $i + 1;
  // two sets of links displayed instead of one
 for($i = 0; $i  count($out); $i++)
  {$j = $i + 1;
// two sets of links displayed instead of one
  for($i = 0; $i  count($save); $i++)
   {$j = $i + 1;
 // two sets of links displayed instead of one
  for($i = 0; $i  count($req); $i++)
   {$j = $i + 1;
 // two sets of links displayed instead of one


The print lines above are supposed to produce a list of links to 
files.

In the web display I get duplicate sets of links which seems to mean
that the loops in the function are running twice, and in one instance
three times instead of once.


Look at the variable names you use for iteration.


Thanks, Usually, when a variable name like $i is used and then
reset to 0 in the next loop it does not matter. But I solved the
problem and posted the solution.  I also solved the regex
problem. There was an extra \n sneaking into the test pattern
so I could not get a match. I am not sure where the extra \n is
coming from.
It looks like I didn't post the solution after all:
Update:
I solved the double loops problem with this code change:

function display($list, $a, $x)
{
 for($i = 0; $i  count($a); $i++)
{$j = $i + 1;
 print a 
href=\steps.php?list=$listnext=$jx=$x\$j/abrbr\n;

};
 }
and:

if($list || $current)
  {
switch($list)
  {
   case 'in':
   display($list, $in, $x);
   break;
   case 'out':
   display($list, $out, $x);
   break;
   case 'save':
   display($list, $save, $x);
   break;
   case 'req':
   display($list, $req, $x);
   break;
  }
  }
Apparently what was happening was that the code running under 5.1.2
was trying to process all the arrays that had values in spite of the 
switch
statement in the original display() function. If the was an $in array 
the
switch  would process that for the $list value being 'in' but since 
there

was also a save value, the switch tried to process it also, even though
'save' wasn't the $list value. I found it would do this for all arrays 
that

had values. So if three had values the loop selected loop would run
three times.
Could this be a bonafide bug?
JK

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



RE: [PHP] calling a function in the same page

2006-12-25 Thread Peter Lauri
Hi,

Are you trying to use PHP as a client scripting language?

What you are doing cannot be done with plain PHP, you have to invoke
JavaScript or similar to make a HTTP request and then parse it.

Search Google for AJAX and you could get it working using that. Prototype
is a easy to use JS library that you can do AJAX requests with and then do
what you want with by DOM.

/Peter


-Original Message-
From: Jahangir [mailto:[EMAIL PROTECTED] 
Sent: Sunday, December 24, 2006 5:34 PM
To: php-general@lists.php.net
Subject: [PHP] calling a function in the same page

I am trying to call a function from a href inside the same page.
this is the code:
echo brbra href=\isearch($query)\More results from Mysite/a;
// calling the function isearch

function isearch($query)

{$query=urlencode($query);

$request='http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=Ja
hangirquery=' .urlencode($query). 'output=phpresults=100site=mysite.com;

$response=file_get_contents($request);

if ($response === false) {

die('Request failed');}

$phpobj=unserialize($response);

$count=$phpobj[ResultSet][totalResultsReturned];

if($phpobj[ResultSet][totalResultsAvailable]==0)

{echo brNO RESULTS TO DISPLAY; }

echo tr; echo h4 style=\color:#FF\ align=\center\Results from
Mysite/h4;

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

{ echo 'pre';

$no=$i+1;

$url=$phpobj[ResultSet][Result][$i][Url];

echo h3 .$no. . a href=\$url\ .
$phpobj[ResultSet][Result][$i][Title] . /a/h3; echo /tr;

echo tr; echo $phpobj[ResultSet][Result][$i][Summary]; echo
/tr;

echo br; echo tr; echo b
.$phpobj[ResultSet][Result][$i][Url] ./b; echo /tr;

echo br; $link=$phpobj[ResultSet][Result][$i][DisplayUrl];

echo tr; echo a href=\$url\$link/a; echo /tr;

echo '/pre'; }}



whenever i try to execute this function i either get an Object not found
error or Access Forbidden error.

Can someone tell me where am i going wrong here??

thanks in advance

-- 
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] Odd behavior

2006-12-25 Thread Martin Alterisio

2006/12/25, jekillen [EMAIL PROTECTED]:



On Dec 25, 2006, at 7:21 AM, Roman Neuhauser wrote:

 # [EMAIL PROTECTED] / 2006-12-24 18:11:03 -0800:
 function display($list, $in, $out, $save, $req, $x)
  {
   for($i = 0; $i  count($in); $i++)
   {$j = $i + 1;
   // two sets of links displayed instead of one
  for($i = 0; $i  count($out); $i++)
   {$j = $i + 1;
 // two sets of links displayed instead of one
   for($i = 0; $i  count($save); $i++)
{$j = $i + 1;
  // two sets of links displayed instead of one
   for($i = 0; $i  count($req); $i++)
{$j = $i + 1;
  // two sets of links displayed instead of one

 The print lines above are supposed to produce a list of links to
 files.
 In the web display I get duplicate sets of links which seems to mean
 that the loops in the function are running twice, and in one instance
 three times instead of once.

 Look at the variable names you use for iteration.

Thanks, Usually, when a variable name like $i is used and then
reset to 0 in the next loop it does not matter. But I solved the
problem and posted the solution.  I also solved the regex
problem. There was an extra \n sneaking into the test pattern
so I could not get a match. I am not sure where the extra \n is
coming from.
It looks like I didn't post the solution after all:
Update:
I solved the double loops problem with this code change:

function display($list, $a, $x)
 {
  for($i = 0; $i  count($a); $i++)
 {$j = $i + 1;
  print a
href=\steps.php?list=$listnext=$jx=$x\$j/abrbr\n;
 };
  }
and:

if($list || $current)
   {
 switch($list)
   {
case 'in':
display($list, $in, $x);
break;
case 'out':
display($list, $out, $x);
break;
case 'save':
display($list, $save, $x);
break;
case 'req':
display($list, $req, $x);
break;
   }
   }
Apparently what was happening was that the code running under 5.1.2
was trying to process all the arrays that had values in spite of the
switch
statement in the original display() function. If the was an $in array
the
switch  would process that for the $list value being 'in' but since
there
was also a save value, the switch tried to process it also, even though
'save' wasn't the $list value. I found it would do this for all arrays
that
had values. So if three had values the loop selected loop would run
three times.
Could this be a bonafide bug?
JK



I suspect this is an EBSAC bug, but I'm not completely sure. Anyway, please
consider improving your coding style, its all messy and unreadable. Also,
you should provide a description of the calling conditions, since there
might be the cause of the error in the function.


Re: [PHP] Clarification: Jump to a record/PHP paging...

2006-12-25 Thread Martin Alterisio

2006/12/25, Robert Cummings [EMAIL PROTECTED]:



WRONG! See Martin Alterisio's post for the same thread. You must not
have understood the OP's requirements.



xD
I was starting to think my mails weren't getting through the list, maybe its
nothing else than only a bigger delay than the usual. Anyway, I kind of lost
the topic of your discussion there... if you're so kind to explain in such a
way that an idiot like me can understand...

And Merry Xmas, Merry hangover or anything else you should desire to
celebrate.

PS: was my previous post useful to anyone? or did I mess up the explanation?
I'm not sure... =S that's why I'm asking...


Re: [PHP] Merry Christmas!

2006-12-25 Thread Miles Thompson

At 07:20 AM 12/25/2006, Robert Cummings wrote:


WhoooOO! Hope you all have a great Christmas day. If
you don't celebrate Christmas, then I hope you have a great Christmas
day anyways *lol*. If this post offends you due to it's promotion of
Christmas then I apologize and hope you have a great anal retentive
Christmas day!!! :B

Merry Christmas,
Rob.



Hey Rob,

It's now Christmas night here in Nova Scotia.

We had a  great day. The weather was mild, so we had apcnic lunch on the 
way to visit my sister and her family; then had the big family get-together 
there. We missed our oldest, he's in Ottawa visiting his girlfriend, but 
then our job is to raise them to leave the nest. Besides, she's a lovely girl.


Merry Christmas to everyone - Miles


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.15.26/601 - Release Date: 12/24/2006

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



[PHP] array_intersect problem

2006-12-25 Thread Leo Liu
Hi,
   
  I try to intersect associative array and it seems to fail to do so. Can 
anyone show me a walk around?
   
  For example I have
   
  array1
   
  Array
(
[0] = Array
(
[imageID] = 1
)

[1] = Array
(
[imageID] = 2
)

[2] = Array
(
[imageID] = 3
)

[3] = Array
(
[imageID] = 4
)
)
   
  And array 2
   
  Array
(
[0] = Array
(
[imageID] = 6
)

[1] = Array
(
[imageID] = 3
)
)
   
  After intersection instead of me getting 3 as a result, I got the array 1 
unchanged. Seems like intersection doesn't take place at all. Anyway to solve 
this problem?
   
  Regards,
   
  Leo
   



Reality starts with Dream 

 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: [PHP] Merry Christmas!

2006-12-25 Thread Craige Leeder

Merry Christmas everyone. I hope you have/had a great one. Enjoy your
turkey feasts this weekend, they comes only a few times a year.

On 12/25/06, Miles Thompson [EMAIL PROTECTED] wrote:

At 07:20 AM 12/25/2006, Robert Cummings wrote:

WhoooOO! Hope you all have a great Christmas day. If
you don't celebrate Christmas, then I hope you have a great Christmas
day anyways *lol*. If this post offends you due to it's promotion of
Christmas then I apologize and hope you have a great anal retentive
Christmas day!!! :B

Merry Christmas,
Rob.


Hey Rob,

It's now Christmas night here in Nova Scotia.

We had a  great day. The weather was mild, so we had apcnic lunch on the
way to visit my sister and her family; then had the big family get-together
there. We missed our oldest, he's in Ottawa visiting his girlfriend, but
then our job is to raise them to leave the nest. Besides, she's a lovely girl.

Merry Christmas to everyone - Miles


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.15.26/601 - Release Date: 12/24/2006

--
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] Couple Problem.

2006-12-25 Thread Craige Leeder

PHP General Mailing List,

I have a few questions when it comes to installation of PHP, and a PHP
extension   I have been eyeing

The first question involves Installation of PHP-GTK with PHP 5, from
zip. Although I follow the simple instructions included in the zip, I
am not able to start the PHP executable. I get an error of a missing
library (php-gtk2.dll [not found], and a pop up saying intl.dll). Have
I done horribly wrong? I didn't think it would be that hard of a task.
I'm using the gtkpath batch file, as apposed to changing my  PATH
variable this time around.

The second question is about installation op PHP 6. I have tried, and
failed at the installation of PHP 6 on my windows machine. Apache will
not load the module. I am not sure my exact setup now, as I attempted
it a week and a half ago, but as I recall I did not change my PATH
variable, to avoid conflict with my existing stable PHP5 installation.
Therefor, I moved the dll into the apache folder.

Sorry if allot of this is a little cryptic. I am dead tired, and just
wanted to send this off tonight before I retired for the night.

Thanks for any help you may be able to give based on this message.

- Craige

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



Re: [PHP] array_intersect problem

2006-12-25 Thread Martin Alterisio

2006/12/25, Leo Liu [EMAIL PROTECTED]:


Hi,

  I try to intersect associative array and it seems to fail to do so. Can
anyone show me a walk around?

  For example I have

  array1

  Array
(
[0] = Array
(
[imageID] = 1
)

[1] = Array
(
[imageID] = 2
)

[2] = Array
(
[imageID] = 3
)

[3] = Array
(
[imageID] = 4
)
)

  And array 2

  Array
(
[0] = Array
(
[imageID] = 6
)

[1] = Array
(
[imageID] = 3
)
)

  After intersection instead of me getting 3 as a result, I got the array
1 unchanged. Seems like intersection doesn't take place at all. Anyway to
solve this problem?

  Regards,

  Leo




Reality starts with Dream



Quote from php manual, in the reference for the array_intersect function:

*Note: * Two elements are considered equal if and only if (string) $elem1
=== (string) $elem2. In words: when the string representation is the same.

That's why array_intersect isn't working with your arrays.

If you're using PHP5 you could use array_uintersect, and compare the items
by the imageID:

   function compareByImageID($elem1, $elem2) {
   return $elem1['imageID'] - $elem2['imageID'];
   }

   $intersection = array_uinsersect($array1, $array2, 'compareByImageID');

Or you can do the following, which works in PHP4, but is not as versatile as
array_uintersect:

   class InArrayFilter {
   var $arr;

   function InArrayFilter($arr) {
   $this-arr = $arr;
   }

   function filterFunction($elem) {
   return in_array($elem, $this-arr);
   }
   }

   $filter = new InArrayFilter($array2);
   $intersection = array_filter($array1, array($filter, 'filterFunction'));


[PHP] calling a function in the same page

2006-12-25 Thread Jahangir
I am trying to call a function from a href inside the same page.
this is the code:
echo brbra href=\isearch($query)\More results from Mysite/a;
// calling the function isearch

function isearch($query)

{$query=urlencode($query);

$request='http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=Ja
hangirquery=' .urlencode($query). 'output=phpresults=100site=mysite.com;

$response=file_get_contents($request);

if ($response === false) {

die('Request failed');}

$phpobj=unserialize($response);

$count=$phpobj[ResultSet][totalResultsReturned];

if($phpobj[ResultSet][totalResultsAvailable]==0)

{echo brNO RESULTS TO DISPLAY; }

echo tr; echo h4 style=\color:#FF\ align=\center\Results from
Mysite/h4;

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

{ echo 'pre';

$no=$i+1;

$url=$phpobj[ResultSet][Result][$i][Url];

echo h3 .$no. . a href=\$url\ .
$phpobj[ResultSet][Result][$i][Title] . /a/h3; echo /tr;

echo tr; echo $phpobj[ResultSet][Result][$i][Summary]; echo
/tr;

echo br; echo tr; echo b
.$phpobj[ResultSet][Result][$i][Url] ./b; echo /tr;

echo br; $link=$phpobj[ResultSet][Result][$i][DisplayUrl];

echo tr; echo a href=\$url\$link/a; echo /tr;

echo '/pre'; }}



whenever i try to execute this function i either get an Object not found
error or Access Forbidden error.

Can someone tell me where am i going wrong here??

thanks in advance

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