Re: [PHP] redefine a define ...

2012-08-25 Thread Matt Neimeyer
Can you just switch the order?

Instead of...

   define(SOME_CONSTANT,Generic Value);
   define(SOME_CONSTANT,Override Value);

Why not do...

   define(SOME_CONSTANT,Override Value);
   if(!defined(SOME_CONSTANT)) { define(SOME_CONSTANT,Generic Value); }

This should avoid any redefinition and thus the notices.

Matt

On Sat, Aug 25, 2012 at 3:07 PM, Matijn Woudt tijn...@gmail.com wrote:
 Op 25 aug. 2012 21:03 schreef Adam Richardson simples...@gmail.com het
 volgende:

 On Sat, Aug 25, 2012 at 2:27 PM, Lester Caine les...@lsces.co.uk wrote:
  What I was not expecting was a string of 'Notices:' complaining about
 the
  redefines. So how does one get around this message? One can't 'if
 defined'
  as the string needs to be replaced with the more appropriate one. I
 would
  say, why is this even a problem, or alternatively I just give up on
 E_STRICT
  and make sure it's disabled again on PHP5.4?
 
  Having spent several months getting the code clean on E_STRICT,
 switching it
  off again will really pig me off, but I can't see any real alternative
 given
  the number of languages and strings that will need reworking simply to
 get
  things clean :(

 Well, I'd do the following to avoid issues in the future.

 1) Create a function like that below, which provides global access to
 variables and allows you to update existing values:

 function val($name, $value = null)
 {
 static $values = array();

 if ($value === null) {
 return isset($values[$name]) ? $values[$name] :
 null;
 } else {
 return $values[$name];
 }
  }

 2) Create a php script that searches out define(SOME_NAME_PATTERN,
 value) and replaces that with val(some_name_pattern, value).

 3) Create a php script that searches out SOME_NAME_PATTERN and
 replaces with val(SOME_NAME_PATTERN);

 Not too bad in terms of work, as PHP's parsing capabilities are really
 nice.

 Hope this gives you ideas :)

 Adam


 That's probably quite some work given the many defines.. Fact is, constants
 are, as the name says, constant. Would it be possible to just not include
 the general file?
 Second, though not 100% sure if it works for E_STRICT is using @ before all
 defines to silence the warning. You could do a simple replace for that..

 - Matijn

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



Re: [PHP] Re: http_referer. what's wrong with that?

2012-01-11 Thread Matt Neimeyer
While perhaps unlikely in common users it is also possible to
prevent your browser from sending the referrer. IIRC, the referrer can
also get mangled when passing through HTTPS (although I don't remember
on which side, HTTP-HTTPS or HTTPS-HTTP or both)

Matt

On Thu, Jan 12, 2012 at 1:11 AM, Ross McKay ro...@zeta.org.au wrote:
 On Wed, 11 Jan 2012 21:27:58 -0800, Haluk Karamete wrote:

[...]
Notice: Undefined index: HTTP_REFERER in
D:\Hosting\5291100\html\blueprint\bp_library.php on line 16
die;
[...]
But I'm still curious, what configuration am I missing so that
http_referer is treated like that?

 You only get an HTTP_REFERER when you link to a page from another page.
 If you go directly to the page, e.g. by typing / pasting the URL into
 the location bar, or linking from an email, then there is no
 HTTP_REFERER.
 --
 Ross McKay, Toronto, NSW Australia
 Let the laddie play wi the knife - he'll learn
 - The Wee Book of Calvin

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


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



Re: [PHP] DOS CLI?

2011-12-08 Thread Matt Neimeyer
On Thu, Dec 8, 2011 at 7:16 AM, Richard Quadling rquadl...@gmail.com wrote:
 On 2 December 2011 21:00, Matt Neimeyer m...@neimeyer.org wrote:
 Is there (or is there a way to compile) a DOS CLI version of a fairly
 recent version of PHP? I have not been able to find one using the
 powers of Google.

 You are pretty much stuck with no network services, limited memory and
 restricted extensions.

 Can you describe your project and to why it MUST run on such an ancient OS?

We have a utility disk that we use for a variety of things where I
work and some of them are DOS based. We use the purely DOS ones rarely
enough these days that people have trouble remembering how to use
them. I wanted to see if it would be possible to write a menu type
front end that would detect what OS it is running under and present
the tools and options that are suitable for that OS.

My thought was to use PHP because it is cross platform (to some
degree) and then in theory the disk could be run under anything that
can run PHP and anything that would run under the current OS can then
be presented to the end user. If there is a better solution than PHP
I'm open to it, but I already know PHP so I figured that would make it
easier.

Basically I need to be able to present a menu to the end user so they
can select the tool they want to run. We currently have tool disks for
DOS, Windows and OSX. If I could combine them into one big disk/usb
key I would be a hero around these parts.

Matt

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



[PHP] DOS CLI?

2011-12-02 Thread Matt Neimeyer
Is there (or is there a way to compile) a DOS CLI version of a fairly
recent version of PHP? I have not been able to find one using the
powers of Google.

Not a Windows Command Prompt CLI but an actual CLI version of PHP that
can be made to run in a real DOS environment?

I'm sure I could find another scripting language for DOS but to
prototype this project I'd like to not have to learn a new language as
well. :)

Thanks in advance for ANY suggestions.

Matt

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



[PHP] Downgrading HTML

2010-09-16 Thread Matt Neimeyer
I know I could possibly hack something together using the Tidy
libraries... (maybe...) but are there any existing php libraries /
projects that already have the ability to take some HTML and
downgrade the version of HTML being used.

One example: turn this...

   p style=font-weight: boldBlah/p

... into ...

   pbBlah/b/p

This is for an eReader I love but is long out of production and the
converter tool only works with HTML 3.2

Thanks in advance.

Matt

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



Re: [PHP] Fun with Streams

2010-02-24 Thread Matt Neimeyer
Basically... I built the stream encapsulation to do two things for me:

1. Keep track of the row I was on.
2. Keep track of the columns by name. So if I wrote columns Foo, Bar,
Baz one time and Foo, Baz the next it would automatically keep the Baz
in column three the second time.

In other words, it makes it simple to just dump row after row of data
into it for exports and simple reports.

Matt

On Mon, Feb 22, 2010 at 4:14 AM, Rene Veerman rene7...@gmail.com wrote:
 just curious, why did you choose to use it from behind a stream wrapper?

 On Sun, Feb 21, 2010 at 11:03 PM, Matt Neimeyer m...@neimeyer.org wrote:
 I created a stream wrapper around the php_writeexcel library found at
 http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/

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



[PHP] Fun with Streams

2010-02-21 Thread Matt Neimeyer
I created a stream wrapper around the php_writeexcel library found at
http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/

