php-general Digest 16 Jul 2010 03:37:17 -0000 Issue 6848

Topics (messages 306908 through 306935):

Stumped - MDB2 & pgsql
        306908 by: Michael A. Peters
        306911 by: Michael A. Peters
        306915 by: Michael A. Peters

Re: How to alter the schema of a database to introducenewfeatures or change the 
current features
        306909 by: Bob McConnell
        306910 by: Richard Quadling

Re: Problem when adding special characters to an XML file
        306912 by: te0t3l

set different .htaccess rules
        306913 by: Dušan Novaković
        306929 by: Tommy Pham
        306935 by: kranthi

Recent Influx of Unrelated Discussions
        306914 by: Daniel Brown

user login and access + headers already sent
        306916 by: Carlos Sura
        306917 by: Richard Quadling
        306918 by: kranthi
        306920 by: Ashley Sheridan
        306921 by: Carlos Sura
        306927 by: Paul M Foster
        306928 by: Carlos Sura

Determining the similarity between a user supplied short piece of text (between 
5 and 15 characters) and a list of similar length text items.
        306919 by: Richard Quadling
        306923 by: Ashley Sheridan
        306924 by: Daniel P. Brown

integrating lib (C++) into php
        306922 by: Tom Sparks
        306925 by: Daniel P. Brown
        306926 by: shiplu

Weird behavior of exec()
        306930 by: Leonardo
        306931 by: Shawn McKenzie
        306932 by: Leonardo
        306933 by: Shawn McKenzie
        306934 by: Leonardo

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

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


----------------------------------------------------------------------
--- Begin Message --- I need to switch from MySQL (where everything is peachy) to Postgresql - reason I need to switch is I need to use PostGIS and I don't see a need to run two databases.

I got Postgresql installed (stock CentOS / RHEL 5) and installed the postgresql php module and mdb2 driver. Restarted the web server.

Did a MySQL dump, ran it through a perl script, and managed to get it load into Postgresql without any apparent hickups. I can connect to postgresql and issue queries and expected results are in fact returned.

Made a user called webuser (what, you expect the real name to be disclosed here ??) in postgresql and gave it a password and access to the database. Updated the data/pg_hba.conf to add the following line:

local    mydbname webuser   127.0.0.1         password

restarted the postgresql server.

I *thought* that all I would then have to do is change my mdb2 dsn to reflect the new driver to use and then find parts of my code that are not standard enough SQL - but when I try to use anything, I get -

Fatal error: Call to undefined method MDB2_Error::execute() in /path/to/blah on line 63

I'm missing something here.

Here's my dsn -

$dsn = array(
   'phptype'  => 'pgsql',
   'username' => 'webuser',
   'password' => 'secret',
   'hostspec' => 'localhost',
   'database' => 'mydbname');

What am I doing wrong?
I get the same error no matter what I set username/password/hostspec/database to - so I think it is a basic connection error.

I'm hoping to be able to get the switch to postgresql finished soon so that I can start playing with using the PostGIS extension.

I'm running php 5.2.12 (my own build, based on Fedora src.rpm) w/ pear 1.8.1:

pear list
Installed packages, channel pear.php.net:
=========================================
Package           Version State
Archive_Tar       1.3.3   stable
Console_Getopt    1.2.3   stable
Date              1.4.7   stable
MDB2              2.4.1   stable
MDB2_Driver_mysql 1.4.1   stable
MDB2_Driver_pgsql 1.4.1   stable
PEAR              1.8.1   stable
Structures_Graph  1.0.2   stable
Text_Highlighter  0.7.1   beta
XML_Parser        1.3.2   stable
XML_RPC           1.5.1   stable
XML_Util          1.2.1   stable

Thanks for suggestions.

--- End Message ---
--- Begin Message ---
Michael A. Peters wrote:
I need to switch from MySQL (where everything is peachy) to Postgresql - reason I need to switch is I need to use PostGIS and I don't see a need to run two databases.

