Re: [PHP] Malformed UTF-8 Data in JSON [SOLVED]

2010-07-15 Thread Benjamin Hawkes-Lewis
On 15 Jul 2010, at 04:12, Dave M G wrote:
 Yes, stripslashes() was the problem. I've removed it and the code works.
 
 However, it seems that when I send JSON data from a Javascript file, 
 stripslashes() is necessary. That's why I had it there. I'm not entirely sure 
 what's going on there, so obviously more experimentation is needed.

Presumably, thanks to your PHP settings, you need stripslashes() on all $_GET, 
$_POST, and $_COOKIE input.

http://www.php.net/manual/en/info.configuration.php#ini.magic-quotes-gpc

This does not apply to input from other sources.

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



Re: [PHP] How to alter the schema of a database to introduce newfeatures or change the current features

2010-07-15 Thread Pete Ford

On 15/07/10 06:03, Paul M Foster wrote:

On Wed, Jul 14, 2010 at 09:28:53PM -0700, Slith One wrote:


I'm developing an app using Zend Framwork using Git for version control.

What is the best approach for updating the schema and the database
when one of us makes an update to the db structure?

currently, we have to blow out the tables and recreate them manually
to reflect the new updates.


I'm probably being naive, but don't you have an ALTER TABLE sql
statement available to you?

Also, for what it's worth, I don't build tables manually (at the command
line or whatever). I always create a script which will build the tables
I need. If, for some crazy reason, I do have to restart from scratch,
it's a simple matter to alter that script and re-run it.

Paul



Scripting is the way to go for database changes: every time I have to make a 
schema change I write an SQL script to do the job, including any manipulation of 
data required. Then I make a copy of the real data and test the hell out of the 
change script before going live with it.
You can commit the database script to your source control at the time you commit 
the code changes, and then when you update the live system you run any new 
scripts at the same time.




--
Peter Ford, Developer phone: 01580 89 fax: 01580 893399
Justcroft International Ltd.  www.justcroft.com
Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United Kingdom
Registered in England and Wales: 2297906
Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS

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




Re: [PHP] How to alter the schema of a database to introduce newfeatures or change the current features

2010-07-15 Thread Ashley Sheridan
On Thu, 2010-07-15 at 09:07 +0100, Pete Ford wrote:

 On 15/07/10 06:03, Paul M Foster wrote:
  On Wed, Jul 14, 2010 at 09:28:53PM -0700, Slith One wrote:
 
  I'm developing an app using Zend Framwork using Git for version control.
 
  What is the best approach for updating the schema and the database
  when one of us makes an update to the db structure?
 
  currently, we have to blow out the tables and recreate them manually
  to reflect the new updates.
 
  I'm probably being naive, but don't you have an ALTER TABLE sql
  statement available to you?
 
  Also, for what it's worth, I don't build tables manually (at the command
  line or whatever). I always create a script which will build the tables
  I need. If, for some crazy reason, I do have to restart from scratch,
  it's a simple matter to alter that script and re-run it.
 
  Paul
 
 
 Scripting is the way to go for database changes: every time I have to make a 
 schema change I write an SQL script to do the job, including any manipulation 
 of 
 data required. Then I make a copy of the real data and test the hell out of 
 the 
 change script before going live with it.
 You can commit the database script to your source control at the time you 
 commit 
 the code changes, and then when you update the live system you run any new 
 scripts at the same time.
 
 
 
 -- 
 Peter Ford, Developer phone: 01580 89 fax: 01580 893399
 Justcroft International Ltd.  www.justcroft.com
 Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United Kingdom
 Registered in England and Wales: 2297906
 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS
 


ALTER TABLE is the way to go. If in doubt, look at the SQL phpMyAdmin
produces when you make the changes in there.

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




Re: [PHP] How to alter the schema of a database to introducenewfeatures or change the current features

2010-07-15 Thread 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.

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




Yeah, scripting ALTER TABLE commands ... :)

--
Peter Ford, Developer phone: 01580 89 fax: 01580 893399
Justcroft International Ltd.  www.justcroft.com
Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United Kingdom
Registered in England and Wales: 2297906
Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS

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



Re: [PHP] Problem when adding special characters to an XML file

2010-07-15 Thread te0t3l
Hi again,

Now I download the editing XML file and open it in windows with notepad and
save with utf-8 encode, then upload the file again and can see the correct
characters, what's the problem? I'm specifying the correct encoding when
process the form and editing the XML file:

$XML = new DOMDocument('1.0', 'UTF-8');

Any idea please...
Thanks,

te0


Re: [PHP] Problem when adding special characters to an XML file