My code can be seen at http://www.pastebin.com/m7212eaa2

I'm trying to add an option that will allow us to lower or uppercase
the column headers we create by calling ftell on the Excel stream but
when I do something like...

   $xls = fopen(xlsfile://../data/measurables.xls,wb); echo ftell($xls);

...I get 0 returned even though I've hard coded a return of 123 in my
stream_tell function (which I did to see if my stream_tell was even
being called).

Can anyone tell me what I'm doing wrong or suggest another way to
communicate into the stream wrapper that will be compatible with PHP
4 and 5 on OSX, Linux and Windows?

Thanks

Matt

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



Re: [PHP] Magnetic Stripe Reader or Barcode to PHP

2010-02-18 Thread Matt Neimeyer
If the scanning device hooks into the keyboard somehow it should be
easy. I believe that's called a keyboard wedge. Basically, you scan
and it types.

My only exposure to this is using one of the old CueCat scanners to
index my personal library into a php app I cobbled together. The
CueCat hooked in line with the keyboard. You'd bring up the scanning
page and an onload Javascript would place the cursor into the Scan
ISBN Here text box. Scan the book and the input went where it was
needed. I believe it also sent an enter keystroke which submitted
the form. It's been a couple years since I played with it so there
might have been some additional software that kicked the enter. Then
you process the data as you would for any other text field submission.
It worked well enough to catalog a couple thousand books in a single
evening.

Hope this helps

Matt

On Thu, Feb 18, 2010 at 5:42 PM, Daevid Vincent dae...@daevid.com wrote:
 So we're opening a new super-club here in Seattle. One of the ideas we'd
 like to pursue is that people are assigned a card. This can be a magstripe
 card or something with a barcode. Not really sure at the moment which way
 to go.

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



[PHP] I'm not crazy I swear it... IE vs Safari and Firefox - The impossible!

2009-08-31 Thread Matt Neimeyer
Probably a year or so ago I asked on this list before and basically
the response was that this should be impossible that it shouldn't
happen... So I'm asking again hoping someone new to the list can
suggest something that might lead to a fix or that someone else has
run across the problem in the intervening time frame.

One of our products allows you to mail merge using an uploaded data
file and have the results emailed to the recipients. IE works fine,
always has. Firefox at some point started having the data disappear
halfway through the merge and now the most recent version of Safari
ALSO has the data disappear halfway through the merge. This means that
users of Macs don't really have any options where before at least we
could point them to Firefox. (Not our favorite option but at least it
worked)

Here's the process:

1. Menu of what type of merge you want to do. (Initialize working table)
2. Process Data File (Initialize working table and then load in new data)
3. Build Email
4. Send out Email

And by disappear I mean that when the end user gets to step 3 and hits
preview with data to see what their final email will look like our
program basically responds No data in your merge table OR the user
hits the Merge button and again it says No records to merge... I've
checked both using the app and by watching the underlying MySQL
tables...

I added a line to the Initialize function to email me every time it's
called (for debugging users) and I get 2 emails for IE users and 4
emails for Firefox. I USED to only get 2 emails from Safari uses but
with the latest version I get 4 now.

I've always been told it shouldn't matter what browser is being
used... but I have no other explanation of why it DOES matter... I've
tried disabling prefetching in Firefox (thinking MAYBE the browser was
prefetching the bailout link back to step 1 from step 3). The
initialize in step 1 fixed another problem we were having but I did
try disabling it temporarily to no avail.

Does anyone have any ideas on what could possibly be causing this?

Thanks!

Matt Neimeyer

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



Re: [PHP] I'm not crazy I swear it... IE vs Safari and Firefox - The impossible!

2009-08-31 Thread Matt Neimeyer
 No answers - just more questions to maybe point you in a direction you
 haven't been

Anything is appreciated...

 Is it possible that the query/script is taking too long to build the
 response page and FireFox/Safari is asking for an empty query result?

I don't think so... the tracer emails I get from the initialize
function are usually a couple seconds apart. It's almost like the
browser is trying to make two simultanious requests which is why I
was thinking maybe prefetching...

 You mention MySQL but is there any JavaScript involved in the
 data/result set.  I am not a JS expert, but there could be differences
 in IE/FF/Saf JavaScript that could cause this.

The only javascript is from the upload screen a popup window is
created that says wait patiently please and then on the next screen
a javascript that closes that popup window. (The email editor is
javascript heavy but the data is already gone by the time you get to
that point. And the only reason the popup exists is because the email
editor requires popups and we have impatient users...)

 When you duplicate this with your data and get the error response, does
 the script show a records in the response query, even though it reports
 no records?

No. By the time the editor screen loads the data really IS gone. If I
sit in a mysql session and keep refreshing the table I see data...
data... data... data... no data... I only mentioned the error
responses as a way (not phrased the best) to indicate that it didn't
see any correlation to this branch of code or that branch of code
(for example if I could narrow it down to it disappears when I
preview then I would know to look at the preview pages)

 Sorry but no definitive answers...

Thanks though... the reason I keep pounding my head on the desk is
that we deliberatly try to keep all the processing on the server side
to avoid cross-browser and cross-platform issues. So sure... maybe a
style sheet breaks... maybe a minor javascript doesn't work quite
right... maybe the font sizes change and things are out of
alignment... but the heavy lifting happens behind the scenes where
they don't need to worry about it. Not very Web 2.0 but it's been
steady (with this exception) so far.

Thanks!

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



Re: [PHP] I'm not crazy I swear it... IE vs Safari and Firefox - The impossible!

2009-08-31 Thread Matt Neimeyer
 If it were prefetching, or another request clobbering your current request
 then you would see a second hit in your server logs.

I will admit... I have made (at least) one assumption... Since...

1. This is a difference between IE and Firefox/Safari...
2. I was seeing a tracer email for each hit to the Initialize function...

I have been assuming that it is the browser that has been the cause.
I'm 90% certain that last year we DID check and we DID see multiple
web hits... That said I will make an explicit check and see if there
are multiple hits in the web server logs now for the Safari as well.

Matt

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



Re: [PHP] I'm not crazy I swear it... IE vs Safari and Firefox - The impossible!

2009-08-31 Thread Matt Neimeyer
 In circumstances like this, I would instrument the code with
 echo/print statements all around where you think the problem is.

We did that with no luck. We only saw one call to the initialize
function which is why I switched to tracer emails because we knew
the initialize function was the only possible explanation but
couldn't prove it based on any output to the browser.

 As with other responders, I have to say that if you're doing the
 processing on the server, it doesn't make any sense.

 Um... one other wild possibility I almost hate to mention. I don't
 recall if you mentioned whether your server was running Windows or not.

I did not mention... Sorry... according to phpinfo() it's PHP 5.2.5 on
Apache/2.0.52 on CentOS under Plesk 8.2.0. SELECT version() on MySQL
reports 4.1.20-log. The MySQL API version in phpinfo() is 4.1.20. If
it matters from what I can tell the entire toolchain is 64-bit (for
example the php configure command reports
--build=x86_64-redhat-linux-gnu)

 But I wouldn't put it past Microsoft to barf under certain circumstances
 if the user agent (browser) isn't IE.

Neither would I... but unless I have to for some other reason I prefer
PHP 5+, MySQL 5+, Apache 2+ and a *nix of some flavor for my web
serving needs.

Matt

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



Re: [PHP] Script to Compare Database Structures

2009-08-05 Thread Matt Neimeyer
I finally got a chance to play with this and it looks like it is
exactly what I need.

Thanks!

On Fri, Jul 31, 2009 at 11:50 PM, German Geekgeek...@gmail.com wrote:
 have you tried mysqldiff?
 I want to be able to compare the structure of two different clients
 databases that might be on different servers that are firewalled away
 from each other. Given the two structures it will list all the SQL
 commands needed to make the database structure the same.

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



[PHP] Re: This isn't infinitely recursive is it?

2009-07-31 Thread Matt Neimeyer
I like it... Thanks!

On Thu, Jul 30, 2009 at 8:04 PM, Ben Dunlapbdun...@agentintellect.com wrote:
 I don't THINK I need to worry about circular mappings... but I'm not
 sure how to check for it if I did...
 Would the following work? It avoids recursion entirely and also checks for
 circular mappings. You can plug in your own code where the comments are to do
 whatever is appropriate when a circular mapping is detected.

 function GetMappedField($Field)
 {
    $OriginalField = $Field;

    while (isset($FieldMap[$Field])) {
        $Field = $FieldMap[$Field];

        if ($Field === $OriginalField) {
            /*
             * circular mapping has been detected;
             * report an error or explode or whatever
             */
             break;
        }
    }

    return $Field;
 }


 Ben


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



[PHP] Script to Compare Database Structures

2009-07-31 Thread Matt Neimeyer
I know I CAN hack something together but I hate to reinvent the wheel.

I want to be able to compare the structure of two different clients
databases that might be on different servers that are firewalled away
from each other. Given the two structures it will list all the SQL
commands needed to make the database structure the same.

In a perfect world on one side you would pull up a PHP page that does
a generate structure which would create a downloadable file which
you could then upload to the other system which would then give a
listing of the SQL commands needed to make the local structure match
the uploaded structure.

Thanks in advance...

Matt

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



[PHP] This isn't infinitely recursive is it?

2009-07-30 Thread Matt Neimeyer
I'm cleaning up some inherited code in our data import module. For a
variety of reasons we have to support old standards of the import
format. Since some of those old versions were created we have since
renamed some fields in our data structure. So right now I've a hard
map for some field names...

function GetMappedField($Field)
   {
   $FieldMap[A] = B;
   $FieldMap[C] = D;

   return isset($FieldMap[$Field])?$FieldMap[$Field]:$Field);
   }