I got Postgresql installed (stock CentOS / RHEL 5) and installed the postgresql php module and mdb2 driver. Restarted the web server.

Did a MySQL dump, ran it through a perl script, and managed to get it load into Postgresql without any apparent hickups. I can connect to postgresql and issue queries and expected results are in fact returned.

Made a user called webuser (what, you expect the real name to be disclosed here ??) in postgresql and gave it a password and access to the database. Updated the data/pg_hba.conf to add the following line:

local    mydbname webuser   127.0.0.1         password

restarted the postgresql server.

I *thought* that all I would then have to do is change my mdb2 dsn to reflect the new driver to use and then find parts of my code that are not standard enough SQL - but when I try to use anything, I get -

Fatal error: Call to undefined method MDB2_Error::execute() in /path/to/blah on line 63

I'm missing something here.

Here's my dsn -

$dsn = array(
   'phptype'  => 'pgsql',
   'username' => 'webuser',
   'password' => 'secret',
   'hostspec' => 'localhost',
   'database' => 'mydbname');

What am I doing wrong?
I get the same error no matter what I set username/password/hostspec/database to - so I think it is a basic connection error.

Yes, I put some error catching in -

MDB2 Error: connect failed, _doConnect: [Error message: unable to establish a connection]

So it looks like pg_hba.conf file either isn't allowing it or something else is blocking it.

*sigh* - guess back to trying to find document on setting up authentication for an account for a pgsql web app user because the docs I did find don't seem to be accurate.
--- End Message ---
--- Begin Message ---
Michael A. Peters wrote:
Michael A. Peters wrote:
I need to switch from MySQL (where everything is peachy) to Postgresql - reason I need to switch is I need to use PostGIS and I don't see a need to run two databases.

I got Postgresql installed (stock CentOS / RHEL 5) and installed the postgresql php module and mdb2 driver. Restarted the web server.

Did a MySQL dump, ran it through a perl script, and managed to get it load into Postgresql without any apparent hickups. I can connect to postgresql and issue queries and expected results are in fact returned.

Made a user called webuser (what, you expect the real name to be disclosed here ??) in postgresql and gave it a password and access to the database. Updated the data/pg_hba.conf to add the following line:

local    mydbname webuser   127.0.0.1         password

restarted the postgresql server.

I *thought* that all I would then have to do is change my mdb2 dsn to reflect the new driver to use and then find parts of my code that are not standard enough SQL - but when I try to use anything, I get -

Fatal error: Call to undefined method MDB2_Error::execute() in /path/to/blah on line 63

I'm missing something here.

Here's my dsn -

$dsn = array(
   'phptype'  => 'pgsql',
   'username' => 'webuser',
   'password' => 'secret',
   'hostspec' => 'localhost',
   'database' => 'mydbname');

What am I doing wrong?
I get the same error no matter what I set username/password/hostspec/database to - so I think it is a basic connection error.

Yes, I put some error catching in -

MDB2 Error: connect failed, _doConnect: [Error message: unable to establish a connection]

So it looks like pg_hba.conf file either isn't allowing it or something else is blocking it.

Possibly solved.
This line works -

host    mydbname webuser       127.0.0.1/32         password

provided I removed the previous host line that specified authentication by ident for all users connection via tcp from localhost.

Still getting errors, but now its a db grant issue and not a connection issue, so i think I'm good to go.
--- End Message ---
--- Begin Message ---
From: Pete Ford

> On 15/07/10 09:14, Ashley Sheridan wrote:
>> ALTER TABLE is the way to go. If in doubt, look at the SQL phpMyAdmin
>> produces when you make the changes in there.
>>
>
> Yeah, scripting "ALTER TABLE" commands ... :)

We maintain two files for every schema, site_schema.pgsql and
site_delta.pgsql. Every time we modify the schema, we add the change
commands to the delta file. We also have markers in it for each build
number, so the update scripts can determine which changes need to be run
when a site is updated.

We use a similar technique on other systems that use Oracle or Sybase
ASA on the back end, but those are stored as a shell database and sets
of patch files for each build.

