Re: [PHP] Session errors when uploaded to host

2005-01-23 Thread Burhan Khalid
Tim Burgan wrote:
Hello,
I've developed my site, and tested on a web host (Apache, PHP 4.3.9).
Now I've uploaded to a different host (IIS, PHP 4.3.1) where I want to 
keep it, and I get session error messages like:

Warning: session_start() [function.session-start 
]: 
open(/tmp\sess_30f6794de4b0d80b91035c6c01aae52d, O_RDWR) failed: No such 
file or directory (2) in E:\W3Sites\ywamsa\www\timburgan\index.php on 
line 9

Warning: session_start() [function.session-start 
]: Cannot send session cookie 
- headers already sent by (output started at 
E:\W3Sites\ywamsa\www\timburgan\index.php:9) in 
E:\W3Sites\ywamsa\www\timburgan\index.php on line 9

The problem is that the php installation on this server is not 
configured correctly.  It still holds the default session location 
(/tmp) which doesn't exist on Windows PCs.

You need to ask the server administrator to verify the PHP installation 
and point the session location directory to a valid location on the server.

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


Re: [PHP] Why no type hints for built-in types?

2005-01-23 Thread Terje Slettebø
> Terje Slettebø wrote:
> > I don't find this answer satisfactory. Yes, PHP has loose/weak typing,
but
> > at any one time, a value or a variable has a distinct type. In the
example
> > in the quote above, you'd have to ensure that the value you pass is of
the
> > right type.
>
> Well, like it or not, that is the way it is.  PHP is first and foremost
> a web scripting language.  Browsers don't send a type along with each
> bit of information they send.  Everything comes across as a string and
> as such all the internal PHP functions do the right thing when you pass
> a string to a function that really takes a number.  We have no plans to
> break this and create an inconsistent set of functions that no longer do
> this.

Thanks for your reply. I can understand the reasoning for that. However,
what the request was about was _optional_ explicit typing; the standard
library didn't have to use it at all, but it would be available to users.
Many places in a web application pass values between functions, where the
type is well-known (i.e. not directly from a browser).

Nevertheless, I assume the official answer is the same, and I understand it,
if this is not a reasonably commonly requested feature.

Regards,

Terje

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



Re: [PHP] Re: Why is access and visibility mixed up in PHP?

2005-01-23 Thread Terje Slettebø
>From: "Matthew Weier O'Phinney" <[EMAIL PROTECTED]>

> * Terje Slettebø <[EMAIL PROTECTED]>:
> > (I've posted this to the PHP newsgroups, as well, but as many here might
not
> > read them, I post here, as well. I hope that's not considered
"overboard",
> > and if so, please let me know)
>
> The newsgroups are simply an NNTP interface to the mailing lists -- use
> one or the other; either way, it gets to the same place.

Ah, thanks. Sorry for the double-posts, then.

> 
> >
> > The above won't work, or at least not work as intended: The function
> > null_action() will only be visible in the class it's defined, and
therefore
> > the derived class version won't override the base class version. In
order to
> > get it to work, the access specifiers have to be changed to protected.
This
> > means that derived classes may also _call_ the function, something that
is
> > not desired. This means I can't enforce this design constraint of having
> > this function private.
> >
> > Why is it done like this?
>
> I'm not sure why the behaviour is as it is, but I do know that PHP
> developers were heavily influenced by Java when writing the new PHP5
> object model; I suspect your answers may lie there.

Yes, I think so, too, and I thought of that, as well. I think it does
something similar. I checked now: yep, it does the same there.

> One question I have to ask of you: why would you want the derived class
> to be able to know a method exists if it will not be able to call it?
> This seems to me to be... well, silly. Either the method is available to
> the class or it isn't and/or the method is available to an instantiated
> object or it isn't; visibility as being orthagonal to access just
> doesn't make a lot of sense to me. Perhaps you could make a case as to
> when this would be beneficial?

I realise that it may seem counter-intuitive or strange, but in this case it
actually makes sense: To take a practical example: A stopwatch FSM (example
from boost::fsm
(http://cvs.sourceforge.net/viewcvs.py/*checkout*/boost-sandbox/boost-sandbo
x/libs/fsm/doc/index.html?content-type=text%2Fplain&rev=1.31)). Here's a
complete, working example (except for the fsm class):

--- Start code ---

include_once("fsm.php");

// States (nested classes are not supported, so these must be at global
scope)

class active {}
class running extends active {}
class stopped extends active {}

class stopwatch_fsm extends fsm
{
  public function stopwatch_fsm()
  {
$this->fsm("stopped"); // Initial state
$this->add_transitions($this->transitions);
  }

  protected function start($from_state,$to_state)
  {
echo "Start stopwatch";
  }

  protected function stop($from_state,$to_state)
  {
echo "Stop stopwatch";
  }

  protected function reset($from_state,$to_state)
  {
echo "Reset stopwatch";
  }

  private $transitions=array(
//, , , 
array("Start/stop button", "stopped", "running","start"),
array("Start/stop button", "running", "stopped","stop"),
array("Reset button", "active", "stopped","reset"));
}

--- End code ---

To explain the above:  The FSM stopwatch_fsm contains a state "active", with
two nested states "running" and "stopped". These are modelled as classes.
The transitions between the states are defined in the above array, each line
gives a signal/initial state/final state/action for a transition. For
example, if it's in the "stopped" state, and receives a "Start/stop button"
signal, it transitions to the "running" state, and calls the start() member
function. Same for the other two defined transitions.

Test program:

include_once("stopwatch_fsm.php");

$test=new stopwatch_fsm();

$test->process("Start/stop button");
$test->process("Start/stop button");
$test->process("Start/stop button");
$test->process("Reset button");

This will print:

Start stopwatch
Stop stopwatch
Start stopwatch
Reset stopwatch

The idea is that fsm will, upon doing state transitions, call the
appropriate action functions, as member functions (here, start/stop/reset),
so these have to be defined in the derived class. Interestingly, this
actually works even if start/stop/reset are _not_ defined in the base class,
fsm (!)

I seem to have talked myself into a corner. :) As these functions are not
defined in the base class, they are _not_ overridden in the derived class;
they are merely defined there. The example I had in the original posting was
a member function that _was_ defined in the base class, and overridden in
the derived class ("null_action"). This is the member function that gets
called, if no specific action function is provided in the transition table.

In _that_ example, the derived class would need to be able to override it,
but need not be able to call it (as it's called by the base class).

I hope this makes some kind of sense... :)

(By the way, besides pear::fsm, this is also inspired by the mentioned
boost::fsm, which also uses classes to model states)

> You might also want to take some of your questions to the 