But I've just spent a while tracking down a bug where someone mapped A
to B and then someone else mapped B to C.

I'm thinking of changing the return to...

   return isset($FieldMap[$Field])?GetMappedField($FieldMap[$Field]):$Field);

...but I'm worried about the recursion. (Which isn't a strength of mine)

I don't THINK I need to worry about circular mappings... but I'm not
sure how to check for it if I did...

Any suggestions? Thanks!

Matt

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



Re: [PHP] Re: Broken IF behavior? (Changing the branch changes the evaluation)

2009-07-29 Thread Matt Neimeyer
 $Ret = mysql_fetch_array($result); if(!$Ret) { } else { return $Ret; }
 I'm assuming that you are calling my_fetch_array() in a loop of some
 sort and so at some point there are no more records in the result.

Oh... Um... Yeah... Well... headdesk

So... Checking the docs... Returns an array of strings that
corresponds to the fetched row, or FALSE if there are no more rows.

Is there a way to differentiate between a FALSE for no more rows and an error?

Matt

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



[PHP] Broken IF behavior? (Changing the branch changes the evaluation)

2009-07-28 Thread Matt Neimeyer
Background: I'm converting a webapp from Visual FoxPro as a backend to
MySQL... However one part of our app (a system status checker) is
common code between the versions.

I've got the following function... In English (in case it's not
apparent), if the version of the app is 2.0 or higher, then use MySQL
functions, otherwise use the ODBTP function to connect to VFP.

function my_fetch_array($result)
{
global $Version;
if(version_compare($Version,2.0,=))
{ $Ret = mysql_fetch_array($result); if(!$Ret) { } else { 
return $Ret; } }
else{ $Ret = odbtp_fetch_array($result); if(!$Ret) { } else { 
return $Ret; } }
}

This feels like a hack but works perfectly. Data is returned and all
is right with the world. Until I added in extra error reporting.
When I change the if(!$Ret) portion as such...

if(!$Ret) { die(myError.mysql_error()); } else { return $Ret; }

It ALWAYS dies... and I see myError on the screen... If I change it
like such...

if(!$Ret) { } else { echo notError; return $Ret; }

I always see the notError on the screen and $Ret gets returned.

WHY does adding the die() inside the { } change the way the if is evaluated?

By the way I've tested this on 4.4.x on OSX and Windows, and on 5.2.5
on Windows...

Thanks

Matt

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



Re: [PHP] Broken IF behavior? (Changing the branch changes the evaluation)

2009-07-28 Thread Matt Neimeyer
It's exactly what I would expect... The content of the row... But in
any case, what does changing the content of the { } branch have to do
with how the IF() itself is evaluated?

array(4) {
  [0]=
  string(8) CustName
  [config]=
  string(8) CustName
  [1]=
  string(11) Sample Cust
  [value]=
  string(11) Sample Cust
}