2010-07-15 Thread Richard Quadling
On 15 July 2010 12:01, te0t3l te0...@gmail.com wrote:
 Hi again,

 Now I download the editing XML file and open it in windows with notepad and
 save with utf-8 encode, then upload the file again and can see the correct
 characters, what's the problem? I'm specifying the correct encoding when
 process the form and editing the XML file:

 $XML = new DOMDocument('1.0', 'UTF-8');

 Any idea please...
 Thanks,

 te0


Can you do a binary comparison between the 2 files (assuming you have
an original).

FC file1.xml file2.xml /b

Or can you zip them both and I can take a look at them for you (email
me directly).

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



[PHP] Stumped - MDB2 pgsql

2010-07-15 Thread Michael A. Peters
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:


localmydbname 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_Getopt1.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_Parser1.3.2   stable
XML_RPC   1.5.1   stable
XML_Util  1.2.1   stable

Thanks for suggestions.

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



RE: [PHP] How to alter the schema of a database to introducenewfeatures or change the current features

2010-07-15 Thread Bob McConnell
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

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



Re: [PHP] How to alter the schema of a database to introducenewfeatures or change the current features

2010-07-15 Thread Richard Quadling
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

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



Re: [PHP] Stumped - MDB2 pgsql

2010-07-15 Thread Michael A. Peters

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:


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


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



Re: [PHP] Problem when adding special characters to an XML file

2010-07-15 Thread te0t3l
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?


[PHP] set different .htaccess rules

2010-07-15 Thread Dušan Novaković
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.

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



[PHP] Recent Influx of Unrelated Discussions

2010-07-15 Thread Daniel Brown
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/

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



Re: [PHP] Stumped - MDB2 pgsql

2010-07-15 Thread Michael A. Peters

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:


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

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


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



[PHP] user login and access + headers already sent

2010-07-15 Thread Carlos Sura

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/

Re: [PHP] user login and access + headers already sent

2010-07-15 Thread Richard Quadling
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

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



Re: [PHP] user login and access + headers already sent

2010-07-15 Thread kranthi
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



[PHP] Determining the similarity between a user supplied short piece of text (between 5 and 15 characters) and a list of similar length text items.

2010-07-15 Thread Richard Quadling
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.

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



Re: [PHP] user login and access + headers already sent

2010-07-15 Thread Ashley Sheridan
On Thu, 2010-07-15 at 15:38 +, 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




RE: [PHP] user login and access + headers already sent

2010-07-15 Thread Carlos Sura

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-general@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/

[PHP] integrating lib (C++) into php

2010-07-15 Thread Tom Sparks
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




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



Re: [PHP] Determining the similarity between a user supplied short piece of text (between 5 and 15 characters) and a list of similar length text items.

2010-07-15 Thread Ashley Sheridan
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




Re: [PHP] Determining the similarity between a user supplied short piece of text (between 5 and 15 characters) and a list of similar length text items.

2010-07-15 Thread Daniel P. Brown
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/

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



Re: [PHP] integrating lib (C++) into php

2010-07-15 Thread Daniel P. Brown
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/

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



Re: [PHP] integrating lib (C++) into php

2010-07-15 Thread shiplu
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)

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



Re: [PHP] user login and access + headers already sent

2010-07-15 Thread Paul M Foster
On Thu, Jul 15, 2010 at 04:56:50PM +0100, Ashley Sheridan wrote:

 On Thu, 2010-07-15 at 15:38 +, 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



RE: [PHP] user login and access + headers already sent

2010-07-15 Thread Carlos Sura


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-general@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 +, 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/

RE: [PHP] set different .htaccess rules

2010-07-15 Thread Tommy Pham
 -Original Message-
 From: Dušan Novaković [mailto:ndu...@gmail.com]
 Sent: Thursday, July 15, 2010 7:46 AM
 To: php-general@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


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



[PHP] Weird behavior of exec()

2010-07-15 Thread Leonardo
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.

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



[PHP] Re: Weird behavior of exec()

2010-07-15 Thread Shawn McKenzie
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

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



[PHP] Re: Weird behavior of exec()

2010-07-15 Thread Leonardo

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.

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



[PHP] Re: Weird behavior of exec()

2010-07-15 Thread Shawn McKenzie
On 07/15/2010 04:40 PM, Leonardo wrote:
 
 Bad habit. I know.

Did it fix it?

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

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



[PHP] Re: Weird behavior of exec()

2010-07-15 Thread Leonardo

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.

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



Re: [PHP] set different .htaccess rules

2010-07-15 Thread kranthi
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)

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