Re: [PHP] Geographical tendancies with RemoteHost

2005-01-23 Thread Jochem Maas
John Taylor-Johnston wrote:
With my counter, I track RemoteHost and IPAddress and save it in a mysql table. 
One of my colleagues asked me these questions (below).
I can track number of hits per month. Is there any OS code anywhere that I 
might implement to see geographical tendencies?
John

Is it possible to track this as a statistical graph that gives us average
hits per month over a longer period? This would be useful for further grant
applications. Also of course if we could track hits per rough geographical
regions (i.e. Quebec, Canada, North America, Latin America, Europe, Other).
Is this doable without too much effort?
php.net (can) redirect requests to the 'nearest' mirror based on your 
IP. to find out how they do this you might start by reading this source 
file:

http://www.php.net/source.php?url=/include/ip-to-country.inc
hint: they use data from http://www.ip-to-country.com/
hope that give you an idea, good luck

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


[PHP] sorting associative array

2005-01-23 Thread Jeffery Fernandez
I have the following multi-dimentional array and I want to sort it by 
the "score" key value

print_r($data);
Array
(
   [0] => Array
   (
   [video_id] => 71
   [old_id] => 7854
   [title] => When the fire comes
   [video_copies] => 1
   [running_time] => 48
   [date_published] => 06/02
   [place_published] => Australia
   [abstract] => ABC TV Gives details on many aspects of bushfires: 
...
   [library_medium_id] => 5
   [library_type] => 4
   [score] => 6.3310546875
   )
   [1] => Array
   (
   [video_id] => 9
   [old_id] => 7792
   [title] => Fire awareness
   [video_copies] => 1
   [running_time] => 15
   [date_published] => 
   [place_published] => Victoria
   [abstract] => Safetycare Australia A general video lookin.
   [library_medium_id] => 5
   [library_type] => 4
   [score] => 3.1997931003571
   )

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


Re: [PHP] Re: Why no type hints for built-in types?

2005-01-23 Thread Terje Slettebø
>From: "Matthew Weier O'Phinney" <[EMAIL PROTECTED]>

> * Terje Slettebø <[EMAIL PROTECTED]>:
> > In PHP5, you can provide "type hints" for functions, like this:
> >
> > class Person {...}
> >
> > function f(Person $p)
> > {
> >   ...
> > }
> >
> > Since this is optional static typing for objects, why not make the same
> > capability available for all types, built-in types included?
> >
> > I come from a background with generally static and strong typing (C++,
> > Java), and having worked with PHP a couple of years, I've quite a few
times
> > got bitten by stupid bugs that could have been caught by static typing,
such
> > as passing an empty string - which gets converted to 0 in an arithmetic
> > context, when the function was supposed to receive a number, or some
such,
> > and no error is reported. These bugs can be hard to find.
>
> This is where the === and !== comparison operators can come in handy, as
> they compare not only the values but the types. I often need to do this
> when checking for zeroes.

Hm, good point. However, this essentially means you have to do "manually"
what the compiler could have done. For example:

function f($a,$b,$c)
{
  assert("is_int(\$a)");
  assert("is_string(\$b)");
  assert("is_array(\$c)");

  // Actual function content here
}

At one time, I actually started to do this, but in the end, I found it
cluttered more than it helped; all those extra lines for each parameter:
clearly, the language worked against me on this. On the other hand, had I
been able to do this:

function f(int $a,string $b,array $c)
{
  // Actual function content here
}

then it would have been just fine. It also works as documentation,
specifying what the function expects (and might also specify what it
returns).

> > This has been suggested in a few Q & A's at Zend, such as this one:
> > http://www.zend.com/expert_qa/qas.php?id=104&single=1
> >
> > 
> >
> > I don't find this answer satisfactory. Yes, PHP has loose/weak typing,
but
> > at any one time, a value or a variable has a distinct type. In the
example
> > in the quote above, you'd have to ensure that the value you pass is of
the
> > right type.
>
> I can recognize that this answer would not be satisfactory for someone
> with a background in traditional application architecture. However, PHP
> has been developed from the beginning as a programming language for the
> web. Since the nature of web requests is to transfer all values as
> strings, PHP needs to be able to compare items of different types -- '0'
> needs to evaluate to the same thing as 0. This may not be optimal for
> many applications, but for most web applications to which PHP is
> applied, it is considered a *feature*.

Yes, and I'm not against the dynamic/loose typing of PHP. However, as
mentioned in the other reply to Rasmus Lerdorf, there may be areas in your
application where the types are well-defined (not from GET/POST), and where
this might help. Even with GET/POST requests, it's often recommended to
"sanitize"/check these before using the values, and in this process, you
might fix the types (you can't very well check a a value you don't know the
expected type for).

> > This would also open the door to overloading, although it seems from the
> > replies from Andi and Zeev in the Zend forums that neither optional
static
> > typing, nor overloading is considered at this time, and likely not in
the
> > future, either. :/
>
> PHP already supports overloading as you're accustomed to it -- the
> syntax is different, and PHP refers to the practice as "variable-lentgh
> argument lists". You use func_num_args(), func_get_args(), and
> func_get_arg() to accomplish it:
>
> function someOverloadedFun()
> {
> $numargs = func_num_args();
> $args= func_get_args();
> if (0 == $numargs) {
> return "ERROR!";
> }
> if (1 == $numargs) {
> if (is_string($args[0])) {
> return "Received string: $args[0]";
> } elseif (is_object($args[0])) {
> return "Received object!";
> }
> } elseif ((2 == $numargs)) {
> return "Received arg0 == $args[0] and arg1 == $args[1]";
> }
> // etc.
> }
>
> Yes, this is more cumbersome than providing hints

Indeed, and it means all the selection have to be done in _one_ function.
Sure, varargs can give you some kind of overloading, but as with using
assert and is_* above, to check for incoming types, you essentially have to
"manually" provide the overloading (by checking argument number and types,
and dispatching appropriately), and then the alternative of using
differently named functions really look more appealing...

Besides, this makes the "switch function" a dependency hog: Every
"overloaded" function you add means you have to change it. If it's in a
third-party library, this may not be useful option.

> > There's a rather lively discussion about adding optional static typing
in
> > Python (http://www.artima.com/weblogs/viewpost.jsp?thread=85551), and
unless
> > it 

Re: [PHP] Re: Why is access and visibility mixed up in PHP?

2005-01-23 Thread Jochem Maas
Terje Slettebø wrote:
From: "Matthew Weier O'Phinney" <[EMAIL PROTECTED]>


Ah, I didn't know about that one. I didn't find it here:
http://www.php.net/mailing-lists.php How can I subscribe to it?
its alternatively call 'php internals', I have read a lot of your 
questions/arguments regarding access/visibility/typehints - some of them 
seem more a case of you needing to adjust to PHP's way of thinking that 
that PHP necessarily does it wrong (its just very different to C/Java 
:-), then again other points you make are valid - either way I'm not the 
one to judge --- I just thought I'd mention that such things have been 
discussed/argued over on the php internals mailing list in some depth 
over the last year, i.e. you may get very short answers :-)

Regards,
Terje
P.S. Why does replies to list posting go to the sender, rather than the
list, by default? Shouldn't reply-to be set to the list, as usual? I had to
manually edit the address, to make the reply go to the list.
don't even start about these mailing list setups! - be glad they work at 
all :-) - btw, it seems, that on php mailing lists reply-all is the norm 
and that bottom-post are generally preferred to top-posts.