On Tue, Jul 28, 2009 at 2:56 PM, Eddie Drapkinoorza...@gmail.com wrote:
 On Tue, Jul 28, 2009 at 2:48 PM, Matt Neimeyerm...@neimeyer.org wrote:
 Background: I'm converting a webapp from Visual FoxPro as a backend to
 MySQL... However one part of our app (a system status checker) is
 common code between the versions.

 I've got the following function... In English (in case it's not
 apparent), if the version of the app is 2.0 or higher, then use MySQL
 functions, otherwise use the ODBTP function to connect to VFP.

 function my_fetch_array($result)
        {
        global $Version;
        if(version_compare($Version,2.0,=))
                { $Ret = mysql_fetch_array($result); if(!$Ret) { } else { 
 return $Ret; } }
        else    { $Ret = odbtp_fetch_array($result); if(!$Ret) { } else { 
 return $Ret; } }
        }

 This feels like a hack but works perfectly. Data is returned and all
 is right with the world. Until I added in extra error reporting.
 When I change the if(!$Ret) portion as such...

        if(!$Ret) { die(myError.mysql_error()); } else { return $Ret; }

 It ALWAYS dies... and I see myError on the screen... If I change it
 like such...

        if(!$Ret) { } else { echo notError; return $Ret; }

 I always see the notError on the screen and $Ret gets returned.

 WHY does adding the die() inside the { } change the way the if is evaluated?

 By the way I've tested this on 4.4.x on OSX and Windows, and on 5.2.5
 on Windows...

 Thanks

 Matt

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



 What's the output of var_dump($Ret) right before that if statement?


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



Re: [PHP] Converting SQL Dialects

2009-07-23 Thread Matt Neimeyer
 You might even be able to convert EMPTY(X) to COALESCE(X, '') = ''.
 MySQL seems to be pretty forgiving with its implicit type-casting.

Hmm... The new system I've written properly handles the datatype and
EMPTY... So this would be a hack to much around with regexs to replace
EMPTY in customer built selects.

Now I fiddled around with this on 5.1.33-community on Windows and I
get the following odd results...

select coalesce(0,)=0,coalesce(,)=0,coalesce(0,)=0,coalesce(,)=0;
returns 1, 1, 1, 1

but...

 select 
coalesce(0,)=,coalesce(,)=,coalesce(0,)=,coalesce(,)=;
returns 0, 1, 0, 1

Which implies that in certain circumstances  = 0 but 0 !=  (unless
I'm missing something).

Either way it looks like I can use coalesce(X,)=0 which should be useful!

Matt

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



[PHP] Converting SQL Dialects

2009-07-21 Thread Matt Neimeyer
Has anyone come across / written a script that will convert one
flavor or Dialect of SQL to another?

I need to convert Visual FoxPro 6.0 style WHERE clauses to MySQL.

For the most part the problems are converting VFP functions to the
equivalent SQL. For example, Visual FoxPro has a function inlist()
that is used like inlist(X,1,2,3) which converts to the MySQL query X
IN (1,2,3). That's easy enough (relatively speaking) but VFP also has
stuff like EMPTY(X) where any of Null, the Empty String (for Char),
-00-00 (or the VFP equivalent anyways for dates), False (for
Boolean), 0 (for Numeric) are considered empty without needing to
know the data type. So that starts getting a lot more complex since I'd
need to check the data type of the field in the right table... to be
able to convert it to something like (X is null OR X=) or (X is null
OR x=0) etc...

These are for customer stored queries... I've already manually
converted system queries and I'm frustrated to the point of giving
up and adding a column untested and let the end user figure it out
but that seems bad from the standpoint of lazy and poor customer
experience.

Thanks!

Matt

P.S. I'm also going to post this to the MySQL general list but my fear
is that they MIGHT say We only know MySQL so we can't help you with
that other DBMS I'm hoping that by posting here someone might say
well it's not to MySQL but I ran script XYZ to convert my VFP to
PostgreSQL... or similar.

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



Re: [PHP] PHP and FoxPro

2009-07-21 Thread Matt Neimeyer
What I did to handle memos... and it's a HACK... was to create a
function DoMemo that took as arguments the table, the primary key
field of the table, the value of said pk, the field to update, and the
string.

Take the first 200 characters of the string.
Replace all newlines in that substring with +CHR(13)+ (Or CHR(13)+CHR(10)?)
Then do something like: UPDATE table SET field=First200 WHERE pk=pkvalue

Then take the next 200 characters of the string.
Replace all newlines as above
Do something like: UPDATE table SET field=ALLTRIM(field)+Next200 WHERE
pk=pkvalue

Repeat until you've consumed the entire string. This works because
you never put in more that 250 odd characters at a time. It can still
fail though if you have enough newlines to push your 200 characters up
over the 250 odd character limit.

It DOES work if you use RECNO() as the pk field and the appropriate
recno() that you would get if you did something like SELECT recno() AS
myrecno,* FROM sometable (I use the myrecno because otherwise you get
some weird exp_1 field name)

It just popped into my head... I wonder if something like this would work...

UPDATE sometable SET a=1,a=a+1,a=a+1,a=a+1 WHERE x=y

You might be able to limit the total number of calls to the database
that way... If I wasn't in the process of migrating to MySQL I might
give it a whirl... :)

Hope this helps whatever you decide to do.

On Tue, Jul 21, 2009 at 8:27 AM, Floyd Reslerfres...@adex-intl.com wrote:
 Matt,
        Thanks for the information.  I'll look into using ODBTP.  I noticed
 you mentioned the problem with memos.  I currently have that problem with
 the set up we're using and it is a pain!

 Thanks!
 Floyd

 On Jul 20, 2009, at 3:22 PM, Matt Neimeyer wrote:

 We currently use the Easysoft ODBC Bridge to connect to a remote FoxPro
 database.  The problem is that the bridge, after a while, starts
 consuming a
 ton of system resources and we have to reboot the machine.  Afterwards,
 it
 can take upwards to two hours before everything is running quickly again.
 We need another solution.  Does anyone know of a any other way to connect
 to a remote FoxPro database (or any ODBC source that isn't a database
 server)?

 We've had a LOT a luck using ODBTP. Which can be found at
 http://odbtp.sourceforge.net

 Here's the rough outline...

 1. Install Visual FoxPro odbc driver (or whatever drivers you want) on
 a Windows machine.
 2. Install the ODBTP Server on the windows machine
 3. Install a PHP module in your php. (Common ones included in the
 download)
 4. Once you connect the functions are ALMOST exactly the same in usage
 as the mysql_xyz functions.

 A couple gotchas:

 1. If you need to compile the PHP ODBTP module from source on x64 (OS
 X Leopard at least) it can be a pain.
 2. The VFP 6.0 ODBC driver (not sure about higher versions) does not
 allow more than 250 odd characters to be inserted at a single time so
 memo's can be a PAIN.
 3. It does require a port be opened on the Windows machine's
 firewall... (Uses TCP/IP for communication)
 4. By default the ODBTP server can use up to 32 threads. The VFP ODBC
 driver is by nature single threaded. We've never had a problem with
 that directly but I assume it is what causes threads to slowly hang
 and disappear... eventually a message comes up Unable to create
 thread. At that point you simply need to restart the ODBTP service in
 the Windows Services Control Panel. The bigger the tables and the more
 heavily used it is the more often this will happen.

 Other than that... Works like a charm. Looking forward, once you bite
 the bullet and convert to MySQL (at least for us) you can almost
 change odbtp_ to mysql_ and be up and running. (Assuming you limit
 yourself to pure SQL and not invoke VFP functions.)

 Matt




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



