Re: [PHP] Alphabetical pagination

2009-07-15 Thread Ashley Sheridan
On Wednesday 15 July 2009 06:35:04 Jim Lucas wrote:
> Andrew Ballard wrote:
> > On Tue, Jul 14, 2009 at 3:38 PM, Miller,
> >
> > Terion wrote:
> >> I am trying to make a page that displays a-z like a b c d e etc as links
> >> then when you click open one it reloads itself and shows only the query
> >> results that go with that letter...i'm not getting itI get a page
> >> that says ARRAY over and over...
> >>
> >> What I have so far:
> >>  >>
> >> if(!isset($_SESSION['RestaurantList']))
> >>
> >> {
> >>  // List not grabbed yet, so run
> >> query and store in $_SESSION
> >>
> >>$sql = "SELECT
> >> DISTINCT name FROM restaurants  GROUP BY name DESC";
> >>
> >> $result = mysql_query($sql) or die(mysql_error()) ;
> >>
> >> $count = mysql_num_rows($result);
> >>
> >> echo $count;
> >>
> >>
> >> while($row = mysql_fetch_array($result)) {
> >>
> >>
> >>
> >> $name=array($row['name'],0,1);
> >
> > Why are you setting the value of $name to an array? If you try to echo
> > $name after this statement (as you are below), PHP will echo the word
> > "Array".
> >
> >> //$name = array('name');
> >>
> >>echo " >> href=\"page.php?name=" .$name. "\"> $name\n";
> >>
> >> }
> >>
> >>
> >>}
> >>
> >>
> >>
> >> $alphabet = range('A', 'Z');
> >>
> >> foreach ($alphabet as $letter) {
> >>
> >> echo '' . $letter . '';
> >>
> >> }
> >>
> >>
> >>
> >>
> >>
> >>
> >> ?>
> >
> > If the list of restaurants is very long, I wouldn't store it in a
> > session variable. It is the same for every person who visits your
> > site, so there is little use storing separate redundant copies in
> > session scope where it will needlessly fill up disk space and/or
> > memory.
> >
> > As far as the query is concerned, you could do this:
> >
> >  >
> > $index_letter = $_GET['letter'];
> >
> > if (preg_match('/^[A-Za-z]$/', $index_letter)) {
> >
> > $sql = "SELECT DISTINCT name FROM restaurants WHERE name LIKE
> > '$index_letter%' GROUP BY name DESC";
> >
> > //
> > ?>
> >
> > I would also consider whether you really need the keyword DISTINCT in
> > the query. In a properly normalized table, name should probably
> > already be distinct (and constrained by a UNIQUE index on that
> > column).
> >
> > Andrew
>
> Also, since this is MySQL, you need to make sure you make it non
> case-sensitive by using ILIKE instead of LIKE in that SELECT statement.
>
> $sql = "SELECT DISTINCT name FROM restaurants WHERE name iLIKE
> '$index_letter%' GROUP BY name DESC";
>
> --
> Jim Lucas

You only have to use that if your character set is not latin1 or 
latin1_swedish_ci. Using LIKE on those character sets is case-insensitive 
too.

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk

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



Re: [PHP] Scrapping email content

2009-07-15 Thread Tom Chubb
2009/7/15 Areba Collins 

> Hello guys, i have a quick one:
>
> Im working on an app that reads email and converts it into a post on a
> forum, everything works fine except the threaded comments at the
> bottom. I would like to delete everything that is from a previous
> email (which usually begins with on this ate, so and so wrote : and
> then comments preceeded by >>
>
> Does anyone know a straightforward function to accomplish this?
>
> Regards,
> Collins -Nairobi KE.
>
> --
> If you have an apple and I have an apple and we exchange these apples
> then you and I will still each have one apple. But if you have an idea
> and I have an idea and we exchange these ideas, then each of us will
> have two ideas.
>
> George Bernard Shaw
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
How about marking the email as read and not deleting it. Compare following
emails to previous read emails and strip out any common text and strip out
"> " and any other common indentation, etc.


Re: [PHP] Mac OS X Server

2009-07-15 Thread Thijs Lensselink
The Doctor wrote:
> ALl right,
> 
> I just install MySQL 5.1.36 on a Mac OS X Server but the PHP
> is looking at the Mysql 5.0.67 ?
> 
> How do I tell the php.ini to look at the 5.1 instead of the 5.0?
> 

You don't do that from the php.ini file. Either recompile PHP against
the new MySQL source. If you use some sort of package management you can
just upgrade PHP.

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



Re: [PHP] Scrapping email content

2009-07-15 Thread Ashley Sheridan
On Wednesday 15 July 2009 08:38:28 Tom Chubb wrote:
> 2009/7/15 Areba Collins 
>
> > Hello guys, i have a quick one:
> >
> > Im working on an app that reads email and converts it into a post on a
> > forum, everything works fine except the threaded comments at the
> > bottom. I would like to delete everything that is from a previous
> > email (which usually begins with on this ate, so and so wrote : and
> > then comments preceeded by >>
> >
> > Does anyone know a straightforward function to accomplish this?
> >
> > Regards,
> > Collins -Nairobi KE.
> >
> > --
> > If you have an apple and I have an apple and we exchange these apples
> > then you and I will still each have one apple. But if you have an idea
> > and I have an idea and we exchange these ideas, then each of us will
> > have two ideas.
> >
> > George Bernard Shaw
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
> How about marking the email as read and not deleting it. Compare following
> emails to previous read emails and strip out any common text and strip out
> "> " and any other common indentation, etc.

Or a regex a bit like this:

^>.+$

That should match any line beginning with a > character, so you can just 
replace any such lines with nothing.

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk

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



[PHP] Re: I have an idea

2009-07-15 Thread Carlos Medina

Martin Scotta schrieb:

Hi

Do you noted that all the discussion here are about problems, bugs, or
just "urgent pleaaase help me"
I have an idea. It is not really THE idea... but it is.
What happen if tell this idea to the community? I don't know, so,
let's take a look.


PHP is a great language. You can do a lot of things with him, even
have fun with it.
My idea is to make a simple game where your have to write some AI to
beat the other players AI

The idea, as simple as it looks, is really difficult to implement
specially about security

so, do you like me idea?


Hi Martin,
i think is a good idea. How do you think to implement this?

Carlos Medina

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



Re: [PHP] Re: I have an idea

2009-07-15 Thread Michael A. Peters

Carlos Medina wrote:

Martin Scotta schrieb:

Hi

Do you noted that all the discussion here are about problems, bugs, or
just "urgent pleaaase help me"
I have an idea. It is not really THE idea... but it is.
What happen if tell this idea to the community? I don't know, so,
let's take a look.


PHP is a great language. You can do a lot of things with him, even
have fun with it.
My idea is to make a simple game where your have to write some AI to
beat the other players AI

The idea, as simple as it looks, is really difficult to implement
specially about security

so, do you like me idea?


Hi Martin,
i think is a good idea. How do you think to implement this?



The LISP list is two doors down across the hall.

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



Re: [PHP] [GD] Image errors

2009-07-15 Thread Peter Ford
Ash, Martin,

Seems you are both wandering around the obvious problem...

I suspect that $tipo (in the next line) is *supposed* to be $type - sounds like
a partial Italian translation to me...

So given that $type="imagecreatefrompng" (for example, if the mime check returns
'png' - not very reliable, I suspect),

then

$immagine = $type($this->updir.$id.'.png')

should create a GD resource from the file, but the image appears to be empty.

My take on this is:

OP says he gets the same result from
$immagine = imagecreatefromjpeg(this->updir.$id.'.png')

- well I might expect to get an error message if I loaded a PNG expecting it to
be a JPEG, but I certainly wouldn't expect an image.

On some basic tests, I find that mime_content_type() is not defined on my
system, so ignoring that and trying to load a PNG file using imagecreatefromjpeg
results in pretty much the same result as the OP...

Conclusions:

First: if you use Italian for your variable names, don't change half of their
instances to English...

Second: Make sure you actually know the mime type of a file before you try to
load it into GD...

My version of this would test against known image types to try the GD function:

foreach (Array('png','jpeg','gif') as $typeName)
{
  $type = 'imagecreatefrom'.$typeName;
  $immagine = $type(this->updir.$id.'.png'le);
  if (is_resource($immagine))
  {
header('Content-type: image/jpeg');
imagejpeg($immagine,null,100);
imagedestroy($immagine);
break;
  }
}
header('HTTP/1.0 500 File is not an allowed image type');





-- 
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] [GD] Image errors

2009-07-15 Thread Peter Ford
Martin Scotta wrote:
> Why are you ussing GD?
> All you need is output the image to the browser?
> 
> try this... I didn't test/run this code, but it may work...
> 
> public function showPicture( $id ) {
>   header('Content-type:' . mime_content_type( $this->updir . $id .
> '.png' ) );
>   readfile( $this->updir . $id . '.png' );
>   }
> 
> hey, look, just 2 lines!
> 
But it doesn't convert the image from whatever came in to a JPEG output, which
is what the OP's code appears to be trying to do (and possibly ought to work...)



-- 
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Pattern Matching

2009-07-15 Thread Lenin
On Wed, Jul 15, 2009 at 3:24 AM, VamVan wrote:

> contact/me - Contact US
>
> perfect match would be easy because I can exactly look for what I want.
>
> It becomes tricky when I introduce wild cards like contact/* for example. It
> could also be contact/me/*
>
> How would I match patterns for this kind of relative matches.? Any ideas
> anyone?


Use preg_match function to do that.

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



[PHP] error_append_string and error_log

2009-07-15 Thread Javier Ruiz
Hi!

I'm trying to append some extra info to my php errors. It works well when
I'm displaying errors on screen, but it doesn't work to log the extra info
into an error file (log_errors and  error_log). I mean, if I use this:



Re: [PHP] Re: I have an idea

2009-07-15 Thread Carlos Medina

Michael A. Peters schrieb:

Carlos Medina wrote:

Martin Scotta schrieb:

Hi

Do you noted that all the discussion here are about problems, bugs, or
just "urgent pleaaase help me"
I have an idea. It is not really THE idea... but it is.
What happen if tell this idea to the community? I don't know, so,
let's take a look.


PHP is a great language. You can do a lot of things with him, even
have fun with it.
My idea is to make a simple game where your have to write some AI to
beat the other players AI

The idea, as simple as it looks, is really difficult to implement
specially about security

so, do you like me idea?


Hi Martin,
i think is a good idea. How do you think to implement this?



The LISP list is two doors down across the hall.

:-D but... why lisp? and why not PHP? explain please.

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



[PHP] IP to geo-location advice

2009-07-15 Thread Patrick
Hi Everyone

Could anyone give me some advice on the best way to do IP to
geo-location with php using open source code?

Thanks in advance-Patrick

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



Re: [PHP] error_append_string and error_log

2009-07-15 Thread Ashley Sheridan
On Wednesday 15 July 2009 12:44:21 Javier Ruiz wrote:
> Hi!
>
> I'm trying to append some extra info to my php errors. It works well when
> I'm displaying errors on screen, but it doesn't work to log the extra info
> into an error file (log_errors and  error_log). I mean, if I use this:
>
>  ini_set('display_errors', 1);
> ini_set('log_errors', 1);
> ini_set('error_log', './ERRORS');
> ini_set('error_append_string', " -- SomeStuff!");
> require 'test.php';   // this file contains syntax errors...
>
>
> When I issue this using a web browser, I get a syntax error shown in the
> browser and it contains the "SomeStuff" text, but in the ERRORS file I just
> get the php error without the "SomeStuff" text...
>
> Is there any way to get this working?
>
> Thanks!
> Regards,
>
> JaviRuiz.

Try setting this in your php.ini rather than PHP and see if that does the 
trick

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk

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



Re: [PHP] IP to geo-location advice

2009-07-15 Thread Daniel Brown
On Wed, Jul 15, 2009 at 08:14, Patrick wrote:
>
> Could anyone give me some advice on the best way to do IP to
> geo-location with php using open source code?

Advice: RTFM.  ;-P

http://php.net/geoip

-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Check out our great hosting and dedicated server deals at
http://twitter.com/pilotpig

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



Re: [PHP] Alphabetical pagination

2009-07-15 Thread Andrew Ballard
On Wed, Jul 15, 2009 at 3:28 AM, Ashley
Sheridan wrote:
> On Wednesday 15 July 2009 06:35:04 Jim Lucas wrote:
>> Andrew Ballard wrote:
>> > On Tue, Jul 14, 2009 at 3:38 PM, Miller,
>> >
>> > Terion wrote:
>> >> I am trying to make a page that displays a-z like a b c d e etc as links
>> >> then when you click open one it reloads itself and shows only the query
>> >> results that go with that letter...i'm not getting itI get a page
>> >> that says ARRAY over and over...
>> >>
>> >> What I have so far:
>> >>                             > >>
>> >> if(!isset($_SESSION['RestaurantList']))
>> >>
>> >> {
>> >>                                      // List not grabbed yet, so run
>> >> query and store in $_SESSION
>> >>
>> >>                                                        $sql = "SELECT
>> >> DISTINCT name FROM restaurants  GROUP BY name DESC";
>> >>
>> >> $result = mysql_query($sql) or die(mysql_error()) ;
>> >>
>> >> $count = mysql_num_rows($result);
>> >>
>> >> echo $count;
>> >>
>> >>
>> >> while($row = mysql_fetch_array($result)) {
>> >>
>> >>
>> >>
>> >> $name=array($row['name'],0,1);
>> >
>> > Why are you setting the value of $name to an array? If you try to echo
>> > $name after this statement (as you are below), PHP will echo the word
>> > "Array".
>> >
>> >> //$name = array('name');
>> >>
>> >>                                                        echo "> >> href=\"page.php?name=" .$name. "\"> $name\n";
>> >>
>> >> }
>> >>
>> >>
>> >>                                                                    }
>> >>
>> >>
>> >>
>> >> $alphabet = range('A', 'Z');
>> >>
>> >> foreach ($alphabet as $letter) {
>> >>
>> >> echo '' . $letter . '';
>> >>
>> >> }
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> ?>
>> >
>> > If the list of restaurants is very long, I wouldn't store it in a
>> > session variable. It is the same for every person who visits your
>> > site, so there is little use storing separate redundant copies in
>> > session scope where it will needlessly fill up disk space and/or
>> > memory.
>> >
>> > As far as the query is concerned, you could do this:
>> >
>> > > >
>> > $index_letter = $_GET['letter'];
>> >
>> > if (preg_match('/^[A-Za-z]$/', $index_letter)) {
>> >
>> >     $sql = "SELECT DISTINCT name FROM restaurants WHERE name LIKE
>> > '$index_letter%' GROUP BY name DESC";
>> >
>> > //
>> > ?>
>> >
>> > I would also consider whether you really need the keyword DISTINCT in
>> > the query. In a properly normalized table, name should probably
>> > already be distinct (and constrained by a UNIQUE index on that
>> > column).
>> >
>> > Andrew
>>
>> Also, since this is MySQL, you need to make sure you make it non
>> case-sensitive by using ILIKE instead of LIKE in that SELECT statement.
>>
>> $sql = "SELECT DISTINCT name FROM restaurants WHERE name iLIKE
>> '$index_letter%' GROUP BY name DESC";
>>
>> --
>> Jim Lucas
>
> You only have to use that if your character set is not latin1 or
> latin1_swedish_ci. Using LIKE on those character sets is case-insensitive
> too.
>
> --
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>

... or any of the other *_ci character set collations. ;-) I generally
use utf8_unicode_ci in MySQL.

Andrew

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



[PHP] Re: IP to geo-location advice

2009-07-15 Thread pan
Patrick wrote:
>> Hi Everyone
>>
>> Could anyone give me some advice on the best way to do IP to
>> geo-location with php using open source code?
>>
>> Thanks in advance-Patrick


That is not an easy problem.

You can go to ARIN, APNIC, etc and get /8 and smaller assignments.
But, if the new assignee hasn't SWIP'd their blocks, the world
will think the old assignment is still true. Recently a block was
assigned to a US company and their customers couldn't access
hulu.com because there hadn't been a SWIP. hulu denied access
because the block is still in the whois records as non-US.

The big geolocation companies make a lot of mistakes.
Because - they will not use a fine enough granularity to sort
out where an ip connection is coming from. They'll usually stop
at the last router within a large transit provider's block.
For example: many local ISPs in northern california will
all appear to be in stockton, etc. where some tier 1 routers are.

For dynamic ip ranges it is even messier.

For now, ip geolocation is very fuzzy. Much better to go by
zip code or postal code. At least  when zip areas are merged
or changed you might get sufficient advance notice.




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



Re: [PHP] error_append_string and error_log

2009-07-15 Thread Javier Ruiz
Hi, thanks for your reply.

The thing is, I need to set it in runtime (ini_set) since I want to append
the URI that generated the error, so I'll need to use some $_SERVER
variables.

Regards

JaviRuiz.



On Wed, Jul 15, 2009 at 2:25 PM, Ashley Sheridan
wrote:

> On Wednesday 15 July 2009 12:44:21 Javier Ruiz wrote:
> > Hi!
> >
> > I'm trying to append some extra info to my php errors. It works well when
> > I'm displaying errors on screen, but it doesn't work to log the extra
> info
> > into an error file (log_errors and  error_log). I mean, if I use this:
> >
> >  > ini_set('display_errors', 1);
> > ini_set('log_errors', 1);
> > ini_set('error_log', './ERRORS');
> > ini_set('error_append_string', " -- SomeStuff!");
> > require 'test.php';   // this file contains syntax errors...
> >
> >
> > When I issue this using a web browser, I get a syntax error shown in the
> > browser and it contains the "SomeStuff" text, but in the ERRORS file I
> just
> > get the php error without the "SomeStuff" text...
> >
> > Is there any way to get this working?
> >
> > Thanks!
> > Regards,
> >
> > JaviRuiz.
>
> Try setting this in your php.ini rather than PHP and see if that does the
> trick
>
> --
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>


Re: [PHP] IP to geo-location advice

2009-07-15 Thread Per Jessen
Patrick wrote:

> Hi Everyone
> 
> Could anyone give me some advice on the best way to do IP to
> geo-location with php using open source code?
> 

Use DNS and http://countries.nerd.dk. 


/Per

-- 
Per Jessen, Zürich (24.2°C)


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



Re: [PHP] I have an idea

2009-07-15 Thread Govinda

PHP is a great language. You can do a lot of things with him, even
have fun with it.
My idea is to make a simple game where your have to write some AI to
beat the other players AI

The idea, as simple as it looks, is really difficult to implement
specially about security

so, do you like me idea?

--  
Martin Scotta





sorry if this is getting OT:

Martin, I wrote a really fun and charming remake of a great that 2  
others wrote in the 1980's.  My version has really fun graphics and  
sounds.  I used visual basic as that is what I had then on my then  
windows laptop, without internet, literally in the mountains in north  
India where we only had electricity a couple hours per day, let alone  
no internet.  It is a simple but very fun strategy game with more  
depth than say checkers (by far!),  but less complex/daunting than say  
chess.  It has 2-player option, but writing the AI for the various  
levels of difficulty when playing against the computer was the most  
challenging and fun part of the project.  I often thought of taking it  
the next step and doing just what you propose here.   I don't know  
what is LISP, but I assume that post meant to say that PHP is not the  
best language for this.  (?)  I say, "so?"  If you know PHP, (and  
what, AJAX to go with it?)  then you can do it, and HAVE FUN,  
regardless that it is very inefficient way to do it.
For myself I can't afford to take time for that much programming fun,  
just now..  but let me know in case you (or anyone) would like a copy  
of that game.. it may give you some ideas, not to mention it is  
perfect fun for unwinding at the end of a day of coding.  Takes 5  
minutes to play.  The expert level is not at all easy to beat!  ;-)
(for windows 98-->Vista.Windows-7 I don't know... I use Mac when I  
have a choice.)


-Govinda

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



[PHP] Error handling

2009-07-15 Thread Paul M Foster
This note shows up in the documentation for set_error_handler():

The following error types cannot be handled with a user defined
function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING,
E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT raised in the
file where set_error_handler() is called. 

So if I set up an error handler function like:

function my_error_handler()
{
switch ($errno) {
case E_ERROR:
die('Something or other');
break;
...
}
}

the parts which reference errors like those above won't actually
execute?

Paul
-- 
Paul M. Foster

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



Re: [PHP] Alphabetical pagination

2009-07-15 Thread tedd

At 12:38 PM -0700 7/14/09, Miller, Terion wrote:

I am trying to make a page that displays a-z like a b c d e etc as links
then when you click open one it reloads itself and shows only the query
results that go with that letter...i'm not getting itI get a page that
says ARRAY over and over...

What I have so far:

-snip-

Why not have MySQL sort the data instead of using php?

For example (from memory -- use with caution)

SELECT name FROM restaurant ORDER BY name DESC LIMIT $offset, 1

Then just change the offset to go up and down the list.

Cheers,

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

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



Re: [PHP] Alphabetical pagination

2009-07-15 Thread Ashley Sheridan
On Wednesday 15 July 2009 16:21:22 tedd wrote:
> At 12:38 PM -0700 7/14/09, Miller, Terion wrote:
> >I am trying to make a page that displays a-z like a b c d e etc as links
> >then when you click open one it reloads itself and shows only the query
> >results that go with that letter...i'm not getting itI get a page that
> >says ARRAY over and over...
> >
> >What I have so far:
>
> -snip-
>
> Why not have MySQL sort the data instead of using php?
>
> For example (from memory -- use with caution)
>
> SELECT name FROM restaurant ORDER BY name DESC LIMIT $offset, 1
>
> Then just change the offset to go up and down the list.
>
> Cheers,
>
> tedd
> --
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com

You could do what Tedd suggested, but use MySQL to actually limit the results 
it returns you by using a like clause, i.e. WHERE `somefield` LIKE 'a%'.

*ducks to avoid people throwing things at him. I know it's slow!*

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk

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



Re: [PHP] Alphabetical pagination

2009-07-15 Thread Miller, Terion



On 7/15/09 10:30 AM, "Ashley Sheridan"  wrote:

On Wednesday 15 July 2009 16:21:22 tedd wrote:
> At 12:38 PM -0700 7/14/09, Miller, Terion wrote:
> >I am trying to make a page that displays a-z like a b c d e etc as links
> >then when you click open one it reloads itself and shows only the query
> >results that go with that letter...i'm not getting itI get a page that
> >says ARRAY over and over...
> >
> >What I have so far:
>
> -snip-
>
> Why not have MySQL sort the data instead of using php?
>
> For example (from memory -- use with caution)
>
> SELECT name FROM restaurant ORDER BY name DESC LIMIT $offset, 1
>
> Then just change the offset to go up and down the list.
>
> Cheers,
>
> tedd
> --
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com

You could do what Tedd suggested, but use MySQL to actually limit the results
it returns you by using a like clause, i.e. WHERE `somefield` LIKE 'a%'.

*ducks to avoid people throwing things at him. I know it's slow!*

--
Thanks,
Ash
http://www.ashleysheridan.co.uk


Hi all thanks for all the suggestions, I really had no idea this was going to 
be so difficult..I am a bit closer..well I have the alphabet showing up now I 
just have to get it to actually pull results..LMAO
Here is my code as it is today, I have by end of day to get it to work...yikes 
the stress is unbearable, there are a million pagination scripts out there but 
I can't find any good alpha ones I can understand.
Ok what I have so far: the top part lists all the restaurant names, the bottom 
part has the alpha pagination ...neither links to the results of a 
query...yet... Bit by bit right?

  $name\n";} 

   }
//alphabetical pagination 
linksif 
(!isset($_GET['letter'])) {$letter = "A";} else {$letter = $_GET['letter'];}
echo '';
for ($i=65; $i<90; $i++) {  
  if ($letter!= chr($i)) {echo '';}
echo chr($i)." ";  
  if ($letter!= chr($i)) {echo '';} 
   }
echo "";   

 $query="SELECT * FROM 
restaurants WHERE name LIKE '".$letter."%'";


?>

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



Re: [PHP] I have an idea

2009-07-15 Thread tedd

At 1:21 AM -0300 7/15/09, Martin Scotta wrote:

Hi

Do you noted that all the discussion here are about problems, bugs, or
just "urgent pleaaase help me"
I have an idea. It is not really THE idea... but it is.
What happen if tell this idea to the community? I don't know, so,
let's take a look.


PHP is a great language. You can do a lot of things with him, even
have fun with it.
My idea is to make a simple game where your have to write some AI to
beat the other players AI

The idea, as simple as it looks, is really difficult to implement
specially about security

so, do you like me idea?

--


Here's an AI (rule based) php game:

http://sperling.com/quarters/

Get your AI to beat mine.  :-)

Cheers,

tedd

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

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



Re: [PHP] I have an idea

2009-07-15 Thread Ashley Sheridan
On Wednesday 15 July 2009 16:29:49 tedd wrote:
> At 1:21 AM -0300 7/15/09, Martin Scotta wrote:
> >Hi
> >
> >Do you noted that all the discussion here are about problems, bugs, or
> >just "urgent pleaaase help me"
> >I have an idea. It is not really THE idea... but it is.
> >What happen if tell this idea to the community? I don't know, so,
> >let's take a look.
> >
> >
> >PHP is a great language. You can do a lot of things with him, even
> >have fun with it.
> >My idea is to make a simple game where your have to write some AI to
> >beat the other players AI
> >
> >The idea, as simple as it looks, is really difficult to implement
> >specially about security
> >
> >so, do you like me idea?
> >
> >--
>
> Here's an AI (rule based) php game:
>
> http://sperling.com/quarters/
>
> Get your AI to beat mine.  :-)
>
> Cheers,
>
> tedd
>
> --
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com

I think I can figure out how not to lose, but I don't know how to win...

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk

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



Re: [PHP] Alphabetical pagination

2009-07-15 Thread tedd

At 4:30 PM +0100 7/15/09, Ashley Sheridan wrote:

On Wednesday 15 July 2009 16:21:22 tedd wrote:

 At 12:38 PM -0700 7/14/09, Miller, Terion wrote:
 >I am trying to make a page that displays a-z like a b c d e etc as links
 >then when you click open one it reloads itself and shows only the query
 >results that go with that letter...i'm not getting itI get a page that
 >says ARRAY over and over...
 >
 >What I have so far:

 -snip-

 Why not have MySQL sort the data instead of using php?

 For example (from memory -- use with caution)

 SELECT name FROM restaurant ORDER BY name DESC LIMIT $offset, 1

 Then just change the offset to go up and down the list.

 Cheers,

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


You could do what Tedd suggested, but use MySQL to actually limit the results
it returns you by using a like clause, i.e. WHERE `somefield` LIKE 'a%'.

*ducks to avoid people throwing things at him. I know it's slow!*

--
Thanks,
Ash



Ash:

My solution on this is simply to sort all the names and then pull 
them out one by one depending upon where they appear in the sort. I 
don't really see the need for LIKE to do this unless the user is 
entering a guess. In such case, then you want to provide them with 
your best fit.


Here's an example of both:

http://php1.net/a/edit-db-demo/index.php

The user can step through the database, which is initially sorted on 
last name. If the user picks to sort on email, then the sort is done 
as per email. In both cases, the data is stepped through sequentially 
(Alphabetical pagination) by using an offset and limit combination.


However, if the user clicks on an alphabetical tab, then I use a LIKE 
to place them (their pagination) at the position of that sort at that 
character. That's where a LIKE would work well.


Cheers,

tedd

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

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



Re: [PHP] Alphabetical pagination

2009-07-15 Thread Andrew Ballard
On Wed, Jul 15, 2009 at 11:30 AM, Ashley
Sheridan wrote:
> On Wednesday 15 July 2009 16:21:22 tedd wrote:
>> At 12:38 PM -0700 7/14/09, Miller, Terion wrote:
>> >I am trying to make a page that displays a-z like a b c d e etc as links
>> >then when you click open one it reloads itself and shows only the query
>> >results that go with that letter...i'm not getting itI get a page that
>> >says ARRAY over and over...
>> >
>> >What I have so far:
>>
>> -snip-
>>
>> Why not have MySQL sort the data instead of using php?
>>
>> For example (from memory -- use with caution)
>>
>> SELECT name FROM restaurant ORDER BY name DESC LIMIT $offset, 1
>>
>> Then just change the offset to go up and down the list.
>>
>> Cheers,
>>
>> tedd
>> --
>> ---
>> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> You could do what Tedd suggested, but use MySQL to actually limit the results
> it returns you by using a like clause, i.e. WHERE `somefield` LIKE 'a%'.
>
> *ducks to avoid people throwing things at him. I know it's slow!*
>
> --
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>

Why would that be slow? Using LIKE isn't always a bad thing. In this
case, the LIKE condition begins with a constant rather than a
wildcard, so it should perform well. It can even benefit from an index
on `somefield` if one exists.

I only see a couple issues with tedd's query:

1) As written, it only returns one row. To get it to return a list,
you'd have to call it repeatedly inside a for...loop where $offset
increments begins at some value and increments/decrements to an ending
value. But then he did say "from memory -- use with caution". The
general idea is correct.

2)  It implements numeric pagination, which is usually based on a
fixed number of rows per page. The OP wanted alphabetical pagination
(like an address book) with each page containing all entries that
begin with the selected letter.


Andrew

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



Re: [PHP] Alphabetical pagination

2009-07-15 Thread tedd

At 8:29 AM -0700 7/15/09, Miller, Terion wrote:


Hi all thanks for all the suggestions, I really had no idea this was 
going to be so difficult..


I think you are making it more difficult than it has to be.

Please review what I said and try it out.

Cheers,

tedd



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

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



[PHP] running php script as a user?

2009-07-15 Thread Adam Williams
I have a page where a user authenticates, fills in some information in 
an HTML form, and then when clicking on the submit button, will need to 
execute a php schell script as that user to write some data to their 
/home/username directory.  Since apache web server runs as the user 
nobody, how will I have that script execute as that user so that it can 
write data to their home directory?



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



Re: [PHP] Alphabetical pagination

2009-07-15 Thread Ashley Sheridan
On Wednesday 15 July 2009 16:46:53 Andrew Ballard wrote:
> On Wed, Jul 15, 2009 at 11:30 AM, Ashley
>
> Sheridan wrote:
> > On Wednesday 15 July 2009 16:21:22 tedd wrote:
> >> At 12:38 PM -0700 7/14/09, Miller, Terion wrote:
> >> >I am trying to make a page that displays a-z like a b c d e etc as
> >> > links then when you click open one it reloads itself and shows only
> >> > the query results that go with that letter...i'm not getting itI
> >> > get a page that says ARRAY over and over...
> >> >
> >> >What I have so far:
> >>
> >> -snip-
> >>
> >> Why not have MySQL sort the data instead of using php?
> >>
> >> For example (from memory -- use with caution)
> >>
> >> SELECT name FROM restaurant ORDER BY name DESC LIMIT $offset, 1
> >>
> >> Then just change the offset to go up and down the list.
> >>
> >> Cheers,
> >>
> >> tedd
> >> --
> >> ---
> >> http://sperling.com  http://ancientstones.com  http://earthstones.com
> >
> > You could do what Tedd suggested, but use MySQL to actually limit the
> > results it returns you by using a like clause, i.e. WHERE `somefield`
> > LIKE 'a%'.
> >
> > *ducks to avoid people throwing things at him. I know it's slow!*
> >
> > --
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
>
> Why would that be slow? Using LIKE isn't always a bad thing. In this
> case, the LIKE condition begins with a constant rather than a
> wildcard, so it should perform well. It can even benefit from an index
> on `somefield` if one exists.
>
> I only see a couple issues with tedd's query:
>
> 1) As written, it only returns one row. To get it to return a list,
> you'd have to call it repeatedly inside a for...loop where $offset
> increments begins at some value and increments/decrements to an ending
> value. But then he did say "from memory -- use with caution". The
> general idea is correct.
>
> 2)  It implements numeric pagination, which is usually based on a
> fixed number of rows per page. The OP wanted alphabetical pagination
> (like an address book) with each page containing all entries that
> begin with the selected letter.
>
>
> Andrew

I just had a query doing the same thing one time, and that did take it's time 
(about 2-3 seconds) but it did have a few million records to look at, so I 
can understand why it was slow!

And it was on MSSQL, with no indexes set up :( I nearly cried when I saw what 
I was dealing with!

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk

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



[PHP] Exception not being caught

2009-07-15 Thread Weston C
So, I've got a little piece of code designed to play with catching the
exception that's thrown when an object doesn't have a __toString
method.



This does not run as expected. I'd think that when the implicit string
conversion in the try block hits, the exception would be thrown,
caught by the catch block, and relayed.

Instead you don't ever see the words "exception caught" and you get
"Catchable fatal error: Object of class A could not be converted to
string."

If it's catchable, why isn't it caught in my example?

Thanks,

Weston

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



Re: [PHP] Alphabetical pagination

2009-07-15 Thread Martin Scotta
SET @letter := 'B';
SELECT name FROM table WHERE SUBSTRING(name, 1) == @letter;
SELECT name FROM table WHERE name like concat(@letter, '%');

I don't know a faster way to do it

On Wed, Jul 15, 2009 at 12:57 PM, Ashley
Sheridan wrote:
> On Wednesday 15 July 2009 16:46:53 Andrew Ballard wrote:
>> On Wed, Jul 15, 2009 at 11:30 AM, Ashley
>>
>> Sheridan wrote:
>> > On Wednesday 15 July 2009 16:21:22 tedd wrote:
>> >> At 12:38 PM -0700 7/14/09, Miller, Terion wrote:
>> >> >I am trying to make a page that displays a-z like a b c d e etc as
>> >> > links then when you click open one it reloads itself and shows only
>> >> > the query results that go with that letter...i'm not getting itI
>> >> > get a page that says ARRAY over and over...
>> >> >
>> >> >What I have so far:
>> >>
>> >> -snip-
>> >>
>> >> Why not have MySQL sort the data instead of using php?
>> >>
>> >> For example (from memory -- use with caution)
>> >>
>> >> SELECT name FROM restaurant ORDER BY name DESC LIMIT $offset, 1
>> >>
>> >> Then just change the offset to go up and down the list.
>> >>
>> >> Cheers,
>> >>
>> >> tedd
>> >> --
>> >> ---
>> >> http://sperling.com  http://ancientstones.com  http://earthstones.com
>> >
>> > You could do what Tedd suggested, but use MySQL to actually limit the
>> > results it returns you by using a like clause, i.e. WHERE `somefield`
>> > LIKE 'a%'.
>> >
>> > *ducks to avoid people throwing things at him. I know it's slow!*
>> >
>> > --
>> > Thanks,
>> > Ash
>> > http://www.ashleysheridan.co.uk
>>
>> Why would that be slow? Using LIKE isn't always a bad thing. In this
>> case, the LIKE condition begins with a constant rather than a
>> wildcard, so it should perform well. It can even benefit from an index
>> on `somefield` if one exists.
>>
>> I only see a couple issues with tedd's query:
>>
>> 1) As written, it only returns one row. To get it to return a list,
>> you'd have to call it repeatedly inside a for...loop where $offset
>> increments begins at some value and increments/decrements to an ending
>> value. But then he did say "from memory -- use with caution". The
>> general idea is correct.
>>
>> 2)  It implements numeric pagination, which is usually based on a
>> fixed number of rows per page. The OP wanted alphabetical pagination
>> (like an address book) with each page containing all entries that
>> begin with the selected letter.
>>
>>
>> Andrew
>
> I just had a query doing the same thing one time, and that did take it's time
> (about 2-3 seconds) but it did have a few million records to look at, so I
> can understand why it was slow!
>
> And it was on MSSQL, with no indexes set up :( I nearly cried when I saw what
> I was dealing with!
>
> --
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
Martin Scotta

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



Re: [PHP] Re: I have an idea

2009-07-15 Thread Martin Scotta
On Wed, Jul 15, 2009 at 4:55 AM, Carlos Medina wrote:
> Martin Scotta schrieb:
>>
>> Hi
>>
>> Do you noted that all the discussion here are about problems, bugs, or
>> just "urgent pleaaase help me"
>> I have an idea. It is not really THE idea... but it is.
>> What happen if tell this idea to the community? I don't know, so,
>> let's take a look.
>>
>>
>> PHP is a great language. You can do a lot of things with him, even
>> have fun with it.
>> My idea is to make a simple game where your have to write some AI to
>> beat the other players AI
>>
>> The idea, as simple as it looks, is really difficult to implement
>> specially about security
>>
>> so, do you like me idea?
>>
> Hi Martin,
> i think is a good idea. How do you think to implement this?
>
> Carlos Medina
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Well, that's is exactly the main problem.

First I think that users must provide a set of classes to participate.
Then there will be some "matches" between the classes.

The problem here is the security, you are allowing to execute arbitrary code!

So, if the user classes can be executed remotely this issue is solved,
maybe using webservices...
This also free the user to implement the AI in PHP but has a great
limitation for the players.
Not all player has the resources / knowledge to set a webservice...

Another approach can be create some sort of "scripting" language. This
can be parsed / translated by PHP and all solved... but this will not
be a PHP game.

I want players to write the AI using PHP but, if possible, not restricting to it

-- 
Martin Scotta

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



Re: [PHP] Pattern Matching[Resolved]

2009-07-15 Thread VamVan
On Wed, Jul 15, 2009 at 4:21 AM, Lenin  wrote:

> On Wed, Jul 15, 2009 at 3:24 AM, VamVan wrote:
>
> > contact/me - Contact US
> >
> > perfect match would be easy because I can exactly look for what I want.
> >
> > It becomes tricky when I introduce wild cards like contact/* for example.
> It
> > could also be contact/me/*
> >
> > How would I match patterns for this kind of relative matches.? Any ideas
> > anyone?
>
>
> Use preg_match function to do that.


Ok here is how I solved it. When I have a url like www.xx.ccom/a/b/c for
example, what I do is
get an array of abc, ab, a

Then I run a union query for all three combinations. So basically select *
from {lookup_table} WHERE path = 'abc' UNION select 

Then I just retrieve the first row  mysql_fetch_object. That is what I need.

Thanks Anyways
V


Re: [PHP] I have an idea

2009-07-15 Thread Martin Scotta
On Wed, Jul 15, 2009 at 10:38 AM, Govinda wrote:
>> PHP is a great language. You can do a lot of things with him, even
>> have fun with it.
>> My idea is to make a simple game where your have to write some AI to
>> beat the other players AI
>>
>> The idea, as simple as it looks, is really difficult to implement
>> specially about security
>>
>> so, do you like me idea?
>>
>> -- Martin Scotta
>>
>
>
> sorry if this is getting OT:
>
> Martin, I wrote a really fun and charming remake of a great that 2 others
> wrote in the 1980's.  My version has really fun graphics and sounds.  I used
> visual basic as that is what I had then on my then windows laptop, without
> internet, literally in the mountains in north India where we only had
> electricity a couple hours per day, let alone no internet.  It is a simple
> but very fun strategy game with more depth than say checkers (by far!),  but
> less complex/daunting than say chess.  It has 2-player option, but writing
> the AI for the various levels of difficulty when playing against the
> computer was the most challenging and fun part of the project.  I often
> thought of taking it the next step and doing just what you propose here.   I
> don't know what is LISP, but I assume that post meant to say that PHP is not
> the best language for this.  (?)  I say, "so?"  If you know PHP, (and what,
> AJAX to go with it?)  then you can do it, and HAVE FUN, regardless that it
> is very inefficient way to do it.
> For myself I can't afford to take time for that much programming fun, just
> now..  but let me know in case you (or anyone) would like a copy of that
> game.. it may give you some ideas, not to mention it is perfect fun for
> unwinding at the end of a day of coding.  Takes 5 minutes to play.  The
> expert level is not at all easy to beat!  ;-)
> (for windows 98-->Vista.    Windows-7 I don't know... I use Mac when I have
> a choice.)
>
> -Govinda
>

That's the idea. You will have fun programming the AI and looking how
it "match" between others.

I'd like to see your game, do you still have it?

-- 
Martin Scotta

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



Re: [PHP] I have an idea

2009-07-15 Thread tedd

At 4:40 PM +0100 7/15/09, Ashley Sheridan wrote:

On Wednesday 15 July 2009 16:29:49 tedd wrote:
 > Here's an AI (rule based) php game:


 http://sperling.com/quarters/

 Get your AI to beat mine.  :-)

 Cheers,

 tedd

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


I think I can figure out how not to lose, but I don't know how to win...

--
Thanks,
Ash



Yes, but that's you -- write an AI program to do it.  :-)

Cheers,

tedd

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

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



Re: [PHP] I have an idea

2009-07-15 Thread Martin Scotta
On Wed, Jul 15, 2009 at 12:29 PM, tedd wrote:
> At 1:21 AM -0300 7/15/09, Martin Scotta wrote:
>>
>> Hi
>>
>> Do you noted that all the discussion here are about problems, bugs, or
>> just "urgent pleaaase help me"
>> I have an idea. It is not really THE idea... but it is.
>> What happen if tell this idea to the community? I don't know, so,
>> let's take a look.
>>
>>
>> PHP is a great language. You can do a lot of things with him, even
>> have fun with it.
>> My idea is to make a simple game where your have to write some AI to
>> beat the other players AI
>>
>> The idea, as simple as it looks, is really difficult to implement
>> specially about security
>>
>> so, do you like me idea?
>>
>> --
>
> Here's an AI (rule based) php game:
>
> http://sperling.com/quarters/
>
> Get your AI to beat mine.  :-)
>
> Cheers,
>
> tedd
>
> --
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>

nice game tedd, I played it a lot of times and still can't beat it.
Also I have pass the link about 2 weeks ago in the office... and the
AI always wins

quite frustrating, but really entertained

-- 
Martin Scotta

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



Re: [PHP] Alphabetical pagination

2009-07-15 Thread Miller, Terion



--snip


How do I write the for each loop in here:

   //alphabetical pagination links  
  if (!isset($_GET['letter'])) {$letter = "A";} else 
{$letter = $_GET['letter'];}
echo ''; 
   for ($i=65; $i<90; $i++) {   
 if ($letter!= chr($i)) {echo 
'';}
echo chr($i)." ";  
  if ($letter!= chr($i)) {echo '';  

  ->>> for each letter 
pull out those restaurants names and reload the page    




 }}

Or is that passed in the isset portion,

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



Re: [PHP] I have an idea

2009-07-15 Thread Govinda

That's the idea. You will have fun programming the AI and looking how
it "match" between others.

I'd like to see your game, do you still have it?

--  
Martin Scotta



I would love to see someone write an AI to beat my best skill level  
that I could get into the AI.  I can beat expert level now, every  
time..  so I know there is more than I have captured so far in the  
AI..  (thus the greyed-out option for skill level "Master")  .. but as  
Tedd alluded to in his reply to Ashley - having the skill is one  
thing.. but capturing the skill in bytes is a feat, not for the meek  
coder!


http://www.blisscode.com/BC_downloadables/Rama's%20Campaign%201.0.2%20-%20INSTALLER.ZIP

the game itself is like 1MB.  The rest of those 14 MB's are for the  
sounds (.wav) mostly..  and a few small graphics.


make sure your windows desktop screen resolution is set to the default  
(96 d.p.i., IIRC) or else it is unplayable due to improper positioning  
of controls.  Also ignore the hokey opening ..  I wrote it for the  
members of the ashram where I was living at the time; just push any  
key to get past the intro and then read the directions of how to play  
in the help menu - the "?" icon in the sky on the top right.


Let me know how it goes!


Govinda
govinda.webdnat...@gmail.com


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



[PHP] boolean vs int comparison

2009-07-15 Thread Martin Scotta
I always have doubts about comparison between boolean and integers.
Lets PHP shows hows is that he does.

The results where:
false <   $int === true / $int !== 0
false <=  $int === true
false >   $int === false
false >=  $int === false / $int !== 0
false ==  $int === false / $int !== 0
false === $int === false
false !=  $int === true / $int !== 0
false !== $int === true
true  <   $int === false
true  <=  $int === true / $int !== 0
true  >   $int === false / $int !== 0
true  >=  $int === true
true  ==  $int === true / $int !== 0
true  === $int === false
true  !=  $int === false / $int !== 0
true  !== $int === true

  ', '>= ', '== ', '===', '!= ', '!==') as
$test)
for($i=-1; $i<1; ++$i)
{
@eval(
'$value =' . (
$_test = bol2string($boolean) . ' ' . $test . ' ' . $i
) . ';'
);
$results[ $boolean][ $test ][ $i ] = $value;
}

foreach($results as $boolean => $_boolean)
foreach($_boolean as $test => $_test)
echo bol2string($boolean) , $boolean ? '  ': ' ' ,
$test ,' $int === ' , bol2string($_test[-1]),
$_test[0] !== $_test[-1] ? ' / $int !== 0' : '' ,
PHP_EOL;
?>
-- 
Martin Scotta


Re: [PHP] I have an idea

2009-07-15 Thread Ashley Sheridan
On Wed, 2009-07-15 at 12:28 -0400, tedd wrote:
> At 4:40 PM +0100 7/15/09, Ashley Sheridan wrote:
> >On Wednesday 15 July 2009 16:29:49 tedd wrote:
> >  > Here's an AI (rule based) php game:
> >>
> >>  http://sperling.com/quarters/
> >>
> >>  Get your AI to beat mine.  :-)
> >>
> >>  Cheers,
> >>
> >>  tedd
> >>
> >>  --
> >>  ---
> >>  http://sperling.com  http://ancientstones.com  http://earthstones.com
> >
> >I think I can figure out how not to lose, but I don't know how to win...
> >
> >--
> >Thanks,
> >Ash
> 
> 
> Yes, but that's you -- write an AI program to do it.  :-)
> 
> Cheers,
> 
> tedd
> 
> -- 
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> 
Done! In order to never lose, don't play ;)

Thanks
Ash
www.ashleysheridan.co.uk


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



Re: [PHP] I have an idea

2009-07-15 Thread Daniel Brown
On Wed, Jul 15, 2009 at 15:30, Ashley Sheridan wrote:
> Done! In order to never lose, don't play ;)

That's what I had expected.  ;-P

About eleven years ago, a co-worker and I each wanted the same day
off.  I had seniority, but decided to play fair with him and give him
a shot.  I told him that I could guarantee I could tell him the score
of a football game that night before the game started.  If I was
wrong, he could have the day off AND I would give him my pay for the
day (we were medics for the state, so it wasn't a horrible chunk of
change).  If I was right, I got the day off --- but to make sure it
was fair, we had to watch the game together that night, and he had to
pay for pizza.

When I got to his house, he ordered the pizza and asked if I was
ready to lose.  I told him quite the contrary: before the game starts,
the score is a tie at zero-zero.

Being a good sport and admitting defeat, he let me have the day
off.  Being as graceful as he was, I instead let him have the day
off and paid for the pizza.

A very "cheesy" story (yeah, that's right), but relevant.  Seems
that now, in some places, trying to pull the same gag - even on a
friend - could get you two to the chest, single to the head.  People
just don't have a sense of humor anymore

-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Check out our great hosting and dedicated server deals at
http://twitter.com/pilotpig

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



Re: [PHP] I have an idea

2009-07-15 Thread VamVan
On Wed, Jul 15, 2009 at 12:40 PM, Daniel Brown  wrote:

> On Wed, Jul 15, 2009 at 15:30, Ashley Sheridan
> wrote:
> > Done! In order to never lose, don't play ;)
>
> That's what I had expected.  ;-P
>
>About eleven years ago, a co-worker and I each wanted the same day
> off.  I had seniority, but decided to play fair with him and give him
> a shot.  I told him that I could guarantee I could tell him the score
> of a football game that night before the game started.  If I was
> wrong, he could have the day off AND I would give him my pay for the
> day (we were medics for the state, so it wasn't a horrible chunk of
> change).  If I was right, I got the day off --- but to make sure it
> was fair, we had to watch the game together that night, and he had to
> pay for pizza.
>
>When I got to his house, he ordered the pizza and asked if I was
> ready to lose.  I told him quite the contrary: before the game starts,
> the score is a tie at zero-zero.
>
>Being a good sport and admitting defeat, he let me have the day
> off.  Being as graceful as he was, I instead let him have the day
> off and paid for the pizza.
>
>A very "cheesy" story (yeah, that's right), but relevant.  Seems
> that now, in some places, trying to pull the same gag - even on a
> friend - could get you two to the chest, single to the head.  People
> just don't have a sense of humor anymore
>
> --
> 
> daniel.br...@parasane.net || danbr...@php.net
> http://www.parasane.net/ || http://www.pilotpig.net/
> Check out our great hosting and dedicated server deals at
> http://twitter.com/pilotpig
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> : nice one


Re: [PHP] I have an idea

2009-07-15 Thread Tom Worster
On 7/15/09 12:21 AM, "Martin Scotta"  wrote:

> Hi
> 
> Do you noted that all the discussion here are about problems, bugs, or
> just "urgent pleaaase help me"
> I have an idea. It is not really THE idea... but it is.
> What happen if tell this idea to the community? I don't know, so,
> let's take a look.
> 
> 
> PHP is a great language. You can do a lot of things with him, even
> have fun with it.
> My idea is to make a simple game where your have to write some AI to
> beat the other players AI
> 
> The idea, as simple as it looks, is really difficult to implement
> specially about security
> 
> so, do you like me idea?

like core wars?



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



Re: [PHP] I have an idea

2009-07-15 Thread tedd

At 3:40 PM -0400 7/15/09, Daniel Brown wrote:

When I got to his house, he ordered the pizza and asked if I was
ready to lose.  I told him quite the contrary: before the game starts,
the score is a tie at zero-zero.


Reminds me of many years ago when I was in New Orleans and a street 
kid came up to me and said "I bet I know where you got them boots."


Considering that my boots were genuine elephant-skin made custom by a 
boot maker in Las Vegas, I figured that the kid had mistaken the 
maker for someone local. So I asked him "How much?" and he answered 
"Five Bucks!"


I said "Okay, you got a bet." and the kid replied "You got them boots 
on Bourbon Street." Considering that I was currently standing on 
Bourbon street in the french Quarter, I saw how I had been tricked.


In any event, I paid the kid $5 and the next kid who asked me the 
same question, I qualified the bet but had no takers.


Cheers,

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

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



Re: [PHP] Scope of Variables and use of global and this->var

2009-07-15 Thread tedd

At 12:21 PM +0200 7/14/09, Anton Heuschen wrote:


In my index.php page I then use $dbconnect again  but do I simply use
$dbconnect again ... or must I say global $dbconnect and then use it in the
rest of the DB calls? or use GLOBALS ..


Anton:

My way -- every time I open a database, I do so by including the 
configuration.php file that holds the logon/password et other data to 
connect with the database. When I'm done with what I want from the 
database, I close it. I do not store anything in GLOBALS.


Cheers,

tedd


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

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




[PHP] why is this SIMPLE elseif not firing?

2009-07-15 Thread Govinda
Sorry this is isn't good 'ninja' material..  but I gotta start where I  
am.


this:

echo 'is set (EditExistingClient) ='. isset($EditExistingClient).">\n";

is returning:
is set (EditExistingClient) =1

but this, later down the page:
elseif ((isset($EditExistingClient)) || ($CreateClient)) //we just  
created a client, OR edited a client

{
echo ''."\n";

}

is not firing unless $CreateClient is set.

This, too, is not firing when I think it should:
elseif (($EditExistingClient) || ($CreateClient)) //we just created a  
client, OR edited a client

{
echo ''."\n";

}

what ridiculously simple thing am I missing?



Govinda
govinda.webdnat...@gmail.com


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



[PHP] Re: why is this SIMPLE elseif not firing?

2009-07-15 Thread Govinda

nevermind..  sorry for the noise.
It was my if clause that was firing too much, and never even reaching  
that elseif.

-G

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



Re: [PHP] why is this SIMPLE elseif not firing?

2009-07-15 Thread Jim Lucas
Govinda wrote:
> Sorry this is isn't good 'ninja' material..  but I gotta start where I am.
> 
> this:
> 
> echo 'is set (EditExistingClient) ='. isset($EditExistingClient)." />\n";

I realize this is after the fact, but...

The above does not indicate WHAT it is set too.  Just that it is set.

it could be set to /null/, FALSE, or 0 and they would all return false,
and fail, in your if condition later on.


> is returning:
> is set (EditExistingClient) =1
> 
> but this, later down the page:
> elseif ((isset($EditExistingClient)) || ($CreateClient)) //we just
> created a client, OR edited a client
> {
> echo ''."\n";
> }
> 
> is not firing unless $CreateClient is set.
> 
> This, too, is not firing when I think it should:
> elseif (($EditExistingClient) || ($CreateClient)) //we just created a
> client, OR edited a client
> {
> echo ''."\n";
> }
> 
> what ridiculously simple thing am I missing?
> 
> 
> 
> Govinda
> govinda.webdnat...@gmail.com
> 
> 



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



Re: [PHP] why is this SIMPLE elseif not firing?

2009-07-15 Thread Govinda

I realize this is after the fact, but...

The above does not indicate WHAT it is set too.  Just that it is set.

it could be set to /null/, FALSE, or 0 and they would all return  
false,

and fail, in your if condition later on.


I understand.  I appreciate your taking the time to explain things.
You too Nathan!

-G


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



Re: [PHP] PHP/mysql equivalent of PEAR's tableInfo()??

2009-07-15 Thread Jason Pruim


On Jul 13, 2009, at 10:03 AM, Govinda wrote:


I have this code:

  $db_billing=mysqli_connect(localhost,metheuser,mypass,billing);
  if (mysqli_connect_error()) { die("Can't connect: " .  
mysqli_connect_error()); }


mysqli


  //$dbname = 'billing';
  $sql = "SHOW TABLES";

  $result = mysql_query($sql); // line 53

Now mysql, What are you doing?


Yes.  3 lashing.  Thanks.  I am not likely to neglect again  
remembering that mysql and mysqli are different and have different  
syntax.


unfortunately I am still in over my head enough to have to ask..

Here is what I have now:

$db_billing=mysql_connect(localhost,metheuser,mypass,billing);
if (!$db_billing) { die('Could not connect: ' . mysql_error()); }

$sql = "SHOW TABLES";

$result = mysql_query($sql);

foreach(mysql_fetch_assoc($result) as $k => $v) { //line 62
$ssql = "DESCRIBE ".mysql_real_escape_string($v);
$rresult = mysql_query($ssql);
echo "".$k.":\n";
echo "\n";
print_r(mysql_fetch_assoc($rresult));
echo "\n";
echo "\n";
}

giving this error:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL  
result resource in /home/meee/public_html/somedir/test.php on line 62


I read about:
-mysql_fetch_assoc
-mysql_query
-SHOW TABLES

but do not see why this should be failing.  Why isn't $result a '  
valid MySQL result resource'?


Better late then never! :)

I played around with your code tonight and got this working on a test  
server:



$db_billing = mysql_connect($DBHOST, $DBUSER, $DBPASS) or die("Could  
not connect: " .mysql_error());


$db_selected = mysql_select_db($DB, $db_billing);

if(!$db_selected) {
die("Can't use database: " . mysql_error());
}


if (!$db_billing) { die('Could not connect: ' . mysql_error()); }

$sql = "SHOW TABLES";

$result = mysql_query($sql) or die("query failed:  
" .mysql_error());

$resulttest = mysql_fetch_assoc($result);


foreach($resulttest as $k => $v) { //line 62
$ssql = "DESCRIBE ".mysql_real_escape_string($v);
$rresult = mysql_query($ssql);
echo "".$k.":\n";
echo "\n";
print_r(mysql_fetch_assoc($rresult));
echo "\n";
echo "\n";
}



?>

The only big difference from what you had is that I moved the  
mysql_fetch_assoc($result); into a separate line rather then running  
it from the foreach...


Let me know if that helps.



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



Re: [PHP] PHP/mysql equivalent of PEAR's tableInfo()??

2009-07-15 Thread Govinda


Better late then never! :)

I played around with your code tonight and got this working on a  
test server:



$db_billing = mysql_connect($DBHOST, $DBUSER, $DBPASS) or die("Could  
not connect: " .mysql_error());


$db_selected = mysql_select_db($DB, $db_billing);

   if(!$db_selected) {
   die("Can't use database: " . mysql_error());
   }


if (!$db_billing) { die('Could not connect: ' . mysql_error()); }

   $sql = "SHOW TABLES";

   $result = mysql_query($sql) or die("query failed:  
" .mysql_error());

   $resulttest = mysql_fetch_assoc($result);


   foreach($resulttest as $k => $v) { //line 62
   $ssql = "DESCRIBE ".mysql_real_escape_string($v);
   $rresult = mysql_query($ssql);
   echo "".$k.":\n";
   echo "\n";
   print_r(mysql_fetch_assoc($rresult));
   echo "\n";
   echo "\n";
   }



?>

The only big difference from what you had is that I moved the  
mysql_fetch_assoc($result); into a separate line rather then running  
it from the foreach...


Let me know if that helps.


Thanks Jason :-)

What you just offered just shows info about only the first column in  
the table.


I got this working to show info about all the columns in the table:

$ssql = "DESCRIBE billing_table";
$rresult = mysql_query($ssql);
echo "\n";
while ($row = mysql_fetch_assoc($rresult)) {
print_r($row); //line 278
}
echo "\n";
echo "\n";

-G

Re: [PHP] why is this SIMPLE elseif not firing?

2009-07-15 Thread Stuart
2009/7/15 Govinda :
> Sorry this is isn't good 'ninja' material..  but I gotta start where I am.
>
> this:
>
> echo 'is set (EditExistingClient) ='. isset($EditExistingClient)."\n";
> is returning:
> is set (EditExistingClient) =1
>
> but this, later down the page:
> elseif ((isset($EditExistingClient)) || ($CreateClient)) //we just created a
> client, OR edited a client
> {
> echo ''."\n";
> }
>
> is not firing unless $CreateClient is set.
>
> This, too, is not firing when I think it should:
> elseif (($EditExistingClient) || ($CreateClient)) //we just created a
> client, OR edited a client
> {
> echo ''."\n";
> }
>
> what ridiculously simple thing am I missing?

The only possibility I can see is that $EditExistingClient is getting
modified between the echo and the first elseif statement.

-Stuart

-- 
http://stut.net/

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



Re: [PHP] why is this SIMPLE elseif not firing?

2009-07-15 Thread Stuart
Oops, clearly too early in the morning to be looking at code. Sorry.

-Stuart

2009/7/16 Stuart :
> 2009/7/15 Govinda :
>> Sorry this is isn't good 'ninja' material..  but I gotta start where I am.
>>
>> this:
>>
>> echo 'is set (EditExistingClient) ='. isset($EditExistingClient)."\n";
>> is returning:
>> is set (EditExistingClient) =1
>>
>> but this, later down the page:
>> elseif ((isset($EditExistingClient)) || ($CreateClient)) //we just created a
>> client, OR edited a client
>> {
>> echo ''."\n";
>> }
>>
>> is not firing unless $CreateClient is set.
>>
>> This, too, is not firing when I think it should:
>> elseif (($EditExistingClient) || ($CreateClient)) //we just created a
>> client, OR edited a client
>> {
>> echo ''."\n";
>> }
>>
>> what ridiculously simple thing am I missing?
>
> The only possibility I can see is that $EditExistingClient is getting
> modified between the echo and the first elseif statement.
>
> -Stuart
>
> --
> http://stut.net/
>

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