PS - I enjoyed your posts!

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


Re: [PHP] Re: Why no type hints for built-in types?

2005-01-23 Thread Jochem Maas
Terje Slettebø wrote:
...
I certainly know that a number of bugs I've encountered could have been
found with type hints for built-in types, so I think it would be useful. The
question, of course, is whether most PHP developers don't think so. Also, we
don't have any experience with it in PHP.
Personally I like PHP(5) the way it is now - rather than keep adding new 
functionality I would rather welcome bew/better documentation (not a dig 
at the dev or the docteam - I know that there are difficult issues AND 
that writing docs is a, hard and b, often is thankless task!) on SPL etc

and I do wish they had left the 'bug' in that allowed syntax like:
function (MyClass $var = null)
{
...
}
but they didn't so I changed my code - basically I don't always agree 
with what the dev decide to do with the tool I use most to earn money BUT:

1. these guys are all better 'hackers' than me.
2. they hand out their work from free.
3. life is a box of choloclates... and God doesn't give a  as to 
whether I like the cherry fillings or not :-)

rgds,
Jochem.
Thanks for your replies.
Regards,
Terje
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Xemacs indentation for php

2005-01-23 Thread dayton

I recently saw a super mode that does just what you want.
Try this link http://www.emacswiki.org/cgi-bin/wiki/HtmlModeDeluxe

dayton


> "Song" == Song Ken Vern-E11804 <[EMAIL PROTECTED]> writes:

Song> Hi, I would like the behaviour of turning on the cc-mode
Song> indentation in the  tags but turning off when escaping and
Song> doing html.

Song> I have been looking at the cc-engine.el source and can't seem to
Song> find the place where I should change.

Song> Is this behaviour possible?

Song> thanx

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



Re: [PHP] sorting associative array

2005-01-23 Thread Jochem Maas
Jeffery Fernandez wrote:
I have the following multi-dimentional array and I want to sort it by 
the "score" key value
...
any ideas. Thanks
A long time ago I had this problem, came up with the following class (based 
on
someone else's stuff that I found in the comments section of the php manual) to
handle it for me. its probably a rubbish way of doing it (look forward to
some clever bar steward showing us how do it in 3 lines. :-) ) - there are 
usage examples
at the bottom:
http://www.php.net/usort\>
 * @author  Jochem Maas <[EMAIL PROTECTED]>
 *
 * $Id: MDASort.class.php,v 1.1 2004/08/03 13:38:37 jochem Exp $
 *
 */
/**
 * This file and its contents is not copyrighted;
 * The contents are free to be used by anybody under any conditions.
 */
class MDASort {
private $dataArray; //the array we want to sort.
private $sortKeys;  //the order in which we want the array to be sorted.
function __construct()
{
if ($cnt = func_num_args()) {
$args = func_get_args();
if (isset($args[0])) {
$this->setData($args[0]);
}
if (isset($args[1])) {
$this->setSortKeys($args[1]);
}
if (isset($args[2]) && $args[2] === true) {
$this->sort();
}
}
}
function _sortcmp($a, $b, $i=0)
{
   $r = strnatcmp($a[$this->sortKeys[$i][0]],$b[$this->sortKeys[$i][0]]);
   if ($this->sortKeys[$i][1] == "DESC") $r = $r * -1;
   if($r==0) {
   $i++;
   if ($this->sortKeys[$i]) $r = $this->_sortcmp($a, $b, $i);
   }
   return $r;
}
function sort()
{
   if(count($this->sortKeys)) {
   usort($this->dataArray, array($this,"_sortcmp"));
   }
}
function setData($dataArray = array())
{
$this->dataArray = $dataArray;
}
function setSortKeys($sortKeys = array())
{
$this->sortKeys = $sortKeys;
}
function getData()
{
return $this->dataArray;
}
function getSortKeys()
{
return $this->sortKeys;
}
}
/* example of usage */
/*
$sorter = new MDASort;
$sorter->setData( array(
   array("name" => "hank", "headsize" => "small", "age" => 32),
   array("name" => "sade", "headsize" => "petit", "age" => 36),
   array("name" => "hank", "headsize" => "large", "age" => 33),
   array("name" => "sade", "headsize" => "large", "age" => 32),
   array("name" => "john", "headsize" => "large", "age" => 32),
   array("name" => "hank", "headsize" => "small", "age" => 36),
   array("name" => "hank", "headsize" => "small", "age" => 40)
));
$sorter->setSortKeys( array(
   array('name','ASC'),
   array('headsize','DESC'),
   array('age','ASC'),
));
$sorter->sort();
$sortedArray = $sorter->getData();
*/
/* 2nd example of usage */
/*
$data = array(
   array("name" => "hank", "headsize" => "small", "age" => 32),
   array("name" => "sade", "headsize" => "petit", "age" => 36),
   array("name" => "hank", "headsize" => "large", "age" => 33),
   array("name" => "sade", "headsize" => "large", "age" => 32),
   array("name" => "john", "headsize" => "large", "age" => 32),
   array("name" => "hank", "headsize" => "small", "age" => 36),
   array("name" => "hank", "headsize" => "small", "age" => 40)
);
$sort = array(
   array('name','ASC'),
   array('headsize','DESC'),
   array('age','ASC'),
);
$sorter = new MDASort($data, $sort);
$sorter->sort();
$sortedArray = $sorter->getData();
*/
/* 3rd example of usage */
/*
$data = array(
   array("name" => "hank", "headsize" => "small", "age" => 32),
   array("name" => "sade", "headsize" => "petit", "age" => 36),
   array("name" => "hank", "headsize" => "large", "age" => 33),
   array("name" => "sade", "headsize" => "large", "age" => 32),
   array("name" => "john", "headsize" => "large", "age" => 32),
   array("name" => "hank", "headsize" => "small", "age" => 36),
   array("name" => "hank", "headsize" => "small", "age" => 40)
);
$sort = array(
   array('name','ASC'),
   array('headsize','DESC'),
   array('age','ASC'),
);
$sorter = new MDASort($data, $sort, true);  // auto sort
$sortedArray = $sorter->getData();
*/
Jeffery
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] sorting associative array

