php-general Digest 18 Sep 2008 20:21:33 -0000 Issue 5689
Topics (messages 280429 through 280462):
Re: Email Verification
280429 by: Colin Guthrie
280430 by: Stut
280431 by: Colin Guthrie
280438 by: Andrew Ballard
Re: MySQL Workbench coming for Linux
280432 by: Luke
280433 by: Ross McKay
ODBC Functions & MS SQL Server 2005
280434 by: Dan Joseph
280461 by: Dan Shirah
280462 by: Dan Joseph
Static method variable
280435 by: Christoph Boget
280436 by: Thijs Lensselink
280437 by: Carlos Medina
280440 by: Micah Gersten
280455 by: Jochem Maas
$_SERVER["REMOTE_ADDR"] returning ::1
280439 by: David Rocks
280441 by: Stut
280443 by: Brady Mitchell
280446 by: David Rocks
280447 by: David Rocks
280448 by: Stut
280454 by: David Rocks
Function parameters and arrays
280442 by: Frank Stanovcak
280444 by: Stut
280449 by: Simcha
280450 by: Jim Lucas
280453 by: Frank Stanovcak
Re: SQLExtendedFetch
280445 by: Liz Kim
Re: textarea html generation problem
280451 by: sean greenslade
Re: PHP and MySQL SELECT COUNT (*)
280452 by: Vinny Gullotta
Deconstruct PDF
280456 by: Ashley Sheridan
280457 by: Eric Butera
280458 by: Ashley Sheridan
280459 by: Eric Butera
280460 by: Ashley Sheridan
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Per Jessen wrote:
Lupus Michaelis wrote:
Richard Heyes a écrit :
New domain name extensions can be accounted for easily, eg:
\.(?:[a-z]){2,4}
It excludes .museum tld.
Don't make assumptions about which TLDs that are or are not allowed -
the domain part of an email address could be validated with this:
and .anythingyouwant now that the TLD space has been opened up....
@[a-z0-9][a-z0-9-]*(\.[a-z0-9][a-z0-9-]*)+
A test for total length and valid use of hyphens should be added. See
RFC1034. Then look up the A record.
Or better, the MX record... :)
Col
--
Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/
Day Job:
Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
Mandriva Linux Contributor [http://www.mandriva.com/]
PulseAudio Hacker [http://www.pulseaudio.org/]
Trac Hacker [http://trac.edgewall.org/]
--- End Message ---
--- Begin Message ---
On 18 Sep 2008, at 09:44, Colin Guthrie wrote:
Per Jessen wrote:
Lupus Michaelis wrote:
Richard Heyes a écrit :
New domain name extensions can be accounted for easily, eg:
\.(?:[a-z]){2,4}
It excludes .museum tld.
Don't make assumptions about which TLDs that are or are not allowed -
the domain part of an email address could be validated with this:
and .anythingyouwant now that the TLD space has been opened up....
@[a-z0-9][a-z0-9-]*(\.[a-z0-9][a-z0-9-]*)+
A test for total length and valid use of hyphens should be added.
See
RFC1034. Then look up the A record.
Or better, the MX record... :)
An MX record is not required to accept email for a domain. The
relevant RFC (can't recall the number right now) states that it
should fall back to using the A record if no MX record is present.
-Stut
--
http://stut.net/
--- End Message ---
--- Begin Message ---
Stut wrote:
Or better, the MX record... :)
An MX record is not required to accept email for a domain. The relevant
RFC (can't recall the number right now) states that it should fall back
to using the A record if no MX record is present.
Excellent. That's my "new thing" learned for the day. May as well go home :)
Col
--
Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/
Day Job:
Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
Mandriva Linux Contributor [http://www.mandriva.com/]
PulseAudio Hacker [http://www.pulseaudio.org/]
Trac Hacker [http://trac.edgewall.org/]
--- End Message ---
--- Begin Message ---
On Thu, Sep 18, 2008 at 2:09 AM, Per Jessen <[EMAIL PROTECTED]> wrote:
> Lupus Michaelis wrote:
>
>> Richard Heyes a écrit :
>>
>>> New domain name extensions can be accounted for easily, eg:
>>>
>>> \.(?:[a-z]){2,4}
>>
>> It excludes .museum tld.
>
> Don't make assumptions about which TLDs that are or are not allowed -
> the domain part of an email address could be validated with this:
>
> @[a-z0-9][a-z0-9-]*(\.[a-z0-9][a-z0-9-]*)+
>
> A test for total length and valid use of hyphens should be added. See
> RFC1034. Then look up the A record.
>
>
>
> /Per Jessen, Zürich
>
I don't know that it would add much benefit, but you could
periodically download a TLD list from IANA and compare that last
segment to the list.
Andrew
--- End Message ---
--- Begin Message ---
so it's like Microsoft Access? I don't get it...
2008/9/18 Ross McKay <[EMAIL PROTECTED]>
> Bastien Koert wrote:
>
> >what about dia on llinux? Not quite as nice as visio...but livable
>
> The Enterprise Architect version of Visio lets you add column
> definitions to your entities, add foreign key relationships, add
> indices, add comments at the table and column level, and then generate a
> build script. It also has a reporting tool for generating a data
> dictionary. In short, it makes a pretty good stab at being a data
> modelling tool (imperfectly, but sufficiently for my needs).
>
> Dia is just a diagramming tool (unless you can tell me otherwise).
> --
> Ross McKay, Toronto, NSW Australia
> "Nobody ever rioted for austerity" - George Monbiot
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Luke Slater
--- End Message ---
--- Begin Message ---
Luke wrote:
>so it's like Microsoft Access? I don't get it...
No, Microsoft Access is a development environment sitting on top of a
simplistic database (JET). Access gives you a nice GUI to help you
interactively build up your database, and it makes a great prototyping
tool and data massage tool, but it isn't very good for data modelling.
I'm talking about proper data modelling tools, where you design the
conceptual and physical databases, then generate scripts to build them
(e.g. in Oracle, Microsoft SQL Server, MySQL, etc.) and generate nice
documentation including diagrams that help you understand your database
at a quick glance. Usually, they can also suck a live database back in
(reverse engineer) to help you document whatever nasty hack you've
inherited from your predecessors in a legacy application ;-)
MySQL Workbench is what I really want, or something similar. I just
happen to already have a copy of Visio Enterprise Architect that comes
close enough to doing the job, so I use that until Workbench is up and
working properly on Linux. I hack the generated SQL scripts (minimally)
to make them MySQL friendly, and I hack the generated RTF data
dictionary files to make them more to my liking, and load them into OOo
and embed the ER diagrams, to get nice, easily referenced documentation
on my DBs.
See here for more information about data modelling tools in general, and
a couple of specific ones:
http://en.wikipedia.org/wiki/Entity-relationship_model
http://en.wikipedia.org/wiki/CA_ERwin_Data_Modeler
http://en.wikipedia.org/wiki/ER/Studio
http://en.wikipedia.org/wiki/Toad_Data_Modeler
http://en.wikipedia.org/wiki/MySQL_Workbench
--
Ross McKay, Toronto, NSW Australia
"Before enlightenment: chop wood, carry water;
After enlightenment: chop wood, carry water" - Wu Li
--- End Message ---
--- Begin Message ---
Hi,
Anyone else using the odbc_* functions to interact with MS SQL Server 2005?
I'm having a problem getting odbc_num_rows() to return anything other than
-1 when querying a stored procedure. I can get it to work using Top in a
normal query (non-stored procedure).
SELECT Top 1000000 * FROM Table
if I do an odbc_num_rows( result ) on that, I get the number of rows.
However...
EXEC ProcedureName @Var = 'value'
if I do an odbc_num_rows( result), I get -1. The same is true if I did a
straight SELECT * FROM Table. I've tried putting Top in my query in the
stored procedure.
Right now I'm either doing an extra query for @@ROWCOUNT, or I'm doing two
result sets, a counting query, and then the normal query. I am concerned
about performance in doing the two queries, and with @@ROWCOUNT, I feel I'm
just adding extra things to the code that may be unreliable?
>From what I've read, its something with the ODBC driver, and updating the
ODBC driver isn't an option.
Anyone else having this problem? Any suggestions?
--
-Dan Joseph
www.canishosting.com - Plans start @ $1.99/month.
"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."
--- End Message ---
--- Begin Message ---
On 9/18/08, Dan Joseph <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Anyone else using the odbc_* functions to interact with MS SQL Server 2005?
>
> I'm having a problem getting odbc_num_rows() to return anything other than
> -1 when querying a stored procedure. I can get it to work using Top in a
> normal query (non-stored procedure).
>
> SELECT Top 1000000 * FROM Table
>
> if I do an odbc_num_rows( result ) on that, I get the number of rows.
> However...
>
> EXEC ProcedureName @Var = 'value'
>
> if I do an odbc_num_rows( result), I get -1. The same is true if I did a
> straight SELECT * FROM Table. I've tried putting Top in my query in the
> stored procedure.
>
> Right now I'm either doing an extra query for @@ROWCOUNT, or I'm doing two
> result sets, a counting query, and then the normal query. I am concerned
> about performance in doing the two queries, and with @@ROWCOUNT, I feel I'm
> just adding extra things to the code that may be unreliable?
>
> From what I've read, its something with the ODBC driver, and updating the
> ODBC driver isn't an option.
>
> Anyone else having this problem? Any suggestions?
>
> --
> -Dan Joseph
Dan,
If you already have your results in an array, try using count($result); That
should count the number of results returned to your result array.
Or you could try uncommenting the mssql extension in your php.ini file and
then try using:
mssql_num_rows() ?
Dan
--- End Message ---
--- Begin Message ---
On Thu, Sep 18, 2008 at 3:36 PM, Dan Shirah <[EMAIL PROTECTED]> wrote:
>
> If you already have your results in an array, try using count($result);
> That should count the number of results returned to your result array.
>
> Or you could try uncommenting the mssql extension in your php.ini file and
> then try using:
>
> mssql_num_rows() ?
>
> Dan
>
>
>
>
I don't have them in an array usually, I just cycle thru each row.
I've thought about using the mssql_* functions. My boss originally pushed
me into odbc posing the question "What if we move to a different database
server type?".
I do have a class for handling all the database functions. Maybe I'll just
go that route. If he changed to Oracle or something, I could modify my
class easy enough.
I'm assuming mssql_num_rows() works fine when calling a stored procedure?
--
-Dan Joseph
www.canishosting.com - Plans start @ $1.99/month.
"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."
--- End Message ---
--- Begin Message ---
Perhaps I'm misunderstanding what a static method variable is supposed
to do. I thought the value would be static for an class' instance but
it appears it is static across all instances of the class. Consider:
class StaticTest
{
public function __construct()
{
}
public function test( $newVal )
{
static $retval = '';
if( $retval == '' )
{
$retval = $newVal;
}
echo $retval . '<br>';
}
}
$one = new StaticTest();
$one->test( 'joe' );
$two = new StaticTest();
$two->test( 'bob' );
Should it be working that way?
thnx,
Chris
--- End Message ---
--- Begin Message ---
Quoting Christoph Boget <[EMAIL PROTECTED]>:
Perhaps I'm misunderstanding what a static method variable is supposed
to do. I thought the value would be static for an class' instance but
it appears it is static across all instances of the class. Consider:
class StaticTest
{
public function __construct()
{
}
public function test( $newVal )
{
static $retval = '';
if( $retval == '' )
{
$retval = $newVal;
}
echo $retval . '<br>';
}
}
$one = new StaticTest();
$one->test( 'joe' );
$two = new StaticTest();
$two->test( 'bob' );
Should it be working that way?
thnx,
Chris
That's exactly how a static class var functions. It's available cross
all instances of the class.
--- End Message ---
--- Begin Message ---
Christoph Boget schrieb:
Perhaps I'm misunderstanding what a static method variable is supposed
to do. I thought the value would be static for an class' instance but
it appears it is static across all instances of the class. Consider:
class StaticTest
{
public function __construct()
{
}
public function test( $newVal )
{
static $retval = '';
if( $retval == '' )
{
$retval = $newVal;
}
echo $retval . '<br>';
}
}
$one = new StaticTest();
$one->test( 'joe' );
$two = new StaticTest();
$two->test( 'bob' );
Should it be working that way?
thnx,
Chris
Hi Chris,
please read here. If you have questions after that. Write again please:
http://de3.php.net/manual/en/language.oop5.static.php
Regards
Carlos
--- End Message ---
--- Begin Message ---
If you're looking for a persistent variable in one class instance, then
you need a member variable. If you want it persistent across all class
instances, you want a static variable.
Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com
Christoph Boget wrote:
> Perhaps I'm misunderstanding what a static method variable is supposed
> to do. I thought the value would be static for an class' instance but
> it appears it is static across all instances of the class. Consider:
>
> class StaticTest
> {
> public function __construct()
> {
> }
>
> public function test( $newVal )
> {
> static $retval = '';
>
> if( $retval == '' )
> {
> $retval = $newVal;
> }
> echo $retval . '<br>';
> }
> }
>
> $one = new StaticTest();
> $one->test( 'joe' );
> $two = new StaticTest();
> $two->test( 'bob' );
>
> Should it be working that way?
>
> thnx,
> Chris
>
>
--- End Message ---
--- Begin Message ---
Christoph Boget schreef:
Perhaps I'm misunderstanding what a static method variable is supposed
to do. I thought the value would be static for an class' instance but
it appears it is static across all instances of the class. Consider:
class StaticTest
{
public function __construct()
{
}
public function test( $newVal )
{
static $retval = '';
if( $retval == '' )
{
$retval = $newVal;
}
echo $retval . '<br>';
}
}
$one = new StaticTest();
$one->test( 'joe' );
$two = new StaticTest();
$two->test( 'bob' );
Should it be working that way?
yes. it's a function variable that retains state. everyone misread your
opst so far ... this has nothing to do with static class scope, although
it does work in the same way.
you can do the exact same thing with a normal function:
function test( $newVal )
{
static $retval;
if(!isset($retval))
$retval = $newVal;
echo $retval . "\n";
}
test('joe');
test('bob');
thnx,
Chris
--- End Message ---
--- Begin Message ---
I am running a test PHP web app on my local machine that uses
REMOTE_ADDR and most of the time ::1 is returned as the IP addr and
sometimes it is 127.0.0.1 . I am on OS X 10.5.5 and using APACHE 2.
PHPINFO always returns ::1 for REMOTE_ADDR. Is this a PHP or a APACHE 2
thing?
--- End Message ---
--- Begin Message ---
On 18 Sep 2008, at 05:57, David Rocks wrote:
I am running a test PHP web app on my local machine that uses
REMOTE_ADDR and most of the time ::1 is returned as the IP addr and
sometimes it is 127.0.0.1 . I am on OS X 10.5.5 and using APACHE 2.
PHPINFO always returns ::1 for REMOTE_ADDR. Is this a PHP or a
APACHE 2 thing?
It's coming from Apache and is correct. ::1 is the same as 127.0.0.1
in IPv6. Which you get will depend on how you request the page and
how your DNS/hosts file is set up. Request it with an IPv6 domain/IP
and REMOTE_ADDR will also be IPv6.
You should be able to disable IPv6 in your system settings, but from
a future-proof point of view you should be able to handle both.
-Stut
--
http://stut.net/
--- End Message ---
--- Begin Message ---
On Sep 17, 2008, at 957PM, David Rocks wrote:
I am running a test PHP web app on my local machine that uses
REMOTE_ADDR and most of the time ::1 is returned as the IP addr and
sometimes it is 127.0.0.1 . I am on OS X 10.5.5 and using APACHE 2.
PHPINFO always returns ::1 for REMOTE_ADDR. Is this a PHP or a
APACHE 2 thing?
I saw the same thing on my OS X box, and decided to disable IPV6 for
now. Edit httpd.conf and change: "Listen 80" to "Listen 0.0.0.0:80"
and when you restart Apache it'll always return 127.0.0.1
Brady
--- End Message ---
--- Begin Message ---
Stut wrote:
On 18 Sep 2008, at 05:57, David Rocks wrote:
I am running a test PHP web app on my local machine that uses
REMOTE_ADDR and most of the time ::1 is returned as the IP addr and
sometimes it is 127.0.0.1 . I am on OS X 10.5.5 and using APACHE 2.
PHPINFO always returns ::1 for REMOTE_ADDR. Is this a PHP or a APACHE
2 thing?
It's coming from Apache and is correct. ::1 is the same as 127.0.0.1 in
IPv6. Which you get will depend on how you request the page and how your
DNS/hosts file is set up. Request it with an IPv6 domain/IP and
REMOTE_ADDR will also be IPv6.
You should be able to disable IPv6 in your system settings, but from a
future-proof point of view you should be able to handle both.
-Stut
This app uses this test to insure that the page being processed came
from the same machine as was used to login to the app. The app is
intended for broad use so I can't control the use of IPv6. Is localhost
the only case where the value returned might have different values? Can
you point to a reference where I might figure out a better future proof
test?
--- End Message ---
--- Begin Message ---
Stut wrote:
On 18 Sep 2008, at 05:57, David Rocks wrote:
I am running a test PHP web app on my local machine that uses
REMOTE_ADDR and most of the time ::1 is returned as the IP addr and
sometimes it is 127.0.0.1 . I am on OS X 10.5.5 and using APACHE 2.
PHPINFO always returns ::1 for REMOTE_ADDR. Is this a PHP or a APACHE
2 thing?
It's coming from Apache and is correct. ::1 is the same as 127.0.0.1 in
IPv6. Which you get will depend on how you request the page and how your
DNS/hosts file is set up. Request it with an IPv6 domain/IP and
REMOTE_ADDR will also be IPv6.
You should be able to disable IPv6 in your system settings, but from a
future-proof point of view you should be able to handle both.
-Stut
This app uses this test to insure that the page being processed came
from the same machine as was used to login to the app. The app is
intended for broad use so I can't control the use of IPv6. Is localhost
the only case where the value returned might have different values? Can
you point to a reference where I might figure out a better future proof
test?
--- End Message ---
--- Begin Message ---
On 18 Sep 2008, at 16:37, David Rocks wrote:
Stut wrote:
On 18 Sep 2008, at 05:57, David Rocks wrote:
I am running a test PHP web app on my local machine that uses
REMOTE_ADDR and most of the time ::1 is returned as the IP addr
and sometimes it is 127.0.0.1 . I am on OS X 10.5.5 and using
APACHE 2. PHPINFO always returns ::1 for REMOTE_ADDR. Is this a
PHP or a APACHE 2 thing?
It's coming from Apache and is correct. ::1 is the same as
127.0.0.1 in IPv6. Which you get will depend on how you request
the page and how your DNS/hosts file is set up. Request it with an
IPv6 domain/IP and REMOTE_ADDR will also be IPv6.
You should be able to disable IPv6 in your system settings, but
from a future-proof point of view you should be able to handle both.
-Stut
This app uses this test to insure that the page being processed
came from the same machine as was used to login to the app. The app
is intended for broad use so I can't control the use of IPv6. Is
localhost the only case where the value returned might have
different values? Can you point to a reference where I might figure
out a better future proof test?
Using the IP is not a reliable way to check for this. Some ISPs use
transparent proxies which can cause each subsequent request to come
from a different IP, regardless of whether it's v4 or v6. You'd be
better off using a cookie, although that would be a bit less secure.
If you really need to use IP then you can probably rely on it not
switching between v4 and v6 if you're not using localhost. For
testing use the machine's real IP or hostname instead of localhost
and this problem should disappear.
-Stut
--
http://stut.net/
--- End Message ---
--- Begin Message ---
Stut wrote:
On 18 Sep 2008, at 16:37, David Rocks wrote:
Stut wrote:
On 18 Sep 2008, at 05:57, David Rocks wrote:
I am running a test PHP web app on my local machine that uses
REMOTE_ADDR and most of the time ::1 is returned as the IP addr and
sometimes it is 127.0.0.1 . I am on OS X 10.5.5 and using APACHE 2.
PHPINFO always returns ::1 for REMOTE_ADDR. Is this a PHP or a
APACHE 2 thing?
It's coming from Apache and is correct. ::1 is the same as 127.0.0.1
in IPv6. Which you get will depend on how you request the page and
how your DNS/hosts file is set up. Request it with an IPv6 domain/IP
and REMOTE_ADDR will also be IPv6.
You should be able to disable IPv6 in your system settings, but from
a future-proof point of view you should be able to handle both.
-Stut
This app uses this test to insure that the page being processed
came from the same machine as was used to login to the app. The app
is intended for broad use so I can't control the use of IPv6. Is
localhost the only case where the value returned might have different
values? Can you point to a reference where I might figure out a
better future proof test?
Using the IP is not a reliable way to check for this. Some ISPs use
transparent proxies which can cause each subsequent request to come
from a different IP, regardless of whether it's v4 or v6. You'd be
better off using a cookie, although that would be a bit less secure.
If you really need to use IP then you can probably rely on it not
switching between v4 and v6 if you're not using localhost. For testing
use the machine's real IP or hostname instead of localhost and this
problem should disappear.
-Stut
Thanx, using the real ip addr solved my problem as far as my test
install is concerned. I did do some research and found the text display
conventions for IPv6 ip addresses. But it looks like it would be better
to develop a better test than to make an IPv6 safe one.
--- End Message ---
--- Begin Message ---
I am trying to pass a multi dimmed array as a variable parameter to a custom
function to build a query for me. Here is the basic code and what I am
getting.
$WhereList[0][0] = 'OESalesOrder.OrderNo';
$WhereList[0][1] = '=';
$WhereList[0][2] = '2272';
$SQLString = SQLCall('OESalesOrder',$FieldList,$WhereList);
I then use a foreach in the function to process it.
$i = 0;
foreach(func_get_arg(2) as $WhereArray) {
echo $WhereArray[0][0];
if($i == 0) {
$SQLStmt .= ' ' . $WhereArray[$i][0] . ' ' . $WhereArray[$i][1] . ' ' .
$WhereArray[$i][2];
$i += 1;
} else {
$SQLStmt .= ' ' . $WhereArray[$i][0] . ' ' . $WhereArray[$i][1] . ' ' .
$WhereArray[$i][2] . ' ' . $WhereArray[$i][3];
$i += 1;
};
};
What I get when it processes is the first three letters of [0][0]
[0][0] = O
[0][1] = E
[0][2] = S
Did I do something wrong, or is this not possible? I have done an array
processing this way before, but not multidimmed.
Frank.
--- End Message ---
--- Begin Message ---
On 18 Sep 2008, at 16:29, Frank Stanovcak wrote:
I am trying to pass a multi dimmed array as a variable parameter to
a custom
function to build a query for me. Here is the basic code and what
I am
getting.
$WhereList[0][0] = 'OESalesOrder.OrderNo';
$WhereList[0][1] = '=';
$WhereList[0][2] = '2272';
$SQLString = SQLCall('OESalesOrder',$FieldList,$WhereList);
I then use a foreach in the function to process it.
$i = 0;
foreach(func_get_arg(2) as $WhereArray) {
This foreach will give you each array at the first level into
$WhereArray...
echo $WhereArray[0][0];
So there is no need for the first [0] here.
if($i == 0) {
$SQLStmt .= ' ' . $WhereArray[$i][0] . ' ' . $WhereArray[$i]
[1] . ' ' .
$WhereArray[$i][2];
$i += 1;
} else {
$SQLStmt .= ' ' . $WhereArray[$i][0] . ' ' . $WhereArray[$i]
[1] . ' ' .
$WhereArray[$i][2] . ' ' . $WhereArray[$i][3];
$i += 1;
};
};
And $i is not needed at all.
What I get when it processes is the first three letters of [0][0]
[0][0] = O
[0][1] = E
[0][2] = S
Did I do something wrong, or is this not possible? I have done an
array
processing this way before, but not multidimmed.
Suggest you read this: http://php.net/foreach
-Stut
--
http://stut.net/
--- End Message ---
--- Begin Message ---
This would be a little neater:
foreach(func_get_arg(2) as $k => $WhereArray) {
//echo $WhereArray[0][0];
$SQLStmt .= ' ' . $WhereArray[0] . ' ' . $WhereArray[1] . ' ' .
$WhereArray[2];
if($k != 0) $SQLStmt .=' ' . $WhereArray[3];
};
Simcha Younger
-----Original Message-----
From: Frank Stanovcak [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 18, 2008 5:30 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Function parameters and arrays
I am trying to pass a multi dimmed array as a variable parameter to a custom
function to build a query for me. Here is the basic code and what I am
getting.
$WhereList[0][0] = 'OESalesOrder.OrderNo';
$WhereList[0][1] = '=';
$WhereList[0][2] = '2272';
$SQLString = SQLCall('OESalesOrder',$FieldList,$WhereList);
I then use a foreach in the function to process it.
$i = 0;
foreach(func_get_arg(2) as $WhereArray) {
echo $WhereArray[0][0];
if($i == 0) {
$SQLStmt .= ' ' . $WhereArray[$i][0] . ' ' . $WhereArray[$i][1] . ' ' .
$WhereArray[$i][2];
$i += 1;
} else {
$SQLStmt .= ' ' . $WhereArray[$i][0] . ' ' . $WhereArray[$i][1] . ' ' .
$WhereArray[$i][2] . ' ' . $WhereArray[$i][3];
$i += 1;
};
};
What I get when it processes is the first three letters of [0][0]
[0][0] = O
[0][1] = E
[0][2] = S
Did I do something wrong, or is this not possible? I have done an array
processing this way before, but not multidimmed.
Frank.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.169 / Virus Database: 270.6.21/1675 - Release Date: 17/09/2008
17:07
--- End Message ---
--- Begin Message ---
Frank Stanovcak wrote:
> I am trying to pass a multi dimmed array as a variable parameter to a custom
> function to build a query for me. Here is the basic code and what I am
> getting.
>
> $WhereList[0][0] = 'OESalesOrder.OrderNo';
> $WhereList[0][1] = '=';
> $WhereList[0][2] = '2272';
> $SQLString = SQLCall('OESalesOrder',$FieldList,$WhereList);
>
> I then use a foreach in the function to process it.
>
> $i = 0;
> foreach(func_get_arg(2) as $WhereArray) {
> echo $WhereArray[0][0];
> if($i == 0) {
> $SQLStmt .= ' ' . $WhereArray[$i][0] . ' ' . $WhereArray[$i][1] . ' ' .
> $WhereArray[$i][2];
> $i += 1;
> } else {
> $SQLStmt .= ' ' . $WhereArray[$i][0] . ' ' . $WhereArray[$i][1] . ' ' .
> $WhereArray[$i][2] . ' ' . $WhereArray[$i][3];
> $i += 1;
> };
> };
>
> What I get when it processes is the first three letters of [0][0]
> [0][0] = O
> [0][1] = E
> [0][2] = S
>
> Did I do something wrong, or is this not possible? I have done an array
> processing this way before, but not multidimmed.
>
> Frank.
>
>
>
Something like this should do.
function SQLCall($table, $FieldList, $WhereList=array()) {
# work with your field list...
$where_parts = array();
foreach($WhereList AS $cond) {
$where_parts[] = $cond[0].' '.$cond[1].' '.$cond[2];
}
$WHERE = '';
if ( count($where_parts) ) {
$WHERE = 'WHERE ' . join(' AND ', $where_parts);
}
# put it all together.
}
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--- End Message ---
--- Begin Message ---
Actually Stut pointed out that I was calling both dimmensions when my sorry
butt should only have been referencing the second one.
I had everything over expanded so I could see where the code was breaking.
Thank you everyone for the help! That was fantastic!
Frank
""Frank Stanovcak"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>I am trying to pass a multi dimmed array as a variable parameter to a
>custom function to build a query for me. Here is the basic code and what I
>am getting.
>
> $WhereList[0][0] = 'OESalesOrder.OrderNo';
> $WhereList[0][1] = '=';
> $WhereList[0][2] = '2272';
> $SQLString = SQLCall('OESalesOrder',$FieldList,$WhereList);
>
> I then use a foreach in the function to process it.
>
> $i = 0;
> foreach(func_get_arg(2) as $WhereArray) {
> echo $WhereArray[0][0];
> if($i == 0) {
> $SQLStmt .= ' ' . $WhereArray[$i][0] . ' ' . $WhereArray[$i][1] . ' ' .
> $WhereArray[$i][2];
> $i += 1;
> } else {
> $SQLStmt .= ' ' . $WhereArray[$i][0] . ' ' . $WhereArray[$i][1] . ' ' .
> $WhereArray[$i][2] . ' ' . $WhereArray[$i][3];
> $i += 1;
> };
> };
>
> What I get when it processes is the first three letters of [0][0]
> [0][0] = O
> [0][1] = E
> [0][2] = S
>
> Did I do something wrong, or is this not possible? I have done an array
> processing this way before, but not multidimmed.
>
> Frank.
>
--- End Message ---
--- Begin Message ---
thanks for all your input.
unfortunately, i cannot set up a new database as it is being used by other
applications/websites.
the versions of odbc, php and apache are all the same...
please do let me know if you have any other suggestions!
thanks
On Wed, Sep 17, 2008 at 5:48 PM, Chris <[EMAIL PROTECTED]> wrote:
>
> If you have Apache on IIS, why not go MySQL. It's a fair bit faster I've
>> found, and a darn site easier to work with;
>>
>
> because changing a web server is a lot easier than rewriting an app to use
> another database ;)
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>
--- End Message ---
--- Begin Message ---
I prefer the htmlentities because it allows me to edit the real code, not an
edited form of the code. All the <> still appear.
On Tue, Sep 16, 2008 at 9:41 AM, TQ White II <[EMAIL PROTECTED]> wrote:
>
> I add str_replace('textarea', 'textareaHIDE', ... to the display code and
> the reverse to the store it away code.
>
> Good luck.
>
> tqii
>
> On Sep 15, 2008, at 8:08 PM, sean greenslade wrote:
>
> Hi all! I am trying to make a PHP HTML editor. I have made the entire
> editor
> function, but it has a big problem. If the page contains a </textarea> tag,
> it ends the editor's textarea and the browser starts rendering the HTML.
> How
> do I go about preventing this from happening?
>
> Thanks a lot!
> --Zootboy
>
>
>
>
> TQ White II • 708-763-0100
> Website • JustKidding.com <http://justkidding.com/>
>
>
>
--
Feh.
--- End Message ---
--- Begin Message ---
Thanks all, I appreciate the follow ups and the help with the code. I'm
still relatively new with this stuff, and never had any formal training,
it's all just been learn as I go, and I have to learn fast as this project
is relatively urgent to get completed. I plan on going through all of my
code on all of these pages and cleaning it up at the end to make it more
efficient, so I will use these tips to help do that.
Thanks again to all who helped troubleshoot this. It is working great now
and I think my bosses will be happy. =D
"Nathan Rixham" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
learn something new every day! cheers Micah :)
Micah Gersten wrote:
While it's true that '.' concatenates and ',' is a list separator, The
comma is actually more appropriate in this instance since you are just
outputting each piece. It saves the overhead of concatenation before
output.
Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com
Nathan Rixham wrote:
6: " vs '
when you use " php will parse the enclosed string for variables, when
you use ' it won't; so ' leads for faster code, and also encourages
you to code strongly by closing strings and concatenating variables.
Further it allows you to use valid html " around attributes rather
than the invalid '
7: , vs .
there is no vs :) to concatenate we use . (period) not , (comma)
so for 6 & 7..
echo '<td>' . $i['servername'] . '</td>';
I'm going to stop there, hope it helps a little bit; and I won't go
any further as half the fun is learning; so you finding out how to
save time on queries and write your own db handlers etc is not my
domain I reckons
Regards
nathan
--- End Message ---
--- Begin Message ---
Hi All,
I'm not sure if this is possible, but basically I was wondering if
anyone had any experience with using PHP to read/deconstruct a PDF file.
I'm asking because a system I built at work is being used by a complete
computer illiterate. Even after careful step-by-step instruction, she
still keeps trying to upload a PDF in a form carefully marked as a CSV
upload, and she wonders why it doesn't work. She knows how to press the
PDF button on Word to create the PDF, and that's about it. I was just
wondering if there was a way I could extract the information I wanted
from the PDF (it's a fairly simple affair, just text and no images.) If
not, perhaps there's a way to extract what I need from a Word document?
Thanks,
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On Thu, Sep 18, 2008 at 3:15 PM, Ashley Sheridan
<[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I'm not sure if this is possible, but basically I was wondering if
> anyone had any experience with using PHP to read/deconstruct a PDF file.
>
> I'm asking because a system I built at work is being used by a complete
> computer illiterate. Even after careful step-by-step instruction, she
> still keeps trying to upload a PDF in a form carefully marked as a CSV
> upload, and she wonders why it doesn't work. She knows how to press the
> PDF button on Word to create the PDF, and that's about it. I was just
> wondering if there was a way I could extract the information I wanted
> from the PDF (it's a fairly simple affair, just text and no images.) If
> not, perhaps there's a way to extract what I need from a Word document?
>
> Thanks,
>
>
> Ash
> www.ashleysheridan.co.uk
>
I heard one of the goals of Zend_PDF was to be able to read them and
index them with the Zend_Search_Lucene. As for if that works or
not, I don't know.. but maybe it might be a starting point for you.
--- End Message ---
--- Begin Message ---
On Thu, 2008-09-18 at 15:20 -0400, Eric Butera wrote:
> On Thu, Sep 18, 2008 at 3:15 PM, Ashley Sheridan
> <[EMAIL PROTECTED]> wrote:
> > Hi All,
> >
> > I'm not sure if this is possible, but basically I was wondering if
> > anyone had any experience with using PHP to read/deconstruct a PDF file.
> >
> > I'm asking because a system I built at work is being used by a complete
> > computer illiterate. Even after careful step-by-step instruction, she
> > still keeps trying to upload a PDF in a form carefully marked as a CSV
> > upload, and she wonders why it doesn't work. She knows how to press the
> > PDF button on Word to create the PDF, and that's about it. I was just
> > wondering if there was a way I could extract the information I wanted
> > from the PDF (it's a fairly simple affair, just text and no images.) If
> > not, perhaps there's a way to extract what I need from a Word document?
> >
> > Thanks,
> >
> >
> > Ash
> > www.ashleysheridan.co.uk
> >
>
> I heard one of the goals of Zend_PDF was to be able to read them and
> index them with the Zend_Search_Lucene. As for if that works or
> not, I don't know.. but maybe it might be a starting point for you.
>
Thanks, I think that'll do what I need it to (albeit depending on M$ not
making a hash of the PDF it produces!) This is going to sound like a bit
of a dumb question, but would I need to recompile PHP to make use of
this? The server itself is IIS, if that makes a difference also.
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On Thu, Sep 18, 2008 at 3:28 PM, Ashley Sheridan
<[EMAIL PROTECTED]> wrote:
> On Thu, 2008-09-18 at 15:20 -0400, Eric Butera wrote:
>> On Thu, Sep 18, 2008 at 3:15 PM, Ashley Sheridan
>> <[EMAIL PROTECTED]> wrote:
>> > Hi All,
>> >
>> > I'm not sure if this is possible, but basically I was wondering if
>> > anyone had any experience with using PHP to read/deconstruct a PDF file.
>> >
>> > I'm asking because a system I built at work is being used by a complete
>> > computer illiterate. Even after careful step-by-step instruction, she
>> > still keeps trying to upload a PDF in a form carefully marked as a CSV
>> > upload, and she wonders why it doesn't work. She knows how to press the
>> > PDF button on Word to create the PDF, and that's about it. I was just
>> > wondering if there was a way I could extract the information I wanted
>> > from the PDF (it's a fairly simple affair, just text and no images.) If
>> > not, perhaps there's a way to extract what I need from a Word document?
>> >
>> > Thanks,
>> >
>> >
>> > Ash
>> > www.ashleysheridan.co.uk
>> >
>>
>> I heard one of the goals of Zend_PDF was to be able to read them and
>> index them with the Zend_Search_Lucene. As for if that works or
>> not, I don't know.. but maybe it might be a starting point for you.
>>
> Thanks, I think that'll do what I need it to (albeit depending on M$ not
> making a hash of the PDF it produces!) This is going to sound like a bit
> of a dumb question, but would I need to recompile PHP to make use of
> this? The server itself is IIS, if that makes a difference also.
>
>
> Ash
> www.ashleysheridan.co.uk
>
>
Nope, ZF is just a bunch of php classes that you require into your
script. Since I'm on unix I just symlink it into the include path,
but you can also just copy it right in so you don't have to duplicate
it a hundred times. :)
--- End Message ---
--- Begin Message ---
On Thu, 2008-09-18 at 15:30 -0400, Eric Butera wrote:
> On Thu, Sep 18, 2008 at 3:28 PM, Ashley Sheridan
> <[EMAIL PROTECTED]> wrote:
> > On Thu, 2008-09-18 at 15:20 -0400, Eric Butera wrote:
> >> On Thu, Sep 18, 2008 at 3:15 PM, Ashley Sheridan
> >> <[EMAIL PROTECTED]> wrote:
> >> > Hi All,
> >> >
> >> > I'm not sure if this is possible, but basically I was wondering if
> >> > anyone had any experience with using PHP to read/deconstruct a PDF file.
> >> >
> >> > I'm asking because a system I built at work is being used by a complete
> >> > computer illiterate. Even after careful step-by-step instruction, she
> >> > still keeps trying to upload a PDF in a form carefully marked as a CSV
> >> > upload, and she wonders why it doesn't work. She knows how to press the
> >> > PDF button on Word to create the PDF, and that's about it. I was just
> >> > wondering if there was a way I could extract the information I wanted
> >> > from the PDF (it's a fairly simple affair, just text and no images.) If
> >> > not, perhaps there's a way to extract what I need from a Word document?
> >> >
> >> > Thanks,
> >> >
> >> >
> >> > Ash
> >> > www.ashleysheridan.co.uk
> >> >
> >>
> >> I heard one of the goals of Zend_PDF was to be able to read them and
> >> index them with the Zend_Search_Lucene. As for if that works or
> >> not, I don't know.. but maybe it might be a starting point for you.
> >>
> > Thanks, I think that'll do what I need it to (albeit depending on M$ not
> > making a hash of the PDF it produces!) This is going to sound like a bit
> > of a dumb question, but would I need to recompile PHP to make use of
> > this? The server itself is IIS, if that makes a difference also.
> >
> >
> > Ash
> > www.ashleysheridan.co.uk
> >
> >
>
> Nope, ZF is just a bunch of php classes that you require into your
> script. Since I'm on unix I just symlink it into the include path,
> but you can also just copy it right in so you don't have to duplicate
> it a hundred times. :)
>
Thanks! I'll try and get working with that later tonight!
Ash
www.ashleysheridan.co.uk
--- End Message ---