Bob McConnell

--- End Message ---
--- Begin Message ---
On 15 July 2010 13:29, Bob McConnell <r...@cbord.com> wrote:
> From: Pete Ford
>
>> On 15/07/10 09:14, Ashley Sheridan wrote:
>>> ALTER TABLE is the way to go. If in doubt, look at the SQL phpMyAdmin
>>> produces when you make the changes in there.
>>>
>>
>> Yeah, scripting "ALTER TABLE" commands ... :)
>
> We maintain two files for every schema, site_schema.pgsql and
> site_delta.pgsql. Every time we modify the schema, we add the change
> commands to the delta file. We also have markers in it for each build
> number, so the update scripts can determine which changes need to be run
> when a site is updated.
>
> We use a similar technique on other systems that use Oracle or Sybase
> ASA on the back end, but those are stored as a shell database and sets
> of patch files for each build.
>
> Bob McConnell

I use a tool called SQL Compare and SQL Data Compare - by a company
called RedGate. These allow me and others to work on our in-house DBs
and when we are ready to roll out the release, create a changeset of
all the differences between the last release and this one.

It only works on MS SQL servers, but there are others [1]

Regards,

Richard Quadling.

[1] 
http://stackoverflow.com/questions/1265962/is-there-an-equivalent-of-redgate-sql-compare-for-mysql-databases

--- End Message ---
--- Begin Message ---
Thanks for your offer Richard, but I solved the problem deleting the UTF-8
encoding label in the XML file like this:

before: <?xml version="1.0" encoding="utf-8"?>
   <label>....</label>

after: <?xml version="1.0"?>

--- End Message ---
--- Begin Message ---
Hello all,

I have problem with protecting files inside of folder. So, I have one
folder with files inside and the idea is to be able to see those files
(format is not important) only when you are logged in system.
I can't use solutions like to set some wierd name so that actually
user is hardly able to guess the real path to that file, something
like http://site.com/files/we23h4hk234hjksdjrjkl23jfasdf
Is there some trick with .htaccess to check some php value and set
different rules if some another value in php is set or not. I know
that you are able to set some php values in .htaccess, but as I said,
is it possible to manipulate with them inside of .htaccess. Or if
someone has some better solution, you are welcome to write it down :-)

Regards,
Dusan

-- 
mob: + 46 70 044 9432
web: http://novakovicdusan.com

Please consider the environment before printing this email.

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Dušan Novaković [mailto:ndu...@gmail.com]
> Sent: Thursday, July 15, 2010 7:46 AM
> To: php-gene...@lists.php.net
> Subject: [PHP] set different .htaccess rules
> 
> Hello all,
> 
> I have problem with protecting files inside of folder. So, I have one folder
> with files inside and the idea is to be able to see those files (format is not
> important) only when you are logged in system.
> I can't use solutions like to set some wierd name so that actually user is
> hardly able to guess the real path to that file, something like
> http://site.com/files/we23h4hk234hjksdjrjkl23jfasdf
> Is there some trick with .htaccess to check some php value and set different
> rules if some another value in php is set or not. I know that you are able to
> set some php values in .htaccess, but as I said, is it possible to manipulate
> with them inside of .htaccess. Or if someone has some better solution, you
> are welcome to write it down :-)
> 
> Regards,
> Dusan
> 
> --
> mob: + 46 70 044 9432
> web: http://novakovicdusan.com
> 
> Please consider the environment before printing this email.
> 

Dusan,

You can create several components with PHP:
1) authentication, authorization and personalization
2) displaying the files in the various format and whether to permit navigating 
parent/sub- directories: file explorer like, filmstrip, slideshow, preview 
etc...

Then combine the components in one index.php and drop that file in all the 
desired directories.  This will give you enhanced customized service for each 
authorized user, especially if you combine it all with AJAX too.

Regards,
Tommy


--- End Message ---
--- Begin Message ---
i would use a single point of entry to solve this problem
1. keep the files outside your doc root
2. in the php file files.php check for an authorized user, if so allow
the user to download the file