2005-01-23 Thread Kurt Yoder
Use usort (stealing from php docs):

function cmp($a['score'], $b['score'])
{
   if ($a['score'] == $b['score']) {
   return 0;
   }
   return ($a['score'] < $b['score']) ? -1 : 1;
}
$data = array(...);
usort($data, "cmp");

On Jan 23, 2005, at 8:39 AM, Jeffery Fernandez wrote:
I have the following multi-dimentional array and I want to sort it by 
the "score" key value

print_r($data);
Array
(
   [0] => Array
   (
   [video_id] => 71
   [old_id] => 7854
   [title] => When the fire comes
   [video_copies] => 1
   [running_time] => 48
   [date_published] => 06/02
   [place_published] => Australia
   [abstract] => ABC TV Gives details on many aspects of 
bushfires: ...
   [library_medium_id] => 5
   [library_type] => 4
   [score] => 6.3310546875
   )

   [1] => Array
   (
   [video_id] => 9
   [old_id] => 7792
   [title] => Fire awareness
   [video_copies] => 1
   [running_time] => 15
   [date_published] =>[place_published] => Victoria
   [abstract] => Safetycare Australia A general video 
lookin.
   [library_medium_id] => 5
   [library_type] => 4
   [score] => 3.1997931003571
   )

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

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


RE: [PHP] Is this even possible?

2005-01-23 Thread Mikey


-Original Message-
From: Tony Di Croce [mailto:[EMAIL PROTECTED] 
Sent: 22 January 2005 23:21
To: php-general@lists.php.net
Subject: [PHP] Is this even possible?

Is it even possible to connect to a postgres server (thats running on
linux) from a windows CLI php script?

I'm seeing a pg_connect() error... FATAL: no pg_hba.conf  entry for
host 192.168.1.100

Any ideas?

You will need to install the client libraries, as you would for any database
- you will need to go to the Postgres web-site for details of how to do
that.

HTH,

Mikey

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



[PHP] Lost connection to mysql db. Plus I could use some help

2005-01-23 Thread Jimbob
Good morning. In Windows XP, MYSQL, PHP and using the following code
snippet:



I initially was successful. However, about 5 hours later, as I was exploring
how to SELECT and UPDATE to my db in PHP, I was not able to see any values
returned. I ran the snippet above and the only msg I can get is 'Can't
Select Database'. However when I drop the $db line, I get no msg at all. Any
Ideas would be appreciated with a caveat.

I am building a commercial site for myself. The concept documents can be
found at POTBOWLING.COM. I cannot pay anyone for assisting me unless we have
a prior arrangement and until this thing gets off the ground bringing in
real income. Please do not send any response with the intent of making
claims against the project later unless we have an understanding.

I have already run this thing back in the '80's on a DOS based BATCH process
system, and after three failed attempts and all my money to get others to
write the code in the Web World, I am going to do it my self. At least the
proof of concept which will prove the functionality, without the bells and
whistles, that this can work, at which point I hope to acquire funding to
build the security and beef up the code, look and feel of the website. I do
have interested parties waiting to see what I can develop who are willing to
move this along.

So, with that in mind and an understanding that if you can help now, and
this thing goes, I will need a solid staff to help develop and then maintain
this project. Once this one is up and running I have also done another DOS
based project in the Golfing world.  I welcome your assistance. Please reply
directly to
[EMAIL PROTECTED]

Jim Yeatrakas
Charleston SC.


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



[PHP] array search

2005-01-23 Thread Malcolm

Hello All,
  I've been trying for days now to make this work.
I'm trying to search my array for a value and return the key.
I get the visitor's IP and try this  -- this is the latest,
I've tried a few functions to echo the name associated with the viz_ip.
$viz_ip= $_SERVER['REMOTE_ADDR'];
$byte_ip= array(
"204.126.202.56"=>"Mark",
"63.230.76.166"=>"Bob",
"63.220.76.165"=>"John",
);
function _array_search ($viz_ip, $byte_ip) {
   foreach($byte_ip as $key => $val) {
   if ($viz_ip === $key) {
   return($val);
   }
   }
   return(False);
   }
I'm no wiz but this shouldn't be this hard, maybe I'm thinking wrong.
I've read the examples at php.net but I just can't get it. Some help
or even a hint ?
best regards,
malcolm
--
O
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] array search

2005-01-23 Thread Jochem Maas
Malcolm wrote:

Hello All,
  I've been trying for days now to make this work.
I'm trying to search my array for a value and return the key.
I get the visitor's IP and try this  -- this is the latest,
I've tried a few functions to echo the name associated with the viz_ip.
$viz_ip= $_SERVER['REMOTE_ADDR'];
$byte_ip= array(
"204.126.202.56"=>"Mark",
"63.230.76.166"=>"Bob",
"63.220.76.165"=>"John",
);
function _array_search ($viz_ip, $byte_ip) {
   foreach($byte_ip as $key => $val) {
   if ($viz_ip === $key) {
   return($val);
   }
   }
   return(False);
   }
try:
function getValueInArr($val, $arr)
{
$val = (string)$val;
return is_array($arr) && isset($arr[$val]) ? $arr[$val]: false;
}
but maybe the $viz_ip really _isn't_ set in the array you have?
I'm no wiz but this shouldn't be this hard, maybe I'm thinking wrong.
I've read the examples at php.net but I just can't get it. Some help
or even a hint ?
best regards,
malcolm

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


Re: [PHP] array search

2005-01-23 Thread john
> I've been trying for days now to make this work.

This worked for me (with my IP address for 'John'):

"Mark",

"63.230.76.166"=>"Bob",

"84.196.101.86"=>"John",
);

function _array_search ($viz_ip, $byte_ip) {

foreach($byte_ip as $key => $val) {

if ($viz_ip === $key) {
return($val);
}

}

return(False);
}



?>


Hi 

J

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



Re: [PHP] array search

2005-01-23 Thread Malcolm
Thank you Sirs,
  I was echoing the viz-ip so I know it was getting set but
I couldn't get it.
  both work  ..  I got the clue from John, the last echo line did the  
trick.

On Sun, 23 Jan 2005 17:26:58 +0100, Jochem Maas <[EMAIL PROTECTED]>  
wrote:

Malcolm wrote:
  Hello All,
   I've been trying for days now to make this work.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] array search

2005-01-23 Thread Ben Edwards
probably missing something but php have a function called array_search.

Ben

On Sun, 23 Jan 2005 11:33:16 -0500 (EST), [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> > I've been trying for days now to make this work.
> 
> This worked for me (with my IP address for 'John'):
> 
>  $viz_ip= $_SERVER['REMOTE_ADDR'];
> echo ("Your IP is $viz_ip");
> 
> $byte_ip= array(
> 
> "204.126.202.56"=>"Mark",
> 
> "63.230.76.166"=>"Bob",
> 
> "84.196.101.86"=>"John",
> );
> 
> function _array_search ($viz_ip, $byte_ip) {
> 
> foreach($byte_ip as $key => $val) {
> 
> if ($viz_ip === $key) {
> return($val);
> }
> 
> }
> 
> return(False);
> }
> 
> 
> ?>
> 
> Hi 
> 
> J
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
Ben Edwards - Poole, UK, England
WARNING:This email contained partisan views - dont ever accuse me of
using the veneer of objectivity
If you have a problem emailing me use
http://www.gurtlush.org.uk/profiles.php?uid=4
(email address this email is sent from may be defunct)

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



[PHP] Re: array search

2005-01-23 Thread M. Sokolewicz
Malcolm wrote:

Hello All,
  I've been trying for days now to make this work.
I'm trying to search my array for a value and return the key.
I get the visitor's IP and try this  -- this is the latest,
I've tried a few functions to echo the name associated with the viz_ip.
$viz_ip= $_SERVER['REMOTE_ADDR'];
$byte_ip= array(
"204.126.202.56"=>"Mark",
"63.230.76.166"=>"Bob",
"63.220.76.165"=>"John",
);
function _array_search ($viz_ip, $byte_ip) {
   foreach($byte_ip as $key => $val) {
   if ($viz_ip === $key) {
   return($val);
   }
   }
   return(False);
   }
I'm no wiz but this shouldn't be this hard, maybe I'm thinking wrong.
I've read the examples at php.net but I just can't get it. Some help
or even a hint ?
best regards,
malcolm
I might be the only one to notice here, but you don't want to find the 
KEY, you want to find the VALUE. Otherwise, you'll need to assemble your 
array differently.

$viz_ip= $_SERVER['REMOTE_ADDR'];
$byte_ip= array(
   "204.126.202.56"=>"Mark",
   "63.230.76.166"=>"Bob",
   "63.220.76.165"=>"John"
);
That means:
$byte_ip[$viz_ip] = some_name;
That's because you have ips set as your *keys*, and not your values. To 
do what you wanted, simply either:
a) reverse the array, making keys values and values keys:
$byte_ip= array(
   "Mark"=>"204.126.202.56",
   "Bob"=>"63.230.76.166",
   "John"=>"63.220.76.165"
);

or:
b) change the function to match on key (for which you don't *need* a 
function).

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


[PHP] Re: array search

2005-01-23 Thread Malcolm
Ah so  -- array_search only works on values ?
 That probably accounts for my first day or so, thanks.
I've got it now.
On Sun, 23 Jan 2005 19:22:32 +0100, M. Sokolewicz <[EMAIL PROTECTED]> wrote:
Malcolm wrote:
  Hello All,
   I've been trying for days now to make this work.
I'm trying to search my array for a value and return the key.
I get the visitor's IP and try this  -- this is the latest,
I've tried a few functions to echo the name associated with the viz_ip.
  $viz_ip= $_SERVER['REMOTE_ADDR'];
 $byte_ip= array(
 "204.126.202.56"=>"Mark",
 "63.230.76.166"=>"Bob",
 "63.220.76.165"=>"John",
);
 function _array_search ($viz_ip, $byte_ip) {
foreach($byte_ip as $key => $val) {
if ($viz_ip === $key) {
   return($val);
   }
}
return(False);
   }
  I'm no wiz but this shouldn't be this hard, maybe I'm thinking wrong.
I've read the examples at php.net but I just can't get it. Some help
or even a hint ?
 best regards,
malcolm
I might be the only one to notice here, but you don't want to find the  
KEY, you want to find the VALUE. Otherwise, you'll need to assemble your  
array differently.

$viz_ip= $_SERVER['REMOTE_ADDR'];
$byte_ip= array(
"204.126.202.56"=>"Mark",
"63.230.76.166"=>"Bob",
"63.220.76.165"=>"John"
);
That means:
$byte_ip[$viz_ip] = some_name;
That's because you have ips set as your *keys*, and not your values. To  
do what you wanted, simply either:
a) reverse the array, making keys values and values keys:
$byte_ip= array(
"Mark"=>"204.126.202.56",
"Bob"=>"63.230.76.166",
"John"=>"63.220.76.165"
);

or:
b) change the function to match on key (for which you don't *need* a  
function).

- Tul

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


[PHP] php-db@lists.php.net

2005-01-23 Thread Ralph Frost
I had a php routine on a shared server running as a CGI script that 
encrypted and sent email text.

It was running fine under PHP version 4.3.6. Then the ISP upgraded to 
4.3.10  on December 16, 2004 and several of the features in the gpg 
encryption script running in cgi-bin stopped working.

phpinfo()  in a script run from cgi-bin reports  Server 
API  =  Apache.Isn't it supposed to be CGI??

Initially, fopen(),  mail(), and the passthru( ) of the gpg command  would 
not work.

The ISP did something, and  got it back so fopen() and mail() works, but 
files are still being created as "nobody nobody".  The gpg command that 
works from the shell, returns result=2  when run through the script.

I've tried shell_exec() also.
Isn't running the script in cgi-bin  SUPPOSED TO run as myusername rather 
than as nobody?

What mistakes m I making?  Is this a php upgrade/configuration problem that 
the ISP needs to look at,  or it is a general security issue which used to 
work but  now is not going to be allowed... and the ISP doesn't want to 
tell me?

Any thoughts or suggestions, inside or outside the box on how I can get 
back to the same functionality as I had before December 16, 2004?

Thank you in advance for any help you can offer.
Best regards,
Ralph Frost
Imagine consciousness as a single internal analog language
made of ordered water, fabricated on-the-fly during respiration.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Jason

2005-01-23 Thread Tamas Hegedus
Dear Jason,
Thanks!
Such a stupid misstake (however in the earlier version of php I did not
received any notice). But I am not a programmer  ;-)
Regards,
Tamas
>> On Saturday 22 January 2005 08:28, Tamas Hegedus wrote:
>>
>
 define( HOST, 'localhost');