Re: [PHP] Converting SQL Dialects

2009-07-21 Thread Matt Neimeyer
Um... It depends? :) These are customer entered queries and vary based
on the end user and the customizations they have. It could be as
simple as WHERE inlist(SalesPerson,Bob,Bill,Fred) OR it could be
something 12 lines long that pulls in criteria from multiple tables
each of those with their own criteria.

And by easy I meant simply that I would feel comfortable hacking
together something to handle inlist(x,1,2,3) and change it to X in
(1,2,3) it's the rest that worries me.

Having slept on it, I'm probably going to write something that
converts IN, checks for a list of forbidden words and then flags the
resulting updated query if it contains any of those words. This way I
can catch some of the low hanging fruit.

My hope is that if X% of queries don't contain foxpro specific
functions, and IN auto-conversions covers another X% of upgrades, and
auto-convert FunctionX (whatever it is...) gives us another X% of
upgrades... that this will result in a hopefully small number of saved
queries that are flagged for manual upgrading. (And not be so painful
in development that it still nets us saved time)

Matt

On Tue, Jul 21, 2009 at 1:54 PM, Ashley
Sheridana...@ashleysheridan.co.uk wrote:
 On Tue, 2009-07-21 at 13:46 -0400, Matt Neimeyer wrote:
 Has anyone come across / written a script that will convert one
 flavor or Dialect of SQL to another?

 I need to convert Visual FoxPro 6.0 style WHERE clauses to MySQL.

 For the most part the problems are converting VFP functions to the
 equivalent SQL. For example, Visual FoxPro has a function inlist()
 that is used like inlist(X,1,2,3) which converts to the MySQL query X
 IN (1,2,3). That's easy enough (relatively speaking) but VFP also has
 stuff like EMPTY(X) where any of Null, the Empty String (for Char),
 -00-00 (or the VFP equivalent anyways for dates), False (for
 Boolean), 0 (for Numeric) are considered empty without needing to
 know the data type. So that starts getting a lot more complex since I'd
 need to check the data type of the field in the right table... to be
 able to convert it to something like (X is null OR X=) or (X is null
 OR x=0) etc...

 These are for customer stored queries... I've already manually
 converted system queries and I'm frustrated to the point of giving
 up and adding a column untested and let the end user figure it out
 but that seems bad from the standpoint of lazy and poor customer
 experience.

 Thanks!

 Matt

 P.S. I'm also going to post this to the MySQL general list but my fear
 is that they MIGHT say We only know MySQL so we can't help you with
 that other DBMS I'm hoping that by posting here someone might say
 well it's not to MySQL but I ran script XYZ to convert my VFP to
 PostgreSQL... or similar.


 I'm not sure it's as easy as you think it might be. As you get more into
 the various flavours of SQL, you notice their little idiosyncrasies that
 only exist within that one particular language branch. As such, it's
 often a task best left to people to try and convert from one to the
 other, rather than leave it to a machine. How complex are the queries
 that you are trying to convert anyway?

 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] PHP and FoxPro

2009-07-20 Thread Matt Neimeyer
 We currently use the Easysoft ODBC Bridge to connect to a remote FoxPro
 database.  The problem is that the bridge, after a while, starts consuming a
 ton of system resources and we have to reboot the machine.  Afterwards, it
 can take upwards to two hours before everything is running quickly again.
  We need another solution.  Does anyone know of a any other way to connect
 to a remote FoxPro database (or any ODBC source that isn't a database
 server)?

We've had a LOT a luck using ODBTP. Which can be found at
http://odbtp.sourceforge.net

Here's the rough outline...

1. Install Visual FoxPro odbc driver (or whatever drivers you want) on
a Windows machine.
2. Install the ODBTP Server on the windows machine
3. Install a PHP module in your php. (Common ones included in the download)
4. Once you connect the functions are ALMOST exactly the same in usage
as the mysql_xyz functions.

A couple gotchas:

1. If you need to compile the PHP ODBTP module from source on x64 (OS
X Leopard at least) it can be a pain.
2. The VFP 6.0 ODBC driver (not sure about higher versions) does not
allow more than 250 odd characters to be inserted at a single time so
memo's can be a PAIN.
3. It does require a port be opened on the Windows machine's
firewall... (Uses TCP/IP for communication)
4. By default the ODBTP server can use up to 32 threads. The VFP ODBC
driver is by nature single threaded. We've never had a problem with
that directly but I assume it is what causes threads to slowly hang
and disappear... eventually a message comes up Unable to create
thread. At that point you simply need to restart the ODBTP service in
the Windows Services Control Panel. The bigger the tables and the more
heavily used it is the more often this will happen.

Other than that... Works like a charm. Looking forward, once you bite
the bullet and convert to MySQL (at least for us) you can almost
change odbtp_ to mysql_ and be up and running. (Assuming you limit
yourself to pure SQL and not invoke VFP functions.)

Matt

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



[PHP] Launch Windows Program from PHP

2009-07-13 Thread Matt Neimeyer
I'm probably just not Googling right... Short version: How can I
launch a program for the current user sitting in front of a windows
web server?

Longer version: I've written a PHP app to migrate data from the FoxPro
version of our product to the upcoming MySQL version. I have a self
contained setup on an XP box consisting of XAMPP, DBConvert (a data
conversion program) and the ODBTP client/server. Phase 1 is a PHP app
the pre-preps the data through ODBTP to a local FoxPro DBC. Phase 2 is
the DBConvert and Phase 3 is a PHP app again doing post-conversion
stuff in MySQL.

To help in automating the whole shebang I'd like to automatically
launch DBConvert with a command line argument (for the right data
conversion stored session). Whenever I Google I find stuff about
launching background tasks or using things like popen to launch
processes inside the web server. I don't care if the owner of the
process is the user at the keyboard just that they can interact with
it.

And if its Christmas and I can get everything I want :)... I'd love
for PHP to be able to watch the process and stay resident until it
exits so at that point I can send a final bit of javascript that will
cause phase 3 to automatically start.

Any ideas?

Thanks!

Matt

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



[PHP] Split up Date Range

2009-07-01 Thread Matt Neimeyer
I haven't been able to find anything by googling... Does anyone know
of any libraries that will split up date ranges? We've got a project
where Date Of Attendance is moving from a single type in character
field to an automatically built field based on a DateBegin date field
and a DateEnd date field. Some examples of what I'd like ideally...

Given: July 19-22, 2009
Return: 7/19/2009 and 7/22/2009

Given: July 19th and 20th
Return: 7/19/2009 and 7/20/2009 (we can safely assume current year for
this project)