the path http://site.com/files/we23h4hk234hjksdjrjkl23jfasdf will
actually be http://site.com/files.php?file=we23h4hk234hjksdjrjkl23jfasdf

if you hav access to httpd.conf (i am not sure if .htaccss works) u
can set the non php extensions to be executed by the php interpreter
and check for authorization (the way rapidshare works)

--- End Message ---
--- Begin Message ---
    Also known as off-topic posts.  We're all guilty of them, but has
anyone recently noticed that there is a significant number (about 35%
of all traffic) that is off-topic?  There have been questions on
databases, JavaScript, WordPress, Apache directives, and more.... none
of which were even related to PHP.  Unfortunately, this is how
dilution occurs, which often causes communities to dwindle into a
defunct or otherwise low-quality state.  As those of you who have been
around for at least a couple of years know, we have continued to
thrive here because we're not strict on the topics of discussion, and
frequently [d]evolve into off-topic banter (particularly on Fridays,
as it used to be).  However, have you noticed the influx of extremely
low-quality and/or low-class posts to the list?  Couple that with the
ominous silence from the formerly-frequent contributors of
high-quality material, code examples, and community assistance.  It is
not a coincidence.

    This is an open list, and we don't moderate or censor any of the
discussions, but before it gets out of hand, I'd like to suggest a
moratorium on all off-topic posts through the end of this month ---
with the exception, again, of Fridays.  Which would mean that those in
agreement would participate in the hiatus by not only not posting
off-topic threads, but also not replying to those that are off the
general topic.  This isn't to say that threads can't still eventually
decay into a friendly discussion, as has always been welcome, but that
it shouldn't be the intent of a thread to seek assistance on topics
unrelated to PHP and PHP programming in general.


-- 
</Daniel P. Brown>
UNADVERTISED DEDICATED SERVER SPECIALS
SAME-DAY SETUP
Just ask me what we're offering today!
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/

--- End Message ---
--- Begin Message ---
Hello mates, I'm developing a user registration and access level system...

And I wonder... Is there any way to avoid to put code in every header page?
Because, almost every page contains javascript, so almost every page cotains 
<html> tags... And its annoying to look at this: Warning: session_start(): 
Cannot send session cache limiter - headers already sent

So, I'm wondering, is there any other way to avoid put code in every page? 
or... another way to avoid that kind of error.


Thank you.
                                          
_________________________________________________________________
Got a cool Hotmail story? Tell us now
http://clk.atdmt.com/UKM/go/195013117/direct/01/

--- End Message ---
--- Begin Message ---
On 15 July 2010 16:38, Carlos Sura <carlos_s...@hotmail.com> wrote:
>
> Hello mates, I'm developing a user registration and access level system...
>
> And I wonder... Is there any way to avoid to put code in every header page?
> Because, almost every page contains javascript, so almost every page cotains 
> <html> tags... And its annoying to look at this: Warning: session_start(): 
> Cannot send session cache limiter - headers already sent
>
> So, I'm wondering, is there any other way to avoid put code in every page? 
> or... another way to avoid that kind of error.

The quick and dirty way is to use output buffering - [1].

The better way is to use includes/requires - [2]. This will involve
moving code around the system, extracting common parts and then
"include"-ing them in the right place.

Also, a common practise is to only have output generated at the end of
the script, rather than using a lot of echo's through out the code. A
sort of manual output buffering.

Regards,

Richard Quadling.

[1] http://docs.php.net/manual/en/book.outcontrol.php
[2] http://docs.php.net/manual/en/language.control-structures.php and
look for include/require/include_once/require_once

--- End Message ---
--- Begin Message ---
i prefer using a template engine like smarty http://www.smarty.net/

--- End Message ---
--- Begin Message ---
On Thu, 2010-07-15 at 15:38 +0000, Carlos Sura wrote:

> Hello mates, I'm developing a user registration and access level system...
> 
> And I wonder... Is there any way to avoid to put code in every header page?
> Because, almost every page contains javascript, so almost every page cotains 
> <html> tags... And its annoying to look at this: Warning: session_start(): 
> Cannot send session cache limiter - headers already sent
> 
> So, I'm wondering, is there any other way to avoid put code in every page? 
> or... another way to avoid that kind of error.
> 
> 
> Thank you.
>                                         
> _________________________________________________________________
> Got a cool Hotmail story? Tell us now
> http://clk.atdmt.com/UKM/go/195013117/direct/01/


A key concept to remember is that HTML is inserted into your PHP code,
and not the other way around. Once I realised the difference, I found I
was making the header/output mistake far less often.

Anyway, to answer the question, what most apps/websites do for this is
to use controller code to load in the correct HTML as necessary. The
first lines of most of my apps are general include lines. One for DB,
one for other config, etc. That way, I can just use the include files
for doing things that need to be done for every page.

Common logic for a login is to use an include file that does this:


     1. Is user logged in? Yes: goto 5. No: goto 2
     2. Have login details been submitted through form or other? Yes:
        goto 3. No: goto 4
     3. Are login details correct? Yes: goto 5, No: goto 4
     4. Show login form & stop
     5. Show/redirect to app page

(apologies for the hard to follow list, but I just realised I don't know
a good way to show a flowchart in plain text!)

Use include files for your HTML headers, and only include them after
you've done everything you need to with session_start() and header()
calls. If there's content that changes in the header from page to page,
put that in a variable that you use in the included file.

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



--- End Message ---
--- Begin Message ---
Hello Richard, Thank you for your answer, I'm looking now...

Kranthi, seems to be a pretty good solution, I will give it a try. Thank you.







> From: kranthi...@gmail.com
> Date: Thu, 15 Jul 2010 21:24:15 +0530
> To: rquadl...@googlemail.com
> CC: carlos_s...@hotmail.com; php-gene...@lists.php.net
> Subject: Re: [PHP] user login and access + headers already sent
> 
> i prefer using a template engine like smarty http://www.smarty.net/
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
                                          
_________________________________________________________________
Do you have a story that started on Hotmail? Tell us now
http://clk.atdmt.com/UKM/go/195013117/direct/01/

--- End Message ---
--- Begin Message ---
On Thu, Jul 15, 2010 at 04:56:50PM +0100, Ashley Sheridan wrote:

> On Thu, 2010-07-15 at 15:38 +0000, Carlos Sura wrote:
> 
> > Hello mates, I'm developing a user registration and access level system...
> >
> > And I wonder... Is there any way to avoid to put code in every header page?
> > Because, almost every page contains javascript, so almost every
> page cotains <html> tags... And its annoying to look at this: Warning:
> session_start(): Cannot send session cache limiter - headers already sent
> >
> > So, I'm wondering, is there any other way to avoid put code in every
> page? or... another way to avoid that kind of error.
> >
> >
> > Thank you.
> >
> > _________________________________________________________________
> > Got a cool Hotmail story? Tell us now
> > http://clk.atdmt.com/UKM/go/195013117/direct/01/
> 
> 
> A key concept to remember is that HTML is inserted into your PHP code,
> and not the other way around. Once I realised the difference, I found I
> was making the header/output mistake far less often.
> 
> Anyway, to answer the question, what most apps/websites do for this is
> to use controller code to load in the correct HTML as necessary. The
> first lines of most of my apps are general include lines. One for DB,
> one for other config, etc. That way, I can just use the include files
> for doing things that need to be done for every page.
> 
> Common logic for a login is to use an include file that does this:
> 
> 
>      1. Is user logged in? Yes: goto 5. No: goto 2
>      2. Have login details been submitted through form or other? Yes:
>       goto 3. No: goto 4
>      3. Are login details correct? Yes: goto 5, No: goto 4
>      4. Show login form & stop
>      5. Show/redirect to app page
> 
> (apologies for the hard to follow list, but I just realised I don't know
> a good way to show a flowchart in plain text!)
> 
> Use include files for your HTML headers, and only include them after
> you've done everything you need to with session_start() and header()
> calls. If there's content that changes in the header from page to page,
> put that in a variable that you use in the included file.