>
>>
>>   define('HOST', 'localhost');
>>
>> --
>> 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
>> --
>> New Year Resolution: Ignore top posted posts
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
--
Tamas Hegedus, Research Fellow | phone: (1) 480-301-6041
Mayo Clinic Scottsdale | fax:   (1) 480-301-7017
13000 E. Shea Blvd | mailto:[EMAIL PROTECTED]
Scottsdale, AZ, 85259  | http://hegedus.brumart.org
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Attempting to use 'passthru' or 'exec' function

2005-01-23 Thread Andre Dubuc
Hi, 

I'm trying to output a text file from a pdf file using an external function, 
pdftotext, using either PHP's 'passthru' or 'exec' functions.

The following code sort of works (at least I see localhost busy doing 
something for about three seconds, but  the expected output of 'content.txt' 
is empty. I used an idea found on the mailing list: I actually got some 
activity with 'sudo desired_function arg1 arg2'.

File permissions are set wide open (apache:apache 777), safe_mode=off.

What am I doing wrong? (Btw, the pdftotext function works fine on 
commandline).

$Pdf";

passthru("sudo pdftotext /var/www/html/2005-o1-v2.pdf.txt 
/var/www/html/current.txt");
*/

$current = "current.txt";

print "Current Text: $current";
$string_text = file_get_contents("current.txt");
$new_text = nl2br("$string_text");

?>

Any help, pointers, admonitions gratefully accepted,
Tia,
Andre

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



RE: [PHP] Attempting to use 'passthru' or 'exec' function

2005-01-23 Thread Mikey

Have you tried using the backtick (``) operator?  I don't know if it makes
any difference, but it might be worth a try...

HTH,

Mikey
-Original Message-
From: Andre Dubuc [mailto:[EMAIL PROTECTED] 
Sent: 23 January 2005 21:08
To: php-general@lists.php.net
Subject: [PHP] Attempting to use 'passthru' or 'exec' function

Hi, 

I'm trying to output a text file from a pdf file using an external function,

pdftotext, using either PHP's 'passthru' or 'exec' functions.

The following code sort of works (at least I see localhost busy doing 
something for about three seconds, but  the expected output of 'content.txt'

is empty. I used an idea found on the mailing list: I actually got some 
activity with 'sudo desired_function arg1 arg2'.

File permissions are set wide open (apache:apache 777), safe_mode=off.

What am I doing wrong? (Btw, the pdftotext function works fine on 
commandline).

$Pdf";

passthru("sudo pdftotext /var/www/html/2005-o1-v2.pdf.txt 
/var/www/html/current.txt");
*/

$current = "current.txt";

print "Current Text: $current";
$string_text = file_get_contents("current.txt");
$new_text = nl2br("$string_text");

?>

Any help, pointers, admonitions gratefully accepted,
Tia,
Andre

-- 
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] Re: Why is access and visibility mixed up in PHP?

2005-01-23 Thread Terje Slettebø
>From: "Jochem Maas" <[EMAIL PROTECTED]>

> Terje Slettebø wrote:
> >>From: "Matthew Weier O'Phinney" <[EMAIL PROTECTED]>
> >
> > Ah, I didn't know about that one. I didn't find it here:
> > http://www.php.net/mailing-lists.php How can I subscribe to it?
>
> its alternatively call 'php internals'

Ah. I thought that was something else.

>, I have read a lot of your
> questions/arguments regarding access/visibility/typehints - some of them
> seem more a case of you needing to adjust to PHP's way of thinking that
> that PHP necessarily does it wrong (its just very different to C/Java
> :-),

That may well be. :) As mentioned, I've worked with PHP a couple of years,
but have been doing C++/Java much longer (and C before that). I have started
to adjust to the dynamic nature of PHP, and as mentioned in another post,
about variable variable functions and variables, there are some useful
things that this enables, as well.

Nonetheless, the discussion of explicit/implicit typing is a valid one, and
my posts were not at least meant to see what other people think, and if
there are other approaches that kind of compensate for the risk of bugs with
implicit/dynamic typing. Guido van Rossum (Python's creator) and some others
have argued that unit tests may make up for it. Well, unit tests are nice,
but with type checking by the compiler/runtime, you may concentrate on the
non-trivial tests instead, rather than testing something the
compiler/runtime is perfectly able to do by itself.

> then again other points you make are valid - either way I'm not the
> one to judge --- I just thought I'd mention that such things have been
> discussed/argued over on the php internals mailing list in some depth
> over the last year, i.e. you may get very short answers :-)

Well, but this is great news. :) I.e. then I have a place to look. As I said
at the start, I hadn't found discussion about this, but then, I haven't
really known which archive(s) to search, either.

Of course, people won't have to go into a discussion that has happened
before; just point to a previous one, as you did. :)

> > P.S. Why does replies to list posting go to the sender, rather than the
> > list, by default? Shouldn't reply-to be set to the list, as usual? I had
to
> > manually edit the address, to make the reply go to the list.
>
> don't even start about these mailing list setups!

LOL. :) Apparently a recurring theme. :)

> - be glad they work at
> all :-) - btw, it seems, that on php mailing lists reply-all is the norm

I use reply-all, but that also includes the sender as recipient, which I
usually edit out: No need to give them two copies of a posting.

> and that bottom-post are generally preferred to top-posts.

Aren't they everywhere. ;)

> PS - I enjoyed your posts!

Thanks. :) I haven't received any flames, yet, at least. :) I didn't really
know how they would be received, given that I don't know the community.
(I've usually been hanging around the ACCU lists, as well as Boost, and
comp.lang.c++.moderated, comp.std.c++, so I mostly know the C++ community.)

Regards,

Terje

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



Re: [PHP] sorting associative array

2005-01-23 Thread Jeffery Fernandez
Kurt Yoder wrote:
Use usort (stealing from php docs):

function cmp($a['score'], $b['score'])
{
   if ($a['score'] == $b['score']) {
   return 0;
   }
   return ($a['score'] < $b['score']) ? -1 : 1;
}
$data = array(...);
usort($data, "cmp");

This won't work for me as I have 500+ records to sort based on the score 
key.. looking at jochem's class now. Thanks

Jeffery
On Jan 23, 2005, at 8:39 AM, Jeffery Fernandez wrote:
I have the following multi-dimentional array and I want to sort it by 
the "score" key value