Given: Sept 19, 2009 - Sept 22, 2009
Return: 9/19/2009 and 9/22/2009

Given: July 19th, 2009
Return: 7/19/2009 and 7/19/2009

Given: 7/19/2009
Return: 7/19/2009 and 7/19/2009

I could probably hack something together that would work most of the
time... but why reinvent the wheel if some poor shlub has already done
it.

If such a thing doesn't exist... then I'm considering an algorithm
like such... (and advice... yays and nays are appreciated)

Replace the names (and variations thereof) of the months with their
numeric equivilants followed by a comma. So the above would become...

7, 19-22, 2009
7, 19th and 20th
9, 19, 2009 - 9, 22, 2009
7, 19th, 2009
7/19/2009

Then replace all the th and nd and st with nothing... replace all the
ands with a dash... and eliminate spaces... and change / to ,
Giving...

7,19-22,2009
7,19-20
9,19,2009-9,22,2009
7,19,2009
7,19,2009

Then explode on commas. If you have two elements populate the third
with the current year. (This fixes 7,19-20 to 7,19-20,2009). Not a
given example, but it would also fix 7/19 to 7,19,2009.

When you have three elements then you have a valid date. Loop over
each element and populate begin and end, if you find a dash in the
current element then split on the dash and populate as needed. Yes
this would allow 7-8,19-20,2009 to create 7/19/2009 and 8/20/2009 but
I think its as safe as any assumption that regular people wouldn't
enter that as a date range.

If you have more than three elements then split on the dash and as
long as you have have only two elements then consider each item by
itself.

If it's not handled by the above rules then don't split it up.

Thanks in advance.

Matt

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



[PHP] PHP module portability on OSX 10.4

2009-06-23 Thread Matt Neimeyer
I know this is a bit OS specific but it's for PHP so I'm hoping
someone here has run into it before and can answer.

I've compiled php_gd.so for use on an XServe running OSX 10.4. It
works fine there. When I copy it to another XServe it fails because of
missing dependencies (don't remember the exact error but that was the
jist of it).

I used otool -L php_gd.so and got the following...

php_gd.so:
/usr/local/lib/libpng12.0.dylib (compatibility version 33.0.0,
current version 33.0.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current
version 1.2.3)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0,
current version 88.1.11)

libz.1.dylib and libSystem.B.dylib exist on a raw machine so I
assume it's just the libpng.

So... Can I just ALSO copy the libpng file, drop it in the right place
and have it work? It seems like it should work... but at the same
time, something in my head is telling me it shouldn't work...

Barring that does anyone have steps written down that I can follow
to compile php_gd.so with libpng compiled in somehow so it is only one
file?

Thanks in advance!

Matt

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



Re: [PHP] Re: Same Page, Fundamentally Different Behavior OR is Firefox broken?

2009-06-13 Thread Matt Neimeyer
I'd have to check...

But am I to understand that no-cache works with pre-caching? I always
assumed it basically meant when you get this page, don't keep it for
next time?

Thanks!