+1

Let me amplify this by suggesting that you minimize the PHP code inside
your HTML. Like this:

1. Load your main PHP file. Do any calculations, etc., in it.
2. At the end of that file, load in a generic HTML template file. This
file would contain everything from the <html> tag to the </html> tag.
3. Inside your template file, make a call to a "view" file, which is
unique for this page. It should contain all the HTML code outside the
actual template. In this file, make whatever PHP code limited to echoing
values and loops. The values displayed, etc., are formulated in the
original PHP file.

That's one way to do it.

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---

Hello paul, thank you for your answer.

I'm already fixing all my mess with your suggestions. 
It is nice to know where to ask to get a good answer.


Regards,
Carlos Sura.





> Date: Thu, 15 Jul 2010 12:22:23 -0400
> From: pa...@quillandmouse.com
> To: php-gene...@lists.php.net
> Subject: Re: [PHP] user login and access + headers already sent
> 
> On Thu, Jul 15, 2010 at 04:56:50PM +0100, Ashley Sheridan wrote:
> 
> > On Thu, 2010-07-15 at 15:38 +0000, Carlos Sura wrote:
> > 
> > > Hello mates, I'm developing a user registration and access level system...
> > >
> > > And I wonder... Is there any way to avoid to put code in every header 
> > > page?
> > > Because, almost every page contains javascript, so almost every
> > page cotains <html> tags... And its annoying to look at this: Warning:
> > session_start(): Cannot send session cache limiter - headers already sent
> > >
> > > So, I'm wondering, is there any other way to avoid put code in every
> > page? or... another way to avoid that kind of error.
> > >
> > >
> > > Thank you.
> > >
> > > _________________________________________________________________
> > > Got a cool Hotmail story? Tell us now
> > > http://clk.atdmt.com/UKM/go/195013117/direct/01/
> > 
> > 
> > A key concept to remember is that HTML is inserted into your PHP code,
> > and not the other way around. Once I realised the difference, I found I
> > was making the header/output mistake far less often.
> > 
> > Anyway, to answer the question, what most apps/websites do for this is
> > to use controller code to load in the correct HTML as necessary. The
> > first lines of most of my apps are general include lines. One for DB,
> > one for other config, etc. That way, I can just use the include files
> > for doing things that need to be done for every page.
> > 
> > Common logic for a login is to use an include file that does this:
> > 
> > 
> >      1. Is user logged in? Yes: goto 5. No: goto 2
> >      2. Have login details been submitted through form or other? Yes:
> >     goto 3. No: goto 4
> >      3. Are login details correct? Yes: goto 5, No: goto 4
> >      4. Show login form & stop
> >      5. Show/redirect to app page
> > 
> > (apologies for the hard to follow list, but I just realised I don't know
> > a good way to show a flowchart in plain text!)
> > 
> > Use include files for your HTML headers, and only include them after
> > you've done everything you need to with session_start() and header()
> > calls. If there's content that changes in the header from page to page,
> > put that in a variable that you use in the included file.
> 
> +1
> 
> Let me amplify this by suggesting that you minimize the PHP code inside
> your HTML. Like this:
> 
> 1. Load your main PHP file. Do any calculations, etc., in it.
> 2. At the end of that file, load in a generic HTML template file. This
> file would contain everything from the <html> tag to the </html> tag.
> 3. Inside your template file, make a call to a "view" file, which is
> unique for this page. It should contain all the HTML code outside the
> actual template. In this file, make whatever PHP code limited to echoing
> values and loops. The values displayed, etc., are formulated in the
> original PHP file.
> 
> That's one way to do it.
> 
> Paul
> 
> -- 
> Paul M. Foster
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
                                          
_________________________________________________________________
We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now
http://clk.atdmt.com/UKM/go/195013117/direct/01/