print_r($data);
Array
(
   [0] => Array
   (
   [video_id] => 71
   [old_id] => 7854
   [title] => When the fire comes
   [video_copies] => 1
   [running_time] => 48
   [date_published] => 06/02
   [place_published] => Australia
   [abstract] => ABC TV Gives details on many aspects of 
bushfires: ...
   [library_medium_id] => 5
   [library_type] => 4
   [score] => 6.3310546875
   )

   [1] => Array
   (
   [video_id] => 9
   [old_id] => 7792
   [title] => Fire awareness
   [video_copies] => 1
   [running_time] => 15
   [date_published] =>[place_published] => Victoria
   [abstract] => Safetycare Australia A general video 
lookin.
   [library_medium_id] => 5
   [library_type] => 4
   [score] => 3.1997931003571
   )

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

--
Kurt Yoder
http://yoderhome.com

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


[PHP] skip file_get_contents

2005-01-23 Thread Ahmed Abdel-Aliem
hi, i have a script that parses data from xml document
my problem is sometimes i get error when getting file content from xml
file fails
so how can u make the script ignore that part when it fails to pull
the data from the xml file.

here is the script :

$xp = xml_parser_create();
xml_set_character_data_handler($xp,'h_char');
xml_set_element_handler($xp,'h_estart','h_eend');
$listing = 0;
$found_listings = array();
$tag_name = '';

xml_parse($xp,file_get_contents("http://someXMLdocument.xml";));

function h_char($xp,$cdata) {
global $listing, $tag_name;
if (is_array($listing) and $tag_name) {
$listing[$tag_name] .=
str_replace(''',"'",str_replace('&','&',str_replace('\\$','$',$cdata)));
}
return true;
}

function h_estart($xp,$name,$attr) {
global $listing, $tag_name;
if ($name == 'SITE') {
$listing = array();
}
else {
$tag_name = strtolower($name);
}
return true;
}

function h_eend($xp,$name) {
global $listing, $tag_name, $found_listings;
if ($name == 'SITE') {
$found_listings[] = $listing;
$listing = null;
}
$tag_name = '';
return true;
}

echo "hi, i am xml data"
xml_parser_free($xp);

can anyone help me with that please?
-- 
Ahmed Abdel-Aliem
Web Developer
www.ApexScript.com
0101108551

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



Re: [PHP] Session errors when uploaded to host

2005-01-23 Thread Jerry Kita
Burhan Khalid wrote:
Tim Burgan wrote:
Hello,
I've developed my site, and tested on a web host (Apache, PHP 4.3.9).
Now I've uploaded to a different host (IIS, PHP 4.3.1) where I want to 
keep it, and I get session error messages like:

Warning: session_start() [function.session-start 
]: 
open(/tmp\sess_30f6794de4b0d80b91035c6c01aae52d, O_RDWR) failed: No 
such file or directory (2) in 
E:\W3Sites\ywamsa\www\timburgan\index.php on line 9

Warning: session_start() [function.session-start 
]: Cannot send session 
cookie - headers already sent by (output started at 
E:\W3Sites\ywamsa\www\timburgan\index.php:9) in 
E:\W3Sites\ywamsa\www\timburgan\index.php on line 9

The problem is that the php installation on this server is not 
configured correctly.  It still holds the default session location 
(/tmp) which doesn't exist on Windows PCs.

You need to ask the server administrator to verify the PHP installation 
and point the session location directory to a valid location on the server.
You also have the option of creating your own session location directory 
by inserting the following at the beginning of each script.

session_save_path('...public/tmp');
I happen to do this because my hosting company uses load balancing which 
means I can never know what server is processing my PHP script. I place 
my session location in a tmp folder in my public directory. Otherwise I 
would lose my session variables periodically.

--
Jerry Kita
http://www.salkehatchiehuntersville.com
email: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] sessions

2005-01-23 Thread Sam Webb
I've installed Apache 2 and PHP 5 on Windows XP, and I'm having some
issues with sessions. Everything else I've tried to do in PHP works
fine, but for some reason every time I try to use session_start() i
get the following errors:

Warning: session_start() [function.session-start]:
open(C:\PHP\sessiondata\sess_29eb1a211c118cc8083168f24e32ee75, O_RDWR)
failed: No such file or directory (2) in C:\Program Files\Apache
Group\Apache2\htdocs\Games\main.php on line 3

Warning: session_start() [function.session-start]: Cannot send session
cookie - headers already sent by (output started at C:\Program
Files\Apache Group\Apache2\htdocs\Games\main.php:3) in C:\Program
Files\Apache Group\Apache2\htdocs\Games\main.php on line 3

Warning: session_start() [function.session-start]: Cannot send session
cache limiter - headers already sent (output started at C:\Program
Files\Apache Group\Apache2\htdocs\Games\main.php:3) in C:\Program
Files\Apache Group\Apache2\htdocs\Games\main.php on line 3

Any suggestions?

Sam

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



[PHP] PHP Application server

2005-01-23 Thread Devraj Mukherjee
We are evaulating the idea of writing a PHP application server. Its aimed
to be a stateful environment for writing PHP applications and we believe
it will be quite advantegous to the entire community.

Any ideas if there are a similar solutions that already exists out there,
and what is the general feel of a solution like this.

Thanks for your time and feedback.

Devraj

---
Devraj Mukherjee ([EMAIL PROTECTED])
Eternity Technologies Pty. Ltd. ACN 107 600 975
P O Box 5949 Wagga Wagga NSW 2650 Australia
Voice: +61-2-69717131 / Fax: +61-2-69251039
http://www.eternitytechnologies.com/

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



Re: [PHP] Session errors when uploaded to host

2005-01-23 Thread Tim Burgan
Thankyou. That solved the issue.
I didn't know that function existed.
Tim
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Attempting to use 'passthru' or 'exec' function

2005-01-23 Thread Jason Wong
On Monday 24 January 2005 05:08, Andre Dubuc wrote:

> I'm trying to output a text file from a pdf file using an external
> function, pdftotext, using either PHP's 'passthru' or 'exec' functions.
>
> The following code sort of works (at least I see localhost busy doing
> something for about three seconds, but  the expected output of
> 'content.txt' is empty. I used an idea found on the mailing list: I
> actually got some activity with 'sudo desired_function arg1 arg2'.
>
> File permissions are set wide open (apache:apache 777), safe_mode=off.
>
> What am I doing wrong? (Btw, the pdftotext function works fine on
> commandline).

1) What does your php error log say?
2) Is there any reason you're using sudo? Do you know how it works and have 
you configured sudo correctly?
3) Commands like passthru() and exec() allow you to check the return value of 
the system command being executed -- use it.

-- 
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
--
New Year Resolution: Ignore top posted posts

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



[PHP] Re: Lost connection to mysql db. Plus I could use some help

2005-01-23 Thread robleyd
> Good morning. In Windows XP, MYSQL, PHP and using the following code
> snippet:
> 
>  $conn = mysql_connect('localhost', 'odbc', '') or die ("Can't Connect To
> Database");
> $db = mysql_select_db("wwpbt", "$conn") or die ("Can't Select Database");

Change the above line to the following for a more useful error message from 
mysql:
$db = mysql_select_db("wwpbt", "$conn") or die ("Can't Select Database". 
mysql_error());

> $echo ("Congratulations - you connected to MySQL");
> ?>


This message was sent through MyMail http://www.mymail.com.au

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



Re: [PHP] sorting associative array

2005-01-23 Thread Jochem Maas
Jeffery Fernandez wrote:
Kurt Yoder wrote:
Use usort (stealing from php docs):

function cmp($a['score'], $b['score'])
{
   if ($a['score'] == $b['score']) {
   return 0;
   }
   return ($a['score'] < $b['score']) ? -1 : 1;
}
$data = array(...);
usort($data, "cmp");

This won't work for me as I have 500+ records to sort based on the score 
key.. looking at jochem's class now. Thanks
which wont help much - assuming what you say is true
(why wont it work? have you tried it).
sort method from the class:
function sort()
{
   if(count($this->sortKeys)) {
   usort($this->dataArray, array($this,"_sortcmp"));
   }
}

Jeffery
On Jan 23, 2005, at 8:39 AM, Jeffery Fernandez wrote:
I have the following multi-dimentional array and I want to sort it by 
the "score" key value

print_r($data);
Array
(
   [0] => Array
   (
   [video_id] => 71
   [old_id] => 7854
   [title] => When the fire comes
   [video_copies] => 1
   [running_time] => 48
   [date_published] => 06/02
   [place_published] => Australia
   [abstract] => ABC TV Gives details on many aspects of 
bushfires: ...
   [library_medium_id] => 5
   [library_type] => 4
   [score] => 6.3310546875
   )

   [1] => Array
   (
   [video_id] => 9
   [old_id] => 7792
   [title] => Fire awareness
   [video_copies] => 1
   [running_time] => 15
   [date_published] =>[place_published] => Victoria
   [abstract] => Safetycare Australia A general video 
lookin.
   [library_medium_id] => 5
   [library_type] => 4
   [score] => 3.1997931003571
   )

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

--
Kurt Yoder
http://yoderhome.com


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


Re: [PHP] sorting associative array

2005-01-23 Thread Jeffery Fernandez
Jochem Maas wrote:
Jeffery Fernandez wrote:
Kurt Yoder wrote:
Use usort (stealing from php docs):

function cmp($a['score'], $b['score'])
{
   if ($a['score'] == $b['score']) {
   return 0;
   }
   return ($a['score'] < $b['score']) ? -1 : 1;
}
$data = array(...);
usort($data, "cmp");

This won't work for me as I have 500+ records to sort based on the 
score key.. looking at jochem's class now. Thanks

which wont help much - assuming what you say is true
(why wont it work? have you tried it).
sort method from the class:
function sort()
{
   if(count($this->sortKeys)) {
   usort($this->dataArray, array($this,"_sortcmp"));
   }
}

Thanks jochem, I had a second look at it and I figured it out. I had 
problem implementing it with a class but now I have figured how to use it.

cheers,
Jeffery

Jeffery
On Jan 23, 2005, at 8:39 AM, Jeffery Fernandez wrote:
I have the following multi-dimentional array and I want to sort it 
by the "score" key value

print_r($data);
Array
(
   [0] => Array
   (
   [video_id] => 71
   [old_id] => 7854
   [title] => When the fire comes
   [video_copies] => 1
   [running_time] => 48
   [date_published] => 06/02
   [place_published] => Australia
   [abstract] => ABC TV Gives details on many aspects of 
bushfires: ...
   [library_medium_id] => 5
   [library_type] => 4
   [score] => 6.3310546875
   )

   [1] => Array
   (
   [video_id] => 9
   [old_id] => 7792
   [title] => Fire awareness
   [video_copies] => 1
   [running_time] => 15
   [date_published] =>[place_published] => 
Victoria
   [abstract] => Safetycare Australia A general video 
lookin.
   [library_medium_id] => 5
   [library_type] => 4
   [score] => 3.1997931003571
   )

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

--
Kurt Yoder
http://yoderhome.com



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


[PHP] Zend Performance Suite 3.6 and PHP5

2005-01-23 Thread Lars B. Jensen
I've taken over the system administration of our servers, and have been 
migrating from PHP4 on Redhat, to PHP5 on a FreeBSD system setup.

Few questions,
Is this version of the ZPS compatible with PHP5, I mean, the software was 
bought back in dec. 2003 and never updated since. (the new Zend Platform is 
outrageously priced, and I'll never get that through on the IT budget here)

Does anybody know where to download the source for this, the old (and 
ofcourse not working here anymore) admin didnt keep the source, so all I got 
is the name and serial. (and Zend supporters seem to be "on vacation")

With the "Zend Platform" out of the way, should I look more toward eg. the 
APC ?

--
Lars B. Jensen, Internet Architect
CareerCross Japan
Japan's premier online career resource for english speaking professionals
http://www.careercross.com 

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


[PHP] Re: end of array

2005-01-23 Thread Raj Shekhar
"M. Sokolewicz" <[EMAIL PROTECTED]> writes:

> Raj Shekhar wrote:
> > "M. Sokolewicz" <[EMAIL PROTECTED]> writes:
> >
> >>Raj Shekhar wrote:
> >
> >>>$n_elts = count($myarray);
> >>>for ($i=0; $i< $n_elts ; $i++)
> >>>{
> >>>if ($i = $n_elts -1)
> >   ^^^
> > Use of == required to make it work
> >>>{
> >>>echo "On last element";
> >>>break;
> >>>}
> >>>else
> >>>{
> >>>echo "Somwhere in the middle";
> >>>}
> >>>}
> >>
> >>that's an eternal loop in case you hadn't noticed (*rolls eyes*)
> > Oops :( not eternal loop though, only one loop
> why one?
> for($i=0; $i<$n;$i++) {
>   $i = ($n-1);
> }

My statement was, 

if ($i = $n_elts -1)

{
echo "On last element";
break;
}

i.e.

- assign ($i = $n_elts -1) and check the return value of the
  assignment. 

- If the assignment succeeds (which should, unless you are running
  short of free memory) THEN

- echo 
- BREAK out of loop 

Since this conditions are met the first time the loop runs, the loop
will run only once. I know I am correct, since I ran the code this
time :P

-- 
Raj Shekhar
System Administrator, programmer and  slacker
home : http://rajshekhar.net
blog : http://rajshekhar.net/blog/

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