On Fri, Jun 12, 2009 at 2:04 AM, Manuel C.hippopotam...@gmail.com wrote:
 Matt Neimeyer a écrit :

 I'm at a complete loss... So I'm hoping someone can point me in the
 right direction to even start looking.

 We have an application written in PHP that lets users send out emails.
 The basic process is as follows.

 1. Go to start screen. (This resets anything currently in process
 for the current logged in user)
 2. Upload email addresses and other info (Names, etc)
 3. Build Email
 4. Send

 In Step 3 the user can click a Live Preview button to see what the
 email will look like with the merged data.

 Here's the problem,  this works fine in all versions of IE, versions
 1.5 or less of FireFox and versions 3 or less of Safari. However,
 starting in FireFox 2, and now Safari 4, when you get to step four OR
 click the live preview button in step three there is no more data in
 the merge. In those browsers the system is acting like the end user
 went BACK to the start page (in another window?) and reinitialized all
 the data.

 I immediately thought it might be pre-fetching so I tried using the
 system before and after toggling the network.prefetch-next setting in
 about:config with FireFox 2.0.0.20 and restarting the browser. No
 luck. So I added code to my reset function to email me the output of
 phpinfo() when the reset function is called. Using IE I get 1
 notification. Using FF I get two notifications. This reinforces my
 theory that FireFox is prefetching the menu item to start a new
 mailing (just an a link...) from the top of the composer page. Even
 still... I've disabled prefetch so it SHOULDN'T even be considering
 those links right? I've also tried adding artificial
 ?now=timestamp fakes to the end of all menu links since I read
 somewhere (don't remember where) that FireFox only prefetches pages
 with no query section in the address.

 Has anyone run into this behavior before? Any recommendations on how
 to stop it? Preferably from the server with code of some sort...

 Thanks in advance.

 Matt



 Hi Matt,

 Have you tried to put this two lines in the HEAD section of your HTML pages
 :
        META http-equiv=Cache-Control content=no-cache
        META http-equiv=Pragma content=no-cache

 Hope it helps you.

 BR


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



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



[PHP] Same Page, Fundamentally Different Behavior OR is Firefox broken?

2009-06-11 Thread Matt Neimeyer
I'm at a complete loss... So I'm hoping someone can point me in the
right direction to even start looking.

We have an application written in PHP that lets users send out emails.
The basic process is as follows.

1. Go to start screen. (This resets anything currently in process
for the current logged in user)
2. Upload email addresses and other info (Names, etc)
3. Build Email
4. Send

In Step 3 the user can click a Live Preview button to see what the
email will look like with the merged data.

Here's the problem,  this works fine in all versions of IE, versions
1.5 or less of FireFox and versions 3 or less of Safari. However,
starting in FireFox 2, and now Safari 4, when you get to step four OR
click the live preview button in step three there is no more data in
the merge. In those browsers the system is acting like the end user
went BACK to the start page (in another window?) and reinitialized all
the data.

I immediately thought it might be pre-fetching so I tried using the
system before and after toggling the network.prefetch-next setting in
about:config with FireFox 2.0.0.20 and restarting the browser. No
luck. So I added code to my reset function to email me the output of
phpinfo() when the reset function is called. Using IE I get 1
notification. Using FF I get two notifications. This reinforces my
theory that FireFox is prefetching the menu item to start a new
mailing (just an a link...) from the top of the composer page. Even
still... I've disabled prefetch so it SHOULDN'T even be considering
those links right? I've also tried adding artificial
?now=timestamp fakes to the end of all menu links since I read
somewhere (don't remember where) that FireFox only prefetches pages
with no query section in the address.

Has anyone run into this behavior before? Any recommendations on how
to stop it? Preferably from the server with code of some sort...

Thanks in advance.

Matt

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



[PHP] Boolean Parameter to 3 Options?

2009-04-29 Thread Matt Neimeyer
I have a function that currently takes a boolean value as a parameter.
But now I want to expand it to 3 options...  So if I have...

function doFooBar($doFoo = false)
   {
   if($doFoo)
  { echo Did Foo; }
   else
  { echo Did Bar; }
   }

Is it as simple as changing it like follows to avoid having to
change existing code that won't use the new values.

function doFooBar($doFoo = 0)
   {
   if($doFoo == 2)
  { echo Did Baz; }
   else if($doFoo == 1)
  { echo Did Foo; }
   else
  { echo Did Bar; }
   }

Something about that disturbs me. Perhaps because any time I think Oh
it will be as simple as... it usually isn't.

Thanks in advance!

Matt

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



Re: [PHP] Boolean Parameter to 3 Options?

2009-04-29 Thread Matt Neimeyer
On Wed, Apr 29, 2009 at 1:30 PM, Shawn McKenzie nos...@mckenzies.net wrote:
 Philip Thompson wrote:
 On Apr 29, 2009, at 11:42 AM, Matt Neimeyer wrote:

 I have a function that currently takes a boolean value as a parameter.
 But now I want to expand it to 3 options...  So if I have...

 function doFooBar($doFoo = false)
   {
   if($doFoo)
  { echo Did Foo; }
   else
  { echo Did Bar; }
   }

 Is it as simple as changing it like follows to avoid having to
 change existing code that won't use the new values.

 function doFooBar($doFoo = 0)
   {
   if($doFoo == 2)
  { echo Did Baz; }
   else if($doFoo == 1)
  { echo Did Foo; }
   else
  { echo Did Bar; }
   }

 Something about that disturbs me. Perhaps because any time I think Oh
 it will be as simple as... it usually isn't.

 Thanks in advance!

 Matt

 Unless you're doing a strict comparison (===), it probably won't make a
 lot of difference. However, if you sent true to the function, I
 believe it will reach the last else condition. You may revisit all the
 locations you call it and update them appropriately.

 Those are my initial thoughts

 ~Philip


 No, true will match the first condition.  If you're using true and false
 now and just want to add a second option then continue using true/false.
  Don't mix and match.  1 == true and 2 == true.

 function doFooBar($doFoo = false)
 {
   if($doFoo === 2) {
//something
   }
   elseif($doFoo === true) {
//something true
   }
   elseif($doFoo === false) {
//something false
   }
 }


Ah. I somehow missed the direction of the typecasting. Not that the
documentation isn't completely explicit on the matter but for some
reason I was thinking that the bool got cast to 1 or 0... not that the
string/number got cast to a bool (following the standards there).

Good to know.

Thanks

Matt

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



Re: [PHP] Connecting to dBase using ODBC on Mac OS X

2009-04-12 Thread Matt Neimeyer
I know this isn't exactly what you were probably looking for but...

If you have a Windows machine available I would recommend taking a
look at the ODBTP project at http://odbtp.sourceforge.net. ODBTP
stands for Open DataBase Transport Protocol. The short version is that
you add a client module to PHP which allows you to connect to a server
on the windows machine. Using this client/server you can connect to
any ODBC source on the windows machine from the Mac.

I know it's not perfect (since you need Windows running) but we've
used it to add Web acessibility to a legacy VFP app with some success.

Caveat: These are, all things considered, relatively small
installations. By small I mean 5-100 users per intranet accessing
100-20,000 customer records. I could not imagine using this solution
for any major, publicly accessible web site. (We have one client that
tracks 300,000+ records and performance is NOTICABLY slow)

Pro: Allows you to access any odbc compliant database from any web
server that you can compile the client for.

Con: Requires Windows (works reasonably well with a Parallels
installation though...) Only as stable as the underlying ODBC driver
(the VFP driver is single threaded and locks up after a while... but
restarting the ODBTP service frees it all up.)

Overall: Good for transitioning from a Legacy application or for
infrequent tasks like importing from windows only file formats (like
VFP).

We've used this in several installations where the client doesn't want
to lose their legacy app, refuses to upgrade and wants to provide
web access to sales people on the road. We've seen the best
performance using PHP under IIS on Windows connecting to the same
machine. Our worst case for performance is an installation that uses a
Mac OSX 10.4 XServe Web Server connecting to a Windows 2003 Server
which then accesses VFP data files on a Novell Server of some flavor.
(From that client I learned that apparently Windows ALWAYS tries the
Microsoft network file redirectors before it will try any available
Novell network file redirectors. At least that's what the Client's IT
department tells me whenever we relay user complaints about the speed
at that site)

Hope this helps.

Matt

On Thu, Apr 9, 2009 at 10:53 AM, Rahul S. Johari
sleepwal...@rahulsjohari.com wrote:
 Ave,

 Does anyone have any knowledge on connecting a FoxPro table (.dbf, dbase)
 using ODBC on a Mac OS X? I've been googling but not much is turning up.
 Some information is available on ODBC Connections using PHP ... very little
 on Mac OS X ... and absolutely none to do with a FoxPro dBase table.

 Thanks.

 ---
 Rahul Sitaram Johari
 Founder, Internet Architects Group, Inc.

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



Re: [PHP] Problems with implode

2009-03-24 Thread Matt Neimeyer
On Tue, Mar 24, 2009 at 9:15 AM, Per Jessen p...@computer.org wrote:
 TG wrote:

 I don't think that would be a problem, the size of the array.  I've
 used implode at least once or twice on fairly large arrays.  More
 likely is something weird with your data.

 Yeah, like the odd backspace or carriage return perhaps.

I can't tell you how many times I've had data that contained  and got
all kinds of screwed up when data disapeared when really the browser
was just turning it into an HTML tag.

Matt

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



[PHP] Reading from a COM port in Windows blows up

2009-03-14 Thread Matt Neimeyer
I just recently got a new Onkyo TX-SR706 Audio Receiver that has an
RS232 interface and I thought... cool... Build a Web Interface so I
can control it from several rooms away.

The code below works using PHP 5.2.8 under Apache (XAMPP) on Windows
XP to change the current input of my Audio Receiver. So I know at
least one way communication works.

If I swap out !1SLI01 (SeLect Input 01) for !1SLIQSTN which should
query the current input and uncomment the lines that are commented out
below COM1 Replied. That PHP session and the COM Port itself  lock
up until I reboot the machine.

Being able to query the device would be nice... but isn't strictly
necessary... So I just want to make sure I'm not doing something crazy
/ wrong.

--

$Set_Mode = MODE COM1: BAUD=9600 PARITY=N DATA=8 STOP=1 DTR=OFF RTS=OFF;
exec($Set_Mode, $Output, $Result);

echo pre.implode(\n,$Output)./pre;
echo brbr;

switch($Result)
{
case 0: echo COM1 Configuredbr; $BadConfig = false; 
break;
default:echo COM1 not configuredbr; $BadConfig = true;  
break;
}

if(!$BadConfig)
{
$ComPort = fopen(COM1, wb+);

if(!$ComPort)
{ echo COM1 not openedbr; }
else
{
echo COM1 Openedbr;
$Command = !1SLI01\n;
$result = fwrite($ComPort,$Command);
if(!$result)
{ echo COM1 Errorbr; }
else
{
echo COM1 Replied:br;
//  $Buffer = fgets($ComPort,1024);
//  while(trim($Buffer) != )
//  {
//  echo $Buffer.br;
//  $Buffer = fgets($ComPort,1024);
//  }
}
if(fclose($ComPort)) { echo COM1 Closedbr; }
}
}

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



[PHP] Sanitizing Numbers

2009-03-13 Thread Matt Neimeyer
I'm trying to sanitize some numeric data that's coming to us from
another system which I have no control over where all fields are
character fields with no formatting from the end user so data is a
mishmash of clean and mixed types of dirty.

I know I can use intval and floatval to sanitize if the numeric data
is at the front of the string but what about when it's not?

For example, Jersey Number = #45 or Dues = $1,234.56

I see in the comments at php.net for floatval a lot of very complex
solutions... am I missing something about the following that wouldn't
cover me?

?php $output = floatval(ereg_replace([^-0-9\.],,$input)); ?

I'm willing to assuming only US formatted numbers... and knowing that
if they put in 45/46 for jersey it would come out 4546 (but I might
put in additional code for that specific case on that specific
field...). I'm also looking for something that I can generically apply
to any numeric field.

Thanks for your collective guidance.

Matt

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



Re: [PHP] Recursion... Sort of...

2008-05-09 Thread Matt Neimeyer
Wow! Thanks guys! Here's what I ended up doing... To get...

Black on White - 1
  White on Black - 2
 Black on White - 3
 Black on White - 3
  White on Black - 2
 Black on White - 3

I had to do something like...


function doStuff()
  {
  static $callCount = 0;
  $callCount++;

  if($callCount%2)
 { echo 'white on black - '.$callCount; }
  else
 { echo 'black on white - '.$callCount; }

  // Stuff that uses the depth count

  $callCount--;
  }

If I didn't put in the $callCount--; I ended up with something like this...

Black on White - 1
  White on Black - 2
 Black on White - 3
 White on Black - 4
  Black on White - 5
 White on Black - 6

I saw where it was said that oh he said it wasn't recursive... Sorry
I wasn't clearer. In my mind a true recursive function is a function
that operates on it's own output like a factorial... Not just a
function that is called inside itself.

This got me where I needed to be and it is GREATLY appreciated!

Matt

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



[PHP] Recursion... Sort of...

2008-05-08 Thread Matt Neimeyer
Is there a way to tell if a function has been called that has resulted
in a call to the same function?

We have an in-house CRM app that has a function that draws a tabbed
panel on a screen... BUT if there are sub-sub-tabbed panels we want to
invert the tab colors and panel colors...

So...

DrawSubTab($Set) - Black on White
   Content
   DrawSubTab($Set) - White on Black
  Content
  DrawSubTab($Set) - Black on White
 Content
  DrawSubTab($Set) - Black on White
 Content
 Etc...

I suppose I could rewrite EVERY call to the function with a recursion
count like DrawSubTab($Set,$DepthCount+1) but that would be a MASSIVE
commit... whereas if the function can determine itself... All that
said I can't think of a good way to do it without a bastardized global
variable that track how deep we are and there is something that
bothers me about that approach... Unless that really is the easiest
way.

Thanks in advance!

Matt

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



RE: [PHP] Problems with dbase_create function

2002-09-29 Thread Matt Neimeyer

I considered that...

Problem is I'm not 100% certain how to set that the correct way... (so as 
not to screw anything else up)

Recommendations?

Thanks

PS It's good to know I wasn't completely off base... thanks millions!

Does the web server have permission to write to the directory where you
are trying to create the database? PHP runs as the web server when
installed as a module and it needs permission to write in that
directory.

---John Holmes...

  -Original Message-
  From: Matt Neimeyer [mailto:[EMAIL PROTECTED]]
  Sent: Sunday, September 29, 2002 2:19 AM
  To: [EMAIL PROTECTED]
  Subject: [PHP] Problems with dbase_create function
 
  Hey All,
 
  I'm trying to build a DBF for exporting selected data as a download to
the
  end users... But I can't get further than this...
 
error_reporting(E_ALL);
$DBFName = Test.dbf;
$Fields = array( array (Test,C,32) );
if(dbase_create($DBFName, $Fields))
{ echo Good!; } else { echo Bad!; }
 
  It doesn't show an error... and it doesn't create the dbf... it just
shows
  Bad! and nothing else.
 
  Any ideas where I should begin looking? I admit I'm not the most savvy
  Linux user but I at least got it to admit that the function existed
(under
  a freshly compiled php with --enable-dbase on Redhat Linux 7.2)
 
  I've also tried $DBFName=./Test.dbf and
  /full_path_from_root_to_html_folder/Test.dbf and neither work. I've
also
  looked through the archives for this list and for the php-db list and
  haven't seen anything that helps (other than my earlier problem of not
  having enabled dbase, which appears to be fixed, before it wouldn't
even
  show Bad!. )
 
  Thanks in advance for any ideas...
 
  Matt
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php




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


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




[PHP] Problems with dbase_create function

2002-09-28 Thread Matt Neimeyer

Hey All,

I'm trying to build a DBF for exporting selected data as a download to the 
end users... But I can't get further than this...

error_reporting(E_ALL);
$DBFName = Test.dbf;
$Fields = array( array (Test,C,32) );
if(dbase_create($DBFName, $Fields))
{ echo Good!; } else { echo Bad!; }

It doesn't show an error... and it doesn't create the dbf... it just shows 
Bad! and nothing else.

Any ideas where I should begin looking? I admit I'm not the most savvy 
Linux user but I at least got it to admit that the function existed (under 
a freshly compiled php with --enable-dbase on Redhat Linux 7.2)

I've also tried $DBFName=./Test.dbf and 
/full_path_from_root_to_html_folder/Test.dbf and neither work. I've also 
looked through the archives for this list and for the php-db list and 
haven't seen anything that helps (other than my earlier problem of not 
having enabled dbase, which appears to be fixed, before it wouldn't even 
show Bad!. )

Thanks in advance for any ideas...

Matt


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