--- End Message ---
--- Begin Message ---
Hi.

It seems that users cannot enter a vehicle registration 100% accurately.

We have recently released a small mobile web app which allows service
engineers/inspectors to enter a vehicle registration number and a pin
number to get service history for the vehicle.

We are getting around a 40% fail rate on the registrations for the
first time of entry. This drops to around a 1.5% error rate on the
second attempt.

Most of the time it is simply a case of 2 letters/numbers being
swapped. Sometimes a letter/number is entered for a number/letter.

0/O
1/I/l
2/Z
3/E
4/A
5/S
6/G
7/T
8/B
9/q

Some of the registrations are private and don't obey any format (NOTE:
Trailer registrations aren't the same as vehicle registrations - they
can be anything the owner wants. In some cases we have them as
straight numbers - 1, 2, 3, etc.).

I'm looking for is a way to compare what they've entered against a
known list and to provide my 10 best guesses.

What I'm stuck on is what criteria do I use.

I think something like the old style colour Mastermind game (right
colour in the right place, right colour wrong place, wrong colour).
But that's going to be slow. One of the contracts has over 30,000
vehicles/trailers available to them.

Any suggestions really.

Regards,

Richard.

--- End Message ---
--- Begin Message ---
On Thu, 2010-07-15 at 16:54 +0100, Richard Quadling wrote:

> Hi.
> 
> It seems that users cannot enter a vehicle registration 100% accurately.
> 
> We have recently released a small mobile web app which allows service
> engineers/inspectors to enter a vehicle registration number and a pin
> number to get service history for the vehicle.
> 
> We are getting around a 40% fail rate on the registrations for the
> first time of entry. This drops to around a 1.5% error rate on the
> second attempt.
> 
> Most of the time it is simply a case of 2 letters/numbers being
> swapped. Sometimes a letter/number is entered for a number/letter.
> 
> 0/O
> 1/I/l
> 2/Z
> 3/E
> 4/A
> 5/S
> 6/G
> 7/T
> 8/B
> 9/q
> 
> Some of the registrations are private and don't obey any format (NOTE:
> Trailer registrations aren't the same as vehicle registrations - they
> can be anything the owner wants. In some cases we have them as
> straight numbers - 1, 2, 3, etc.).
> 
> I'm looking for is a way to compare what they've entered against a
> known list and to provide my 10 best guesses.
> 
> What I'm stuck on is what criteria do I use.
> 
> I think something like the old style colour Mastermind game (right
> colour in the right place, right colour wrong place, wrong colour).
> But that's going to be slow. One of the contracts has over 30,000
> vehicles/trailers available to them.
> 
> Any suggestions really.
> 
> Regards,
> 
> Richard.
> 


I'm not sure how well it would work for things like a registration
number, but metaphone keys are pretty good for detecting similar words
based on phonetic sounds. If you don't get a match first time, maybe
convert all the digits in the reg no. to letters, and create a metaphone
key that you compare against the list of other keys in your DB that you
already created in the same manner (you'll need to create these first
time)

Like I said, I'm not sure how well it will work, but it might possibly
reduce the failure rate a bit.

Also, there's the electric shock treatment. Find out which engineers are
the worst typists, and... well you get the idea!

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



--- End Message ---
--- Begin Message ---
On Thu, Jul 15, 2010 at 11:54, Richard Quadling <rquadl...@gmail.com> wrote:
>
> I'm looking for is a way to compare what they've entered against a
> known list and to provide my 10 best guesses.

    Look into the following functions and families:

        levenshtein()
        similar_text()

    You wouldn't want to use metaphone() or soundex(), because you're
working with alphanumeric combinations, but if you want to be a
glutton for punishment, it could be fun.  Something along the lines of
using levenshtein() to get the best matches, then similar_text() to
score each of the matches would probably be a viable solution for you.
 The last time I incorporated something like that was for my own use
to track down a record in a MySQL database for which I could remember
just a small blip of text.  It looked through about 23 million records
in under two minutes and I found exactly what it was for which I was
searching --- even though I was off by one word.  Would've taken me
forever to find it using alternative methods.

-- 
</Daniel P. Brown>
UNADVERTISED DEDICATED SERVER SPECIALS
SAME-DAY SETUP
Just ask me what we're offering today!
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/

--- End Message ---
--- Begin Message ---
I have found lib that looks like it dose what i need
How do I integrating this lib into php?
dose php support C++ libs?

http://libnoise.sourceforge.net/tutorials/tutorial1.html#gcc


tom_a_sparks
Light travels faster then sound, which is why some people appear bright, until 
you hear them speak




--- End Message ---
--- Begin Message ---
On Thu, Jul 15, 2010 at 12:02, Tom Sparks <tom_a_spa...@yahoo.com.au> wrote:
> I have found lib that looks like it dose what i need
> How do I integrating this lib into php?
> dose php support C++ libs?
>
> http://libnoise.sourceforge.net/tutorials/tutorial1.html#gcc

    You could build it as an extension, as some of us have done in the
past.  See:

        http://www.google.com/search?q=writing+php+extensions

-- 
</Daniel P. Brown>
UNADVERTISED DEDICATED SERVER SPECIALS
SAME-DAY SETUP
Just ask me what we're offering today!
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/

--- End Message ---
--- Begin Message ---
Sure.

All you have to do is write a php extension.


Shiplu Mokadd.im
My talks, http://talk.cmyweb.net
Follow me, http://twitter.com/shiplu
SUST Programmers, http://groups.google.com/group/p2psust
Innovation distinguishes bet ... ... (ask Steve Jobs the rest)

--- End Message ---
--- Begin Message --- Hi everybody. I need to use exec() to run a background php script, but it's not working properly. Take a look at this sample:

a.php
   <?

   echo ' File A (1) ';

   exec('php b.php > output.txt &');

   echo ' File A (2) ';

   ?>

b.php
   <?

   echo 'File B';

   ?>

output.txt (begins with 64 null bytes before the following)
    File A (2)

I would expect the output's content to be "File B", but it's not happening. I came across this problem because I have a mailing application which stopped working after being moved to a new host. The messages were sent by a background script launched on user's demand. Like this:

SendMessages.php
   <?
      ...
      exec('php Daemon.php -x ' . $USERID . ' > /dev/null &');
      ...
   ?>

Now it won't work, and I got no clue about what's going on. What now?

Thank you.

--- End Message ---
--- Begin Message ---
On 07/15/2010 10:51 AM, Leonardo wrote:
> Hi everybody. I need to use exec() to run a background php script, but
> it's not working properly. Take a look at this sample:
> 
> a.php
>    <?
> 
>    echo ' File A (1) ';
> 
>    exec('php b.php > output.txt &');
> 
>    echo ' File A (2) ';
> 
>    ?>
> 
> b.php
>    <?
> 
>    echo 'File B';
> 
>    ?>
> 

Try not use the short open tag.  Use <?php

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
Em 15/07/2010 18:19, Shawn McKenzie escreveu:
On 07/15/2010 10:51 AM, Leonardo wrote:
Hi everybody. I need to use exec() to run a background php script, but
it's not working properly. Take a look at this sample:

a.php
    <?

    echo ' File A (1) ';

    exec('php b.php>  output.txt&');

    echo ' File A (2) ';

    ?>

b.php
    <?

    echo 'File B';

    ?>


Try not use the short open tag.  Use<?php


Bad habit. I know.

--- End Message ---
--- Begin Message ---
On 07/15/2010 04:40 PM, Leonardo wrote:
> 
> Bad habit. I know.

Did it fix it?

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
Em 15/07/2010 18:54, Shawn McKenzie escreveu:
On 07/15/2010 04:40 PM, Leonardo wrote:

Bad habit. I know.

Did it fix it?


Not really. The server allows short open tags. So, nothing changed.

--- End Message ---

Reply via email to