RE: [PHP] .INC files

2005-06-02 Thread Denis Gerasimov

OK... Let me explain a couple things...


 On Wed, June 1, 2005 1:29 am, Denis Gerasimov said:
  Second, which way are you differ PHP .inc files from HTML .inc files?
 
 There is no such thing as an HTML .inc file. :-)

I see what you mean... but I use templating systems to separate code from
design, so I have to differ PHP .inc files from HTML .inc files ;-)

 
 All your HTML .inc files, by definition, if they are being require'd or
 include'd into PHP *are* PHP .inc files.
 
 It is merely a coincidence of your design that they happen to have no
 ?php ? tags in them.
 
 You *MAY* want to separate those into another other non-web tree
 directory.

Of course, I do. My WWW root contains just a couple of files (like
application.php, robots.txt, favicon.ico etc.). All other included files are
stored outside document root.

 
  Third, I always write context-independent include files.
 
 Example?...

Example something.inc.php:

?php

define('DIR_SOMEDIR', DIR_ROOT . '/somedir/');

function someFunc($num) {
return $num / 2;
}

class MyClass {
var $_someVar;
}

?

Get me? :-)

 
 You *NEED* to have the policy/procedure in place to get those .inc and
 .inc.php and non-entry .php files *OUT* of the web-tree, or you will get
 bit, sooner or later.
 
 For 5 minutes of time, you can avoid dozens of potential pitfalls. [shrug]
 

Agree completely. So what I meant is .inc.php is *not* a security measure,
but just a way to make my life more comfortable.

But seems that that is a question of taste in some way. ;-)

Best regards,
Denis Gerasimov,
Chief Developer, VEKOS Ltd.
www.vekos.ru

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



[PHP] str_replace weird output

2005-06-02 Thread Johan . Barbier
Hello guys :-)

I have a question. I have been using str_replace() quite a lot of times, 
and never encountered any issue. But this time, something weird happened, 
and I am wondering wether, in fact, I have never really understood how 
this function worked, or if there is some kind of bug.

If I do that :

?php
$test = 'bla';
$un = array ('b', 'l', 'a');
$deux = array ('c', 'd', 'e');
$test = str_replace ($un, $deux, $test);
echo $test , 'br /';
?

No prob, the output is the one I would have expected : cde

But if I do that :

?php
$texte = 'cd' ;
$original = array('a', 'b', 'c', 'd', 'e', 'f', 'g');
$modif = array ('c', 'd', 'e', 'f', 'g', 'h', 'i');
$texte = str_replace($original, $modif, $texte) ;
echo $texte, ' br /' ;
?

The result is : ih

Why ? 
It seems to me that str_replace is messing up a litlle bit if there are 
identical values in both replacement and search arrays.
Or am I missing something ?

Thanks a lot :-)

Johan

Re: [PHP] .INC files

2005-06-02 Thread Rory Browne
 
 I do not agree.
Not agreeing with Rasmus on a PHP list, can be seriously damaging to
your credability, unless you really know what you're talking about and
have a solid argument.

Having that said, I personally use .inc.php  - .inc as Rasmus said, to
denote include files, and .php because I couldn't be bothered
configuring my editor, to syntax highlight .inc files.

There are security arguments to be made for both approaches:
 - .php (generally)means that any code is parsed as PHP - which
generally means that it can't be read as source code.
 - .inc (generally) means that it won't execute if it is called on its
own, so even if it does contain code that shouldn't be run in
isolation it won't be run.

 - how about .inc.php.cgi? (: /me Ducks to avoid flamebashing.)

Having that said, I'm about to make the same mistake, by
disagreeing(sort of) with someone else on this list, who is generally
right:

  (By the way, it's faster to specify an absolute path to your includes
  than to rely on include_path. You can save PHP the hassle of searching.)
I see what you're saying, but the human time, you lose in keeping
track where the include files are, and modding the code, any time it
is moved would counteract his.

Having that said, I suppose you could define an INCLUDES_DIR constant,
and then include(INCLUDES_DIR . /include.ext).

Alternatively if the include_path, contained the path that your
includes were in, (and only the directory where you put your
includes), then php wouldn't have very far to search.

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



Re: [PHP] .INC files

2005-06-02 Thread Rasmus Lerdorf
Rory Browne wrote:

 Alternatively if the include_path, contained the path that your
 includes were in, (and only the directory where you put your
 includes), then php wouldn't have very far to search.

Well, no real difference between that and just making sure most of your
includes are in the first path in the include_path list.  It's still an
extra stat() syscall to do an include_path check.  And by the way, a
simple:

  include 'foo.inc';

is an include_path include which has the extra syscall overhead.  By
default . is in the include_path.  A quick way to track these down is
to simple remove . from your include_path and by looking at the errors
go through and change all those to:

  include './foo.inc';

-Rasmus

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



Re: [PHP] PHP 5 Question about OO

2005-06-02 Thread Marcus Bointon

On 2 Jun 2005, at 03:00, Richard Lynch wrote:


Maybe I'm being dumb, but how can an object's __autoload function get
called when the object class definition hasn't been loaded, and  
that's why

you're calling __autoload in the first place...


It wouldn't solve everything, but it would help. It solves the case  
where you have a class library that's quite heavily interconnected,  
and member functions instantiate other classes in that library (a  
common arrangement in my experience). By having an __autoload method,  
you get to at least partly avoid global handler clashes by having one  
that is specific to that library (it would work well in PEAR). If it  
is in a base class, then you are safe in the knowledge that any class  
can find any other in the same library, without tripping over anyone  
else's arrangements. You would still have to deal with the problem of  
finding the first class (which a global handler may help, subject to  
the issues that you've already raised), but once that's done, the  
problem is over. I don't see why they named it __autoload - the __  
prefix is usually reserved for special purpose methods, not global  
functions. Just plain 'autoload' in a global context is not really  
anything wildly different in style to say ini_set or error_reporting.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



[PHP] Multiple inserts as a single string?

2005-06-02 Thread Thomas
Hi there,

 

I have a bit of strange question: when wanting to insert multiple records
into the db, instead of looping through the set and executing mysql_query
(which will then call the db n times), is it not better to concat a string
with all the insert statements and let mysql handle the inserting, that way
we don't call the db n times from php. Does that make any difference?

Maybe I am just stupid .

 

Thomas



Re: [PHP] Craig's List Clone part deux

2005-06-02 Thread Angelo Zanetti
have you looked on sourceforge? there are alot of helpful scripts there,

hope this helps.

Angelo Zanetti
Z Logic
www.zlogic.co.za
[c] +27 72 441 3355
[t] +27 21 469 1052



Philip Hallstrom wrote:

 On May 31, 2005, at 1:48 PM, Michael O'Neal wrote:

 Thanks John.  That's one of the reasons I haven't gone that route. 
 The whole operation seemed cheesy to me.

 I appreciate the feedback though.


 On Tue, 31 May 2005, Michael O'Neal wrote:

 Anyone else?  I have a hard time believing it's not out there...but I
 could be wrong!!!


 I'm trusting you've looked at all 900,000 results here? :-)

 http://www.google.com/search?q=php+classified+scriptstart=0start=0ie=utf-8oe=utf-8client=firefox-arls=org.mozilla:en-US:official


 Seems like there is a *lot* out there, but whether or not they are any
 good is another matter :-)

 Maybe one of those sites will point you in the right direction.  The
 app itself wouldn't be that hard to develop yourself I don't think...

 -philip


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



Re: [PHP] Japanese with UTF-8 and mysql

2005-06-02 Thread M. Sokolewicz

Mark Sargent wrote:

Richard Davey wrote:


Hello Mark,

Monday, May 30, 2005, 4:18:20 PM, you wrote:

MS I have my settings in php.ini set for UTF-8, and the encoding for
MS the mysql database table's column that is using Japanese to UTF-8.
MS Now, if I view the data stored in that column in phpmyadmin, via
MS say, firefox, it displays in UTF-8, but, if I pull the code from
MS the database and display it in a UTF-8 set page, it is just ?
MS marks, although static J text displays fine...any thoughts on
MS this..? Driving me nutz. Cheers.

Are you doing anything to the data after you've pulled it back from
MySQL? Perhaps parsing it, or pushing it through a PHP function that
might convert it back to Latin1? (i.e. using non-overloaded PHP
functions when you should be using the mb functions)

Best regards,

Richard Davey
 


Hi All,

Richard, please view code provided below. Cheers.

Mark Sargent.

?php
session_start();
include(database.php);
?
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;
html
head
   meta http-equiv=Content-Type content=text/html; charset=UTF-8 /
titleJumbo Status-Product Details/title
/head
body lang=en
hr
h1 align=centerJUMBO STATUS/h1p
centerUsed Hardware Specialist/center
centera href=index.phpHome/a/center centera 
href=search.phpSearch/a/center

hr
table align=center bgcolor=lightblue cellpadding=2 border=2 
width=60%

?php
if (isset($_REQUEST[product_id])) {
  $product_id = $_REQUEST[product_id];
$result = mysql_query(SELECT Products.product_id, 
Products.product_name, Products.product_model_number, 
Products.product_price, Products.product_qty, Products.product_desc, 
Products.product_data_output, Conditions.condition_detail FROM Products 
INNER JOIN Conditions On Products.condition_id = Conditions.condition_id 
WHERE Products.product_id = '$product_id');


I don't know if you noticed, but $_REQUEST[product_id] (and thus 
$product_id have *enormous* SQL-injection capabilities. Imagine someone 
sending product_id=1';DROP TABLE Products, Conditions;, do you see the 
problem? You should never ever trsut any user-input, scan it, reform it, 
make sure it's what you expect, before using it.



if (!$result) {
   echo Query failed:  . mysql_error();
 exit;
}
$num = mysql_num_rows($result);
$rows = mysql_fetch_array($result);
echo tr align=\center\td colspan=\4\Status-Product 
Details/td/tr;

}
for ($i=0; $i$num; $i++){
echo tr align=\center\tdPRODUCT 
NAME/tdtd.$rows['product_name']./tdbrtr 
align=\center\tdQUANTITY/tdtd.$rows['product_qty']./td/trbrtr 
align=\center\tdPRICE/tdtd.$rows['product_price 
yen']./td/trbrtr 
align=\center\tdCONDITION/tdtd.$rows['product_condition']./td/trtr 
align=\center\td colspan=\2\MORE DETAILS/td/trtr 
align=\center\td 
colspan=\2\.$rows['product_desc']./td/trtr 
align=\center\td colspan=\2\DATA OUTPUT/td/trtr 
align=\center\td  
colspan=\2\.$rows['product_data_output']./td/tr;

}
?
/table
p
p
p
hrcenteremail: p
Telephone: p
Fax:
/center
/body


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



RE: [PHP] Multiple inserts as a single string?

2005-06-02 Thread Shaw, Chris - Accenture

Thomas,

If you're inserting alot of rows, (eg millions) then concating them and
calling the db once probably would give a small speed advantage, because of
the database handshaking.
But I would look at the load the database is under, if there is alot of users
hitting the database with small inserts/queries then the database is going to
suffer as opposed to the same number of users hitting the database once with
a script.

The only problem I can think of, from php (client) point of view, if the
script (concated inserts) errors, then you will need to handle where it went
wrong, if it was loop, you know exactly what went wrong by outputing the
current insert statement.

C.

-Original Message-
From: Thomas [mailto:[EMAIL PROTECTED]
Sent: 02 June 2005 10:20
To: php-general@lists.php.net
Subject: [PHP] Multiple inserts as a single string?


Hi there,



I have a bit of strange question: when wanting to insert multiple records
into the db, instead of looping through the set and executing mysql_query
(which will then call the db n times), is it not better to concat a string
with all the insert statements and let mysql handle the inserting, that way
we don't call the db n times from php. Does that make any difference?

Maybe I am just stupid .



Thomas






This message has been delivered to the Internet by the Revenue Internet e-mail 
service

*

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



Re: [PHP] TEST

2005-06-02 Thread Angelo Zanetti
gmail doesn't show you your own posts



why is that??

Angelo Zanetti
Z Logic
www.zlogic.co.za


  


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



Re: [PHP] Multiple inserts as a single string?

2005-06-02 Thread Richard Davey
Hello Thomas,

Thursday, June 2, 2005, 10:20:11 AM, you wrote:

T I have a bit of strange question: when wanting to insert multiple
T records into the db, instead of looping through the set and
T executing mysql_query (which will then call the db n times), is it
T not better to concat a string with all the insert statements and
T let mysql handle the inserting, that way we don't call the db n
T times from php. Does that make any difference?

Sure.. mysql_query doesn't support more than one query in the sql
statement.

If you want to do that then upgrade to PHP 5 (if you're not using it
already) and use mysqli_multi_query instead. I guess packages like
Pear DB may offer similar functionality, but I don't know for certain.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 I do not fear computers. I fear the lack of them. - Isaac Asimov

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



[PHP] Accessing DLL from PHP

2005-06-02 Thread Rory McKinley
Hi list

I do not have much programming experience outside some PHP stuff so
please excuse a stupid question:

I have a DLL provided to me by a third-party with a small bit of
documentation regarding its structure and methods. The DLL caculates
event costs based on parameters passed to it. I would like to access
this DLL using PHP if possible.

I have RTFM, and I am still busy STFW and STFA, but the little bit that
I have found has lead me towards trying to understand COM (eek!). Before
I go down that particular garden path, I would like to know if there is
any chance of success with PHP, or should I look at non-PHP alternatives
to access the DLL (e.g. C?)

Regards

Rory

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



Re[2]: [PHP] Japanese with UTF-8 and mysql

2005-06-02 Thread Richard Davey
Hello Mark,

Thursday, June 2, 2005, 4:18:30 AM, you wrote:

MS ?php
MS session_start();
MS include(database.php);
?

I would recommend setting UTF-8 as the Content-type via PHP itself:
header('Content-type: UTF-8') - do it as one of the first things when
you're ready to output the HTML.

MS !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN
MS http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;

This may well be a cause of the problem - your HTML doesn't look like
it's XTHML Strict compatible at all, so browsers are going to
re-render it (IE into Quirks mode). I would remove the DocType for now
or fix the mark-up errors.

MS ?php
MS if (isset($_REQUEST[product_id])) {
MS$product_id = $_REQUEST[product_id];

See the previous reply about why this isn't safe, but also it should
be: $_REQUEST['product_id'] (note the quotes) to avoid PHP scanning
for constants.

MS for ($i=0; $i$num; $i++){
MS echo tr align=\center\tdPRODUCT 
MS NAME/tdtd.$rows['product_name']./tdbrtr 

From a code point of view this is correct. Let's check a few obvious
things: does PHP have the mb extension installed? If so what is the
default character-set in php.ini?

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 I do not fear computers. I fear the lack of them. - Isaac Asimov

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



RE: [PHP] dynamic drop down

2005-06-02 Thread Mark Rees
The dropdown list is on the client (browser). Javascript runs on the
client. PHP runs on the server. 

You have 2 options 

- one is to do as Richard says and use javascript to change the contents
of one select box when an option is selected in another. 
- the other is to refresh the page when the option is selected and write
different data into the second select box based on the option selected.
This is a question of using echo and iterating through the data you wish
to output.


-Original Message-
From: Danny Brow [mailto:[EMAIL PROTECTED] 
Sent: 01 June 2005 07:08
To: PHP-Users
Subject: Re: [PHP] dynamic drop down


On Tue, 2005-05-31 at 22:08 -0700, Richard Lynch wrote:
 On Tue, May 31, 2005 8:48 pm, Danny Brow said:
  Could someone point me to an example with code for dynamic drop 
  downs in PHP? I would like to be able to have drop downs like 
  Select Country and another drop down show the states/provinces 
  based on the selected country.
 
 Well, the dynamic part of it isn't gonna be in PHP at all ; It's 
 gonna be JavaScript.

I thought I'd have to use JS, but was hoping someone knew a way to do it
with PHP.


 You can Google for JavaScript dynamic menus to find what you want.  
 Then you just need to use PHP to spew out the JavaScript you want to 
 spew out, but that's no different than spewing out the HTML you want 
 to spew out, really.

Tons on google, thanks,

Dan.

Gamma Global : Suppliers of HPCompaq, IBM, Acer, EPI, APC, Cyclades, D-Link, 
Cisco, Sun Microsystems, 3Com

GAMMA GLOBAL (UK) LTD IS A RECOGNISED 'INVESTOR IN PEOPLE' AND REGISTERED FOR 
ISO 9001:2000 CERTIFICATION

**

CONFIDENTIALITY NOTICE:

This Email is confidential and may also be privileged. If you are not the
intended recipient, please notify the sender IMMEDIATELY; you should not
copy the email or use it for any purpose or disclose its contents to any
other person.

GENERAL STATEMENT:

Any statements made, or intentions expressed in this communication may not
necessarily reflect the view of Gamma Global (UK) Ltd. Be advised that no 
content
herein may be held binding upon Gamma Global (UK) Ltd or any associated company
unless confirmed by the issuance of a formal contractual document or
Purchase Order,  subject to our Terms and Conditions available from 
http://www.gammaglobal.com

EOE

**
**


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



RE: [PHP] Multiple inserts as a single string?

2005-06-02 Thread Shaw, Chris - Accenture

Thomas,

I am not sure what database you are using, but there was a previous email
thread about using execQuery($concatstring) for mySQL, which apparently
worked. Make sure that your insert statements end with the standard line
terminator character, usually ';'.

Personally, I would output the statements to a file, then use the cmd line
function for executing .sql files for that database. You could execute this
from php by using the shell_exec function. This is so I could look at the
executed sql file and find where the error is, I'm not a big fan of debugging
in php.

C.

-Original Message-
From: Thomas [mailto:[EMAIL PROTECTED]
Sent: 02 June 2005 12:20
To: Shaw, Chris - Accenture
Cc: php-general@lists.php.net
Subject: RE: [PHP] Multiple inserts as a single string?


*

This e-mail has been received by the Revenue Internet e-mail service.

*

Hi Chris,

Thanks, I thought so. You are quite right with the errors, I ran into some
where it looked like that php does not allow you to execute such a concated
string ... the error started at the second insert statement with no apparent
reason. Is that a ph restriction?

Thomas

-Original Message-
From: Shaw, Chris - Accenture [mailto:[EMAIL PROTECTED]
Sent: 02 June 2005 12:20 PM
To: Thomas; php-general@lists.php.net
Subject: RE: [PHP] Multiple inserts as a single string?


Thomas,


If you're inserting alot of rows, (eg millions) then concating them and
calling the db once probably would give a small speed advantage, because of
the database handshaking.
But I would look at the load the database is under, if there is alot of
users
hitting the database with small inserts/queries then the database is going
to
suffer as opposed to the same number of users hitting the database once with
a script.

The only problem I can think of, from php (client) point of view, if the
script (concated inserts) errors, then you will need to handle where it went
wrong, if it was loop, you know exactly what went wrong by outputing the
current insert statement.

C.

-Original Message-
From: Thomas [mailto:[EMAIL PROTECTED]
Sent: 02 June 2005 10:20
To: php-general@lists.php.net
Subject: [PHP] Multiple inserts as a single string?


Hi there,




I have a bit of strange question: when wanting to insert multiple records
into the db, instead of looping through the set and executing mysql_query
(which will then call the db n times), is it not better to concat a string
with all the insert statements and let mysql handle the inserting, that way
we don't call the db n times from php. Does that make any difference?

Maybe I am just stupid .




Thomas






This message has been delivered to the Internet by the Revenue Internet
e-mail service

*

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







This message has been delivered to the Internet by the Revenue Internet e-mail 
service

*

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



RE: [PHP] TEST

2005-06-02 Thread Jay Blanchard
[snip]
gmail doesn't show you your own posts

why is that??
[/snip]


Sounds like a question for the gmail folks.

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



Re: [PHP] Multiple inserts as a single string?

2005-06-02 Thread Rory McKinley
Richard Davey wrote:
snip
 
 Sure.. mysql_query doesn't support more than one query in the sql
 statement.
 
snip

At the risk of being thick, does the OP not mean something like this:

INSERT INTO blah VALUES (value1, value2), (value3, value4)

versus

INSERT INTO blah
VALUES (value1, value2)

 next iteration

INSERT INTO blah
VALUES (value3, value4)

Regards

Rory

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



Re: [PHP] PHP 5 Question about OO

2005-06-02 Thread Marcus Bointon

On 2 Jun 2005, at 11:56, Colin Ross wrote:

The way I see it, you are gonna be spending quite a bit of time  
writing all those lines of code for the class, what is bad about  
another requiring the file each time?


Huh? Writing a 1-line function in a base class means that I would  
never have to write another require anywhere in my library (other to  
include the base class of course, which could conceivably be picked  
up by a global autoload anyway). Each of my 50-odd classes probably  
talks to 5 other classes in the library, giving a net saving of 250  
lines. How is that bad? (I am talking hypothetically anyway as we  
don't have autoload methods at present).


This thread is meant to be about how to improve automatic include  
file location - saying not to try to do it at all is not very helpful.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] PHP 5 Question about OO

2005-06-02 Thread Jochem Maas

Richard Lynch wrote:

On Wed, June 1, 2005 3:53 am, Marcus Bointon said:


On 1 Jun 2005, at 11:38, Jochem Maas wrote:



all true, now imagine that you install a couple of 3rdparty php5
'packages'
and they all define __autoload() - ain't gonna work! which is why
there has been
discussion on internals regarding the possibility of use a handler-
function stack
for autoloading (in the same way that you can register a stack of
input/output
filter-function)... something to keep an eye on in case things
change :-)


I've run into this one. One way that would work for me (and initially
it's how I assumed it worked) is for __autoload to be a standard
class method like __construct, so that a class would attempt to run
its own autoloader before breaking out to the global function namespace.



Maybe I'm being dumb, but how can an object's __autoload function get
called when the object class definition hasn't been loaded, and that's why
you're calling __autoload in the first place...

That seems like classic chicken/egg situation to me...



that was my first reaction, but then I thought what if the __autoload()
function was called when 'any' class needed to be included while running
code inside said class... that _might_ actually be useful

at any rate the __autoload() issue is still very much undecided :-)


It's also incredibly likely that __autoload's being stacked won't work
out too well.

Consider this:

foo software defines an __autoload
Some foo_* classes get defined, autoloaded, everybody's happy.
bar software defines an __autoload
Some bar_* classes get defined, autoloaded, everybody's happy.
Now some foo_* classes try to get instantiated, for whateve reason.
bar's __autoload function is gonna kick, and that ain't good for foo_*

Seems to me you'd need an array of regular expressions and the function to
call:

array('foo_*'='foo__autoload', 'bar_*'='bar__autoload')

if you wanted to allow multiple __autoload functions to exist...

I'm sure there are other ideas/solutions floating around, but that's A
possibility.

For performance, maybe just use stristr and 'foo_' instead of RegEx and
'foo_*' [shrug]



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



RE: [PHP] Multiple inserts as a single string?

2005-06-02 Thread Thomas
Hi Chris,

Thanks, I thought so. You are quite right with the errors, I ran into some
where it looked like that php does not allow you to execute such a concated
string ... the error started at the second insert statement with no apparent
reason. Is that a ph restriction?

Thomas

-Original Message-
From: Shaw, Chris - Accenture [mailto:[EMAIL PROTECTED] 
Sent: 02 June 2005 12:20 PM
To: Thomas; php-general@lists.php.net
Subject: RE: [PHP] Multiple inserts as a single string?


Thomas,


If you're inserting alot of rows, (eg millions) then concating them and
calling the db once probably would give a small speed advantage, because of
the database handshaking.
But I would look at the load the database is under, if there is alot of
users
hitting the database with small inserts/queries then the database is going
to
suffer as opposed to the same number of users hitting the database once with
a script.

The only problem I can think of, from php (client) point of view, if the
script (concated inserts) errors, then you will need to handle where it went
wrong, if it was loop, you know exactly what went wrong by outputing the
current insert statement.

C.

-Original Message-
From: Thomas [mailto:[EMAIL PROTECTED]
Sent: 02 June 2005 10:20
To: php-general@lists.php.net
Subject: [PHP] Multiple inserts as a single string?


Hi there,




I have a bit of strange question: when wanting to insert multiple records
into the db, instead of looping through the set and executing mysql_query
(which will then call the db n times), is it not better to concat a string
with all the insert statements and let mysql handle the inserting, that way
we don't call the db n times from php. Does that make any difference?

Maybe I am just stupid .




Thomas






This message has been delivered to the Internet by the Revenue Internet
e-mail service

*

-- 
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] Multiple inserts as a single string?

2005-06-02 Thread Thomas
Thanks Richard that makes it clear.

Thomas

-Original Message-
From: Richard Davey [mailto:[EMAIL PROTECTED] 
Sent: 02 June 2005 12:43 PM
To: php-general@lists.php.net
Subject: Re: [PHP] Multiple inserts as a single string?

Hello Thomas,

Thursday, June 2, 2005, 10:20:11 AM, you wrote:

T I have a bit of strange question: when wanting to insert multiple
T records into the db, instead of looping through the set and
T executing mysql_query (which will then call the db n times), is it
T not better to concat a string with all the insert statements and
T let mysql handle the inserting, that way we don't call the db n
T times from php. Does that make any difference?

Sure.. mysql_query doesn't support more than one query in the sql
statement.

If you want to do that then upgrade to PHP 5 (if you're not using it
already) and use mysqli_multi_query instead. I guess packages like
Pear DB may offer similar functionality, but I don't know for certain.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 I do not fear computers. I fear the lack of them. - Isaac Asimov

-- 
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] Quick q, most prolly 0T

2005-06-02 Thread Jochem Maas

Ryan A wrote:

Hey,

On 6/2/2005 5:17:47 AM, Richard Lynch ([EMAIL PROTECTED]) wrote:


URL re-writing can do that -- It ends up using his 'index' file (or
whatever) but you don't see it in the URL.



Thanks for replying.

But if I want to copy his exact way of doing things...instead of index file
I would like to
use main.phphow would i do that?
The reason I dont think its url rewriting is the rest of the files have all


AFAIK there is no definite way to tell what he is doing behind the scenes.


their values
eg:
somesite.com/?blah=blah
somesite.com/?something=somethingdo=1
somesite.com/?page=introflash=no


you can do the rewrite trick in php.

make sure everything goes via the index. (easy)
make sure 404's are handled by your index. (use .htaccess)

if you have a '404' first parse the complete request
to determine if you have some content to show based on
what every you found in the request, if you do then make the
404 handler spit out a 200 Status header along
with what ever output you have for the user -- other you have a
real 404 to deal with.


I have used such a schema to allow a user to define in a DB
what 'nice URLs' should link to particular articles etc.

e.g. the real URL is http://example.com/arts/article.php?id=345bar=foo

the DB is configured to match:
http://example.com/arts/article.php?id=345bar=foo
with
http://example.com/urlrewritten.html
(I have it so that the URL query params in the 'real URL' are
parsed and initialized before the real file [arts/article.php] is included)


My php 404 handler sees the user requested 
'http://example.com/urlrewritten.html'
finds the match in the DB, loads the relevant GET args and includes/runs the
script. thew backend might be hacky-as- but in terms of SEO it really 
works well!
(and it beats trying to teach my dad to SSH into a webserver and
edit a .htaccess full of rewrite engine declarations! :-)



etc

Thanks,
Ryan





On Wed, June 1, 2005 7:25 pm, Ryan A said:


Hey,
I noticed a site that is using php, but he is has shortened the url so
that
the filename was not shown..
eg:
somesite.com/?a=1

How did they do that? if it was url rewriting it would be


somesite.com/1/


so
what is he using?

Thanks,
Ryan



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.322 / Virus Database: 267.4.0 - Release Date: 6/1/2005

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





--
Like Music?
http://l-i-e.com/artists.htm







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



Re: [PHP] .INC files

2005-06-02 Thread Jochem Maas

Richard Lynch wrote:

On Wed, June 1, 2005 1:29 am, Denis Gerasimov said:


Second, which way are you differ PHP .inc files from HTML .inc files?



There is no such thing as an HTML .inc file. :-)

All your HTML .inc files, by definition, if they are being require'd or
include'd into PHP *are* PHP .inc files.

It is merely a coincidence of your design that they happen to have no
?php ? tags in them.

You *MAY* want to separate those into another other non-web tree directory.



Third, I always write context-independent include files.



Example?...

Can you guarantee that ever .inc and .inc.php and .php file in every
third-party application is context-independent?

Suppose your client insists tomorrow that you install [insert least
favority forum software here]?

You *NEED* to have the policy/procedure in place to get those .inc and
.inc.php and non-entry .php files *OUT* of the web-tree, or you will get
bit, sooner or later.

It's simply too easy to transfer a site and lose the .htaccess files, or


I've been bitten by that :-)

so what I often do now is use a 'root' .htaccess to define my include_path,
without it the whole site does nothing except go 'argh' at the first line of
each script that can be calledthe first line always being 'include ';

so now I don't forget to copy the .htaccess. ;-)

also this approach makes it easier to check out a project from CVS and get it
running whereever - you just need to create/edit (.htaccess don't live in my CVS
for the very reason that they are specific to a given checkout/installation)
a suitable .htaccess and the site goes.

it's been a great week for tips and advice from the 'big guns' - thanks
to you all, I really have learnt alot this week!

(who are big guns? well their names are either splattered
all over the source or they have been hammering this list with
knowledge for years or both! yes you too Richard ;-)


for a new/changed httpd.conf to not have the .inc rules or mess up PHP
completely or...

Why risk the possibility of your code being exposed or executed out of
context when it's so *EASY* to move the include files and set
include_path?

I just don't understand the resistance to such a simple straight-forward
elegant security measure.

For 5 minutes of time, you can avoid dozens of potential pitfalls. [shrug]



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



Re: [PHP] Accessing DLL from PHP

2005-06-02 Thread Rory Browne
I'm not too sure, but that sounds like a job for ffi. I think you'll
find ffi at pecl.php.net, although, be warned that I've never used
ffi, nor have I read any reports as to how well it worked.

On 6/2/05, Rory McKinley [EMAIL PROTECTED] wrote:
 Hi list
 
 I do not have much programming experience outside some PHP stuff so
 please excuse a stupid question:
 
 I have a DLL provided to me by a third-party with a small bit of
 documentation regarding its structure and methods. The DLL caculates
 event costs based on parameters passed to it. I would like to access
 this DLL using PHP if possible.
 
 I have RTFM, and I am still busy STFW and STFA, but the little bit that
 I have found has lead me towards trying to understand COM (eek!). 
Does the module you're trying to access have a COM interface? If not,
then this is a non-runner.

Regards

Rory (seriously)

 Before
 I go down that particular garden path, I would like to know if there is
 any chance of success with PHP, or should I look at non-PHP alternatives
 to access the DLL (e.g. C?)
 
 Regards
 
 Rory
 
 --
 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] Accessing DLL from PHP

2005-06-02 Thread Angelo Zanetti
perhaps the system command is what you are looking for?

its in the manual. just search in the manual for it...

Hope this helps

Angelo Zanetti
Z Logic
www.zlogic.co.za



Rory McKinley wrote:

Hi list

I do not have much programming experience outside some PHP stuff so
please excuse a stupid question:

I have a DLL provided to me by a third-party with a small bit of
documentation regarding its structure and methods. The DLL caculates
event costs based on parameters passed to it. I would like to access
this DLL using PHP if possible.

I have RTFM, and I am still busy STFW and STFA, but the little bit that
I have found has lead me towards trying to understand COM (eek!). Before
I go down that particular garden path, I would like to know if there is
any chance of success with PHP, or should I look at non-PHP alternatives
to access the DLL (e.g. C?)

Regards

Rory

  


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



Re: [PHP] Quick q, most prolly 0T

2005-06-02 Thread Ryan A
Hi Chris,
Thanks for replying

  I noticed a site that is using php, but he is has shortened
  the url so that the filename was not shown..
  eg:
  somesite.com/?a=1
 
  How did they do that?

 It's called a directory index. Examples include index.html and
 index.php. You configure this with the DirectoryIndex directive in
 httpd.conf.

I did see the directory index in the httpd.conf file, but let me explain a
bit more about what
I am trying to do.
Basically I am waiting for the client to pay me...till he does, I am
displaying the index page which
is a under construction page...but he also wants to play with the site so I
need to direct all calls
to main.php...but i dont want to show the client that he is going to
main.php so I wanted to use
it like this clientssite.com/?do=blah

Thanks,
Ryan



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.322 / Virus Database: 267.4.0 - Release Date: 6/1/2005

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



RE: [PHP] Multiple inserts as a single string?

2005-06-02 Thread Jared Williams
 
 Thanks Richard that makes it clear.
 
 Thomas
 
 Hello Thomas,
 
 Thursday, June 2, 2005, 10:20:11 AM, you wrote:
 
 T I have a bit of strange question: when wanting to insert multiple 
 T records into the db, instead of looping through the set 
 and executing 
 T mysql_query (which will then call the db n times), is it 
 not better 
 T to concat a string with all the insert statements and let mysql 
 T handle the inserting, that way we don't call the db n 
 times from php. 
 T Does that make any difference?

Inserting multiple rows with one INSERT statement is part of the SQL standard 
(IIRC), and MySQL supports it.

INSERT INTO table(a,b) VALUES (1,1), (2,2), (3,3), ... ,(n, n)


Jared

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



Re: [PHP] PHP 5 Question about OO

2005-06-02 Thread Jason Barnett

Jochem Maas wrote:

Richard Lynch wrote:


On Wed, June 1, 2005 3:53 am, Marcus Bointon said:


On 1 Jun 2005, at 11:38, Jochem Maas wrote:



all true, now imagine that you install a couple of 3rdparty php5
'packages'
and they all define __autoload() - ain't gonna work! which is why
there has been
discussion on internals regarding the possibility of use a handler-
function stack
for autoloading (in the same way that you can register a stack of
input/output
filter-function)... something to keep an eye on in case things
change :-)



I've run into this one. One way that would work for me (and initially
it's how I assumed it worked) is for __autoload to be a standard
class method like __construct, so that a class would attempt to run
its own autoloader before breaking out to the global function namespace.




Maybe I'm being dumb, but how can an object's __autoload function get
called when the object class definition hasn't been loaded, and that's 
why

you're calling __autoload in the first place...

That seems like classic chicken/egg situation to me...



that was my first reaction, but then I thought what if the __autoload()
function was called when 'any' class needed to be included while running
code inside said class... that _might_ actually be useful

at any rate the __autoload() issue is still very much undecided :-)



I opened up a feature request for this very topic a while back.  The 
__autoload function should just register user-defined functions and 
store those func names in a stack so that (in turn) each function can 
require the appropriate file.  If the first registered function fails to 
load the class then __autoload tries the next registered fucntion and so 
on until all of the registered functions have been tried.  At this point 
if __autoload fails then we E_ERROR out explaining that __autoload could 
not load the class definition.


As far as I can tell this is the cleanest solution that has been 
provided, but there is some disagreement over some of the details on 
this approach.


just_kiddingLife would be so much easier if everyone just did things 
like the PEAR coders do/just_kidding



--
Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-generalw=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY | 
http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins


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



Re: [PHP] what is -- $this variable - $this other variable -- means?

2005-06-02 Thread ...helmut
thanks for your responses, your comments have lead me to:

http://php.mirrors.ilisys.com.au/manual/en/language.variables.scope.php

and

http://php.mirrors.ilisys.com.au/manual/en/language.variables.variable.php

which certainly explain what I was after.

Thanks!

-- 
...helmut
helmutgranda.com



Richard Lynch [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On Wed, June 1, 2005 12:43 pm, ...helmut said:
 $this variable - $this other variable

 Means?

 I have seen it and i have used but I am not sure what exactly it means
 in
 regular English or Spanish wording that is.

 In Computer Science it is known as:
 slot
 property
 member variable

 depending on which language you use (Lisp, Scheme, C++, PHP, ...)

 Dunno what it would be in English, much less Spanish.

 It really isn't all that different from PHP's array indices, though in
 other languages the differences are magnified between an array element and
 -

 There are also funky things you can do (in PHP, even) to trigger action
 (code) when somebody accesses/reads a slot, or stores data/writes to a
 slot.

 If you Google for Object Oriented and Properties, Slots, Member
 Variables in various combinations you should find a ton of info.

 -- 
 Like Music?
 http://l-i-e.com/artists.htm 

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



Re: [PHP] Accessing DLL from PHP

2005-06-02 Thread Richard Davey
Hello Rory,

Thursday, June 2, 2005, 11:53:56 AM, you wrote:

RM I have RTFM, and I am still busy STFW and STFA, but the little bit
RM that I have found has lead me towards trying to understand COM
RM (eek!). Before I go down that particular garden path, I would like
RM to know if there is any chance of success with PHP, or should I
RM look at non-PHP alternatives to access the DLL (e.g. C?)

If the DLL has a COM interface then you can use PHP to talk to it, the
process is actually quite straight forward (depending on what the DLL
actually does of course).

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 I do not fear computers. I fear the lack of them. - Isaac Asimov

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



Re[2]: [PHP] Accessing DLL from PHP

2005-06-02 Thread Richard Davey
Hello Angelo,

Thursday, June 2, 2005, 1:55:01 PM, you wrote:

AZ perhaps the system command is what you are looking for?

For calling functions within a DLL?? I don't think so.

All system() does is to execute a command/executable. If the OP was to
interface with this DLL from an exe, then this would be possible, but
bear in mind the PHP memory limit - it extends to anything called via
system too. If you're going to pay someone to create the exe in the
first place they might as well build a COM interface for it to avoid
this issue.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 I do not fear computers. I fear the lack of them. - Isaac Asimov

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



Re: [PHP] str_replace weird output

2005-06-02 Thread Andy Pieters
On Thursday 02 June 2005 09:52, [EMAIL PROTECTED] wrote:
 But if I do that :

 ?php
 $texte = 'cd' ;
 $original = array('a', 'b', 'c', 'd', 'e', 'f', 'g');
 $modif = array ('c', 'd', 'e', 'f', 'g', 'h', 'i');
 $texte = str_replace($original, $modif, $texte) ;
 echo $texte, ' br /' ;
 ?

 The result is : ih

 Why ?

You should know that, unless you tell php to limit the number of replaces, it 
will keep on replacing until it doesn't find a match anymore. 

Here is what happens:

 ?php
 $texte = 'cd' ;
 $original = array('a', 'b', 'c', 'd', 'e', 'f', 'g');
 $modif = array ('c', 'd', 'e', 'f', 'g', 'h', 'i');
 $texte = str_replace($original, $modif, $texte) ;
#after first replacement
$texte='ef'
#after 2nd replacement
$texte='gh'
#after third replacement
$texte='ih';

If you want to prevent this, tell the function that you only want 2 
replacements.  Like this:
$limite=2;
$texte=str_replace($original,$modif,$texte,$limite);

Hope this helps

With kind regards


ps: the php documentation is also available in French.  Check out: 
http://fr2.php.net/manual/fr/function.str-replace.php for more info on 
str_replace

Andy

-- 
Registered Linux User Number 379093
-- --BEGIN GEEK CODE BLOCK-
Version: 3.1
GAT/O/E$ d-(---)+ s:(+): a--(-)? C$(+++) UL$ P-(+)++
L+++$ E---(-)@ W++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++)
PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+)
e$@ h++(*) r--++ y--()
-- ---END GEEK CODE BLOCK--
--
Check out these few php utilities that I released
 under the GPL2 and that are meant for use with a 
 php cli binary:
 
 http://www.vlaamse-kern.com/sas/
--

--

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



Re: [PHP] What Works Works Validator

2005-06-02 Thread Leif Gregory
Hello Richard,

Wednesday, June 1, 2005, 3:16:50 PM, you wrote:
R Does anybody know of a What Works Works Validator which checks
R for maxiumum browser compatibility rather than the W3C standard?

E. Got it listed on my XHTML test page at:

http://www.devtek.org/test (In the resources section about validation
services). I think it was the Hermish one.

http://www.hermish.com/

Sorry, gotta run to pick up my daughter or I'd have checked it for
you.


-- 
Leif (TB lists moderator and fellow end user).

Using The Bat! 3.5.24 under Windows XP 5.1
Build 2600 Service Pack 2 on a Pentium 4 2GHz with 512MB

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



Re: [PHP] Accessing DLL from PHP

2005-06-02 Thread Rory McKinley
Richard Davey wrote:
snip
 If the DLL has a COM interface then you can use PHP to talk to it, the
 process is actually quite straight forward (depending on what the DLL
 actually does of course).
 
 Best regards,
 
 Richard Davey
snip

Hi Richard

Rory (the other one ;) ) also mentioned a COM interface - currently I am
trying to find out if such a beast exists for the DLL, there is nothing
in the documentation. I would be interested to know if there was an easy
way to found out - still STFW though.

Have downloaded ffi as per Rory's suggestion, from the attached
documentation it looks as if it may be doable if the COM route doesn't
pan out.

Regards

Rory

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



Re: [PHP] Questionary Development - Continued

2005-06-02 Thread Chris Boget
 That being the case, you may want to consider ajax, so that users
 answers are recorded as soon as they make them.

What's 'ajax'?  Link please?

thnx,
Chris

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



[PHP] Using GET to build multiple sql queries

2005-06-02 Thread Jack Jackson
 I'd love some help with http://hashphp.org/pastebin?pid=3443 if anyone 
can...


Basically I want to make it so that, if the get in the url specifies no 
query or a query to a nonexistent row, send to vanilla index. If url 
specifies c= then set $c=c and use the number to build the mysql query; 
same for p= and s= - if they're valid build  the query, if not kick em out.


Can anyone offer any help?

Thanks in advance!

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



Re: [PHP] PHP 5 Question about OO

2005-06-02 Thread Jochem Maas

Jason Barnett wrote:

Jochem Maas wrote:


Richard Lynch wrote:


On Wed, June 1, 2005 3:53 am, Marcus Bointon said:


On 1 Jun 2005, at 11:38, Jochem Maas wrote:



...





I opened up a feature request for this very topic a while back.  The 
__autoload function should just register user-defined functions and 
store those func names in a stack so that (in turn) each function can 
require the appropriate file.  If the first registered function fails to 
load the class then __autoload tries the next registered fucntion and so 
on until all of the registered functions have been tried.  At this point 
if __autoload fails then we E_ERROR out explaining that __autoload could 
not load the class definition.


As far as I can tell this is the cleanest solution that has been 
provided, but there is some disagreement over some of the details on 
this approach.


agreed, but as you point out - the devil is in the details. :-)



just_kiddingLife would be so much easier if everyone just did things 
like the PEAR coders do/just_kidding


say-it-like-a-piratethat be fightin' talk m'friend ;-)/say-it-like-a-pirate






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



[PHP] OO DB in PHP?

2005-06-02 Thread GamblerZG
When you have objects stored on disk, it's usually very convenient to 
read them on demand. However, MySQL is clearly not meant for this 
purpose. Query overhead, complexity of SQL needed, and some other 
limitation make object storage and retrieval a headache.


The question is, is it possible to write reasonably efficient OO 
database in php? Two main factors would be:
1) Is is possible to make fast B-tree index search without writing any C 
code?
2)How long does it takes for PHP to open 1 file? (It will need to open 
hundreds of them.)


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



Re: [PHP] Questionary Development - Continued

2005-06-02 Thread Rory Browne
On 6/2/05, Chris Boget [EMAIL PROTECTED] wrote:
  That being the case, you may want to consider ajax, so that users
  answers are recorded as soon as they make them.
 
 What's 'ajax'?  Link please?
www.google.com


 
 thnx,
 Chris
 


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



[PHP] Delay?

2005-06-02 Thread Jack Jackson

Has anyone else noticed significant delays in messages getting posted?

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



Re: [PHP] Questionary Development - Continued

2005-06-02 Thread Rory Browne
Sorry I thought I'd sent this to the list.

On 6/1/05, Rory Browne [EMAIL PROTECTED] wrote:
 http://www.adaptivepath.com/publications/essays/archives/000385.php
 
 www.wikipedia.org/wiki/AJAX
 
 
 On 6/1/05, Ryan A [EMAIL PROTECTED] wrote:
 
   That being the case, you may want to consider ajax, so that users
   answers are recorded as soon as they make them.
 
  Hey Rory,
  Got the URL to Ajax? I'm just kinda curiousnever know when I might
  need something like this.
 
  Thanks,
  Ryan
 
 
  --
  No virus found in this outgoing message.
  Checked by AVG Anti-Virus.
  Version: 7.0.322 / Virus Database: 267.3.1 - Release Date: 5/31/2005
 
 


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



Re[2]: [PHP] Questionary Development - Continued

2005-06-02 Thread Richard Davey
Hello Chris,

Thursday, June 2, 2005, 4:43:09 PM, you wrote:

 That being the case, you may want to consider ajax, so that users
 answers are recorded as soon as they make them.

CB What's 'ajax'?  Link please?

It's a way of using the XML HTTP Request object in JavaScript to
provide a very dynamic instant web experience without page reloads
(there are compatability caveats of course, but name me a technology
that doesn't have this).

XML HTTP Request info here: http://jibbering.com/2002/4/httprequest.html

Very easy to use PHP interface: http://www.modernmethod.com/sajax/

Some superb examples of AJAX in action: http://www.forgetfoo.com
Look at areas like the calendar, image gallery, etc - looks almost
Flash quality doesn't it?

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 I do not fear computers. I fear the lack of them. - Isaac Asimov

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



Re: [PHP] PHP 5 Question about OO

2005-06-02 Thread GamblerZG
Maybe it's just me, but the core concept of __autoload() seems to be 
broken to me. Moreover, every proposed solution I've heard about is 
totally inside the box. I would do it like this:

1) Define $_AUTOLOAD superglobal.
2) If I need SomeClass to be autoloaded I write this:
$_AUTOLOAD['SomeClass'] = 'some/dir/some_classs.php';
3) If I care, I could check whether $_AUTOLOAD['SomeClass'] is already 
set and generate an error.


This would mimic Java behaviour (it's about competing with Java, is it?) 
without creating artificial headache for programmers. But wait! What do 
I know? This will cbreak BC; moreover, BC will be broken by this. Forget 
I said something.


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



Re: [PHP] OO DB in PHP?

2005-06-02 Thread Greg Donald
On 6/2/05, GamblerZG [EMAIL PROTECTED] wrote:
 When you have objects stored on disk, it's usually very convenient to
 read them on demand. However, MySQL is clearly not meant for this
 purpose.

A serialized PHP object is just a string of data.  MySQL is a very
fast `data`base, so I don't quite understand this statement.

 Query overhead, complexity of SQL needed, and some other
 limitation make object storage and retrieval a headache.

Did you have some code that you need help debugging?

 The question is, is it possible to write reasonably efficient OO
 database in php?

I don't use objects in web applications.  In my experience the
overhead involved in creating an object for the extremely short
lifetime it has is overkill.

 Two main factors would be:
 1) Is is possible to make fast B-tree index search without writing any C
 code?

MySQL supports btree indexes for MyISAM and InnoDB table types.

 2)How long does it takes for PHP to open 1 file? (It will need to open
 hundreds of them.)

Depends on your hardware, not so much PHP.


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



[PHP] sanitizing get vars

2005-06-02 Thread Sebastian

what is a safe way to clean a post/get before echoing it.
example. input form, user enters some text, hits enter.

.. next page i echo what they entered.
right now i just run the variables passed by htmlentities() which 
preseves any html. is that acceptable?


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



Re: [PHP] Questionary Development - Continued

2005-06-02 Thread Greg Donald
On 6/2/05, Chris Boget [EMAIL PROTECTED] wrote:
 What's 'ajax'?  Link please?

http://en.wikipedia.org/wiki/AJAX

I've been playing with it using Ruby on Rails, it's built-in.


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



Re: [PHP] Using GET to build multiple sql queries

2005-06-02 Thread Greg Donald
On 6/2/05, Jack Jackson [EMAIL PROTECTED] wrote:
   I'd love some help with http://hashphp.org/pastebin?pid=3443 if anyone
 can...
 
 Basically I want to make it so that, if the get in the url specifies no
 query or a query to a nonexistent row, send to vanilla index. If url
 specifies c= then set $c=c and use the number to build the mysql query;
 same for p= and s= - if they're valid build  the query, if not kick em out.
 
 Can anyone offer any help?

I'd iterate over the $_GET array to build the query elements.  Then
implode those elements.

$array = array();

while( list( $k, $v ) = each( $_GET ) )
{
if( $k == 'somekeynotindb' )
{
continue;
}

$array[] = $k . =' . $v . ';
}

if( $array )
{
$and = implode( ', ', $array );
}

$sql = 
SELECT *
FROM table
WHERE 1
$and
;

$query = mysql_query( $sql );


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



Re: [PHP] Delay?

2005-06-02 Thread Sebastian

yea.. takes hours... sometimes 6+ or more.
i dont post that much to the list for this reason.. if it stays like 
this i'll just unsubscribe.. its pointless... this is suppose to be 
E-mail, not post office mail.


Jack Jackson wrote:


Has anyone else noticed significant delays in messages getting posted?



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



Re: [PHP] Delay?

2005-06-02 Thread Richard Davey
Hello Jack,

Thursday, June 2, 2005, 5:24:26 PM, you wrote:

JJ Has anyone else noticed significant delays in messages getting posted?

Yes. My last post took just under 1 hour! I copied this to you as well
to prove the point :)

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 I do not fear computers. I fear the lack of them. - Isaac Asimov

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



Re: [PHP] Delay?

2005-06-02 Thread Jason Sweeney

Jack Jackson wrote:

Has anyone else noticed significant delays in messages getting posted?




No, no delay on my end.

So... any word on the release date for PHP 3?

--
jason sweeney
jason.designshift.com

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



Re: [PHP] sanitizing get vars

2005-06-02 Thread Greg Donald
On 6/2/05, Sebastian [EMAIL PROTECTED] wrote:
 what is a safe way to clean a post/get before echoing it.
 example. input form, user enters some text, hits enter.

set_magic_quotes_runtime( 0 );

if( get_magic_quotes_gpc() == 0 )
{
   $_GET= isset( $_GET )? array_map( 'slashes', $_GET ) : array();
   $_POST   = isset( $_POST )   ? array_map( 'slashes', $_POST ): array();
   $_COOKIE = isset( $_COOKIE ) ? array_map( 'slashes', $_COOKIE )  : array();
}

function slashes( $var )
{
if( is_array( $var ) )
{
return array_map( 'slashes', $var );
}

return addslashes( $var );
}


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



Re: [PHP] OO DB in PHP?

2005-06-02 Thread GamblerZG

Did you have some code that you need help debugging?


Since you have asked...
http://fs.net/projects/naturalgine

Could you please download the latest version, open tools/objects.php and 
look at getObjects() function? Just take a look at it, and you will 
undesrstand what am I talking about, and why I don't want to use mySQL.


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



[PHP] Re: OO DB in PHP?

2005-06-02 Thread Manuel Lemos

Hello,

on 06/02/2005 12:37 PM GamblerZG said the following:
When you have objects stored on disk, it's usually very convenient to 
read them on demand. However, MySQL is clearly not meant for this 
purpose. Query overhead, complexity of SQL needed, and some other 
limitation make object storage and retrieval a headache.


Not if you use an efficient object-relational tool.

You may want to take a look at Metastorage. This is a tool that 
generates efficient persistent object classes from a model definition in 
a simple XML format of classes, variables, relationships, validation 
rules, functions to manipulate the objects.


Then Metastorage generates classes of persistent objects that perform 
the necessary object-relational mapping that you can use right away in 
your applications.


It supports its own Object Query Language (OQL) so you can express 
object search and filter conditions, that may include parameter values 
passed to your persistent object classes at runtime.


Metastorage compiles the OQL expressions into efficient SQL that is 
embedded into the generate PHP code of the persistent object classes.


You may find all about Metastorage here:

http://www.meta-language.net/metastorage.html

Screenshots of the Web interface of Metastorage compiler
http://www.meta-language.net/screenshots.html

Documentation with tutorials and examples
http://www.meta-language.net/documentation.html#metastorage

Download
http://www.meta-language.net/download.html

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html

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



Re: [PHP] PHP 5 Question about OO

2005-06-02 Thread Greg Donald
On 6/2/05, GamblerZG [EMAIL PROTECTED] wrote:
 Maybe it's just me, but the core concept of __autoload() seems to be
 broken to me. Moreover, every proposed solution I've heard about is
 totally inside the box. I would do it like this:
 1) Define $_AUTOLOAD superglobal.

When forced to do OO, I use it like this:

function __autoload( $class )
{
   require_once( $GLOBALS[LIB_PATH]/$class.class.php );
}


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



[PHP] Best way to use other objects within classes?

2005-06-02 Thread Murray @ PlanetThoughtful

Hi All,

I'm using the MDB2 object to access my MySQL database. I have a number 
of classes that perform page-building activities that need db access, 
and I'm wondering what the best way to expose the MDB2 object to them is?


(Note: my development environment is PHP 5.0.3, but the production 
environment is 4.3.10. This is my first project built with 5.x local and 
4.1.x remote, so if anyone with more experience spots any fatal flaws 
where I'm using 5.x specific methods etc, I'd appreciate knowing about them)


Currently, I'm instantiating the MDB2 class in my main page, then 
passing it as an object reference to each of the other classes that 
require it.


A simple representation of my main page and a class would be:

?
 $db = connectMDB2(); // function that returns instantiated MDB2 object

 $comments = new displayComments(); // class that performs displaying 
of comments

 $comments-set_db($db); // passing the MDB2 object to the class
 $comments-doSomethingElse();
?

The displayComments() class might then look something like:

class displayComments{
private $db;

public function set_db($db){
$this-db = $db;
}

public function doSomethingElse(){
$sql = SELECT something FROM sometable;
$rs = $this-db-query($sql);
while ($row = $rs-fetchRow(MDB2_FETCHMODE_OBJECT)){
echo $row-something.br /;
}
$rs-free();
}   
}

My main page calls on at least 8 or 9 such classes as it is being built, 
and I'm concerned that I may not be handling the MDB2 object in respect 
to them in the most efficient way possible. In a way, I guess this isn't 
 specifically about the MDB2 package, but more about how to handle 
objects when they are required within classes.


I'd very much appreciate any comments or advice anyone might be able to 
give.


Much warmth,

Murray

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



Re: [PHP] Delay?

2005-06-02 Thread Chris Boget
  Has anyone else noticed significant delays in messages getting posted?
 No, no delay on my end.

At least 4hrs on my end...

thnx,
Chris

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



Re: [PHP] sanitizing get vars

2005-06-02 Thread GamblerZG

set_magic_quotes_runtime( 0 );


This is for database, not for showing data in browser. For browser you 
need to kill all unknow tags and all unknown properties of known tags. 
Afterwards, you need to prepend http:// to any urls that have unknow 
protocols. Alternatively, you can make sure that data diplayed to user 
is submitted by the same user.


Example of the former method:

http://token.by.ru/ksscripts/htmlparser6.txt

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



Re: [PHP] Delay?

2005-06-02 Thread GamblerZG

Sebastian wrote:

yea.. takes hours... sometimes 6+ or more.
i dont post that much to the list for this reason.. if it stays like 
this i'll just unsubscribe.. its pointless... this is suppose to be 
E-mail, not post office mail.


I don't understand why everyone like these mailing lists so much. 
Web-forums more convenient.


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



[PHP] Unit testing ?

2005-06-02 Thread mbneto
Hi,

I am trying the phpunit2 for unit testing but the examples found in
the documentation are few and do not address, for example, tests when
database access is involved.

Perhaps this belongs to a more general question (i.e strategies for
unit testing) so any urls, docs would be great.

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



[PHP] Exporting to MS Word or Excel

2005-06-02 Thread Miguel Guirao
Hi!!!

Are there any chances that I could export a dynamic created web page into MS
Word or Excel?
I know this can be done with PDF!!

I'm using LAMP!!

---
Miguel Guirao Aguilera
Logistica R8 TELCEL
Tel. (999) 960.7994
Cel. 9931 600.

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



Re: [PHP] sanitizing get vars

2005-06-02 Thread Chris Shiflett

Sebastian wrote:

what is a safe way to clean a post/get before echoing it.


There are two steps that you're lumping into one. Sanitizing and 
cleaning are informal terms for filtering, and this is an inspection 
process where you inspect data to be sure that it's valid. You should do 
this with any input, regardless of the source.


You need to escape data to prepare it for output. When you're sending 
data to the client (echo), you want to use htmlentities(). If possible, 
specify your character encoding (see http://php.net/htmlentities).


This talk covers these two steps in the first few slides:

http://brainbulb.com/talks/php-security-briefing.pdf (PDF)
http://brainbulb.com/talks/php-security-briefing.swf (Flash)

Hope that helps.

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

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



Re: [PHP] Using GET to build multiple sql queries

2005-06-02 Thread Greg Donald
On 6/2/05, Jack Jackson [EMAIL PROTECTED] wrote:
 Thanks for the reply, Greg,
 
 I see how that is useful. I am confused as to how I would implement it
 here. Please bear with me as I am a newbie and am now perhaps more
 confused than ever!:

Bummer, sorry.

 I'm trying to use the number given in the $_GET URL to build one piece
 of the sql:
 
 If there is anything set in the $_GET field other than ?c=[valid int] or
 ?p=[valid int] or ?s=[valid int] then I want to bounce to a plain index.

if( !(  isset( $_GET[ 'c' ] )  is_int( $_GET[ 'c' ] )
|| isset( $_GET[ 'p' ] )  is_int( $_GET[ 'p' ] )
|| isset( $_GET[ 's' ] )  is_int( $_GET[ 's' ] ) ) )
{
header( 'Location: index.php' );
exit;
}

 If it's a valid int (a positive int which corresponds to a valid row)
 then I want to set its value to the appropriate variable: either $c, $p
 or $s,

If it's in the URL it's already set as $_GET[ 'c' ], $_GET[ 'p' ], or
$_GET[ 's' ].

 and thus set the values of $fields, $from and $where.
 
 
 ?php  //IF there is a valid query by cartoon, use $c to build the SQL
  $fields = 'SELECT art.*,publisher.*,subject.*';
  $from = 'FROM art,subject
  LEFT JOIN publisher
   ON publisher.publisher_id=art.publisher_id';
  $sort = ORDER BY art.art_pub_date;
  $where = WHERE art.art_id = '$c' AND

WHERE art.art_id = '$_GET[c]'

   subject.subject_id=art.subject_id;
 ?
 
 If that were instead a $p then I would do:
 
 ?php   //IF there is a valid query by publisher, use $p to build the SQL
  $fields = SELECT art.*,publisher.*,subject.*;
  $from = FROM art,subject
  LEFT JOIN publisher
   ON publisher.publisher_id=art.publisher_id;
 $where = WHERE publisher.publisher_id=art.publisher_id AND
   art.publisher_id = '$p' AND

art.publisher_id = '$_GET[p]' AND

   subject.subject_id=art.subject_id;
 
 ?
 If that were instead an $s then I would do:
 
 ?php  //IF there is a valid query by subject, use $s to build the SQL
  $fields = SELECT art.*,publisher.*,subject.*;
  $from = FROM art,subject
  LEFT JOIN publisher
   ON publisher.publisher_id=art.publisher_id;
 $where = WHERE publisher.publisher_id=art.publisher_id AND
   art.subject_id = '1' AND
   art.subject_id=subject.subject_id;
 ?
 
 I'm sure your method works ( ;) ). If I understand it, as my friend
 Darrell said about your suggestion:
 
 '...We iterate through the array seeing if there's a submitted HTML form
 field name that matches the current database column name. If so, we add
 the column name and the value submitted in the form to a string that is
 being built into a database query.'

It's just a matter of checking for variables in the $_GET array and
doing what you need to do if they exist and are valid or not.  Do you
know about print_r() yet?

echo 'pre';
print_r( $_GET );
echo '/pre';


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



RE: [PHP] Delay?

2005-06-02 Thread Chris W. Parker
Chris Boget mailto:[EMAIL PROTECTED]
on Thursday, June 02, 2005 12:16 PM said:

 Has anyone else noticed significant delays in messages getting
 posted? No, no delay on my end. 
 
 At least 4hrs on my end...

Uhh.. I think he was joking... Take another read of his next sentence.
:)



Chris.

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



Re: [PHP] Using GET to build multiple sql queries

2005-06-02 Thread Jack Jackson

Thanks for the reply, Greg,

I see how that is useful. I am confused as to how I would implement it 
here. Please bear with me as I am a newbie and am now perhaps more 
confused than ever!:


I'm trying to use the number given in the $_GET URL to build one piece 
of the sql:


If there is anything set in the $_GET field other than ?c=[valid int] or 
?p=[valid int] or ?s=[valid int] then I want to bounce to a plain index. 
If it's a valid int (a positive int which corresponds to a valid row) 
then I want to set its value to the appropriate variable: either $c, $p 
or $s, and thus set the values of $fields, $from and $where.



?php  //IF there is a valid query by cartoon, use $c to build the SQL
$fields = 'SELECT art.*,publisher.*,subject.*';
$from = 'FROM art,subject
LEFT JOIN publisher
 ON publisher.publisher_id=art.publisher_id';
$sort = ORDER BY art.art_pub_date;
$where = WHERE art.art_id = '$c' AND
 subject.subject_id=art.subject_id;
?

If that were instead a $p then I would do:

?php   //IF there is a valid query by publisher, use $p to build the SQL
$fields = SELECT art.*,publisher.*,subject.*;
$from = FROM art,subject
LEFT JOIN publisher
 ON publisher.publisher_id=art.publisher_id;
   $where = WHERE publisher.publisher_id=art.publisher_id AND
 art.publisher_id = '$p' AND
 subject.subject_id=art.subject_id;

?
If that were instead an $s then I would do:

?php  //IF there is a valid query by subject, use $s to build the SQL
$fields = SELECT art.*,publisher.*,subject.*;
$from = FROM art,subject
LEFT JOIN publisher
 ON publisher.publisher_id=art.publisher_id;
   $where = WHERE publisher.publisher_id=art.publisher_id AND
 art.subject_id = '1' AND
 art.subject_id=subject.subject_id;
?

I'm sure your method works ( ;) ). If I understand it, as my friend 
Darrell said about your suggestion:


'...We iterate through the array seeing if there's a submitted HTML form 
field name that matches the current database column name. If so, we add 
the column name and the value submitted in the form to a string that is 
being built into a database query.'


I'm trying to see how this code lets me do that. I know it's right in 
front of my face but I cannot see how to adapt it to the task. .



Thanks in advance!!






Greg Donald wrote:

On 6/2/05, Jack Jackson [EMAIL PROTECTED] wrote:


 I'd love some help with http://hashphp.org/pastebin?pid=3443 if anyone
can...

Basically I want to make it so that, if the get in the url specifies no
query or a query to a nonexistent row, send to vanilla index. If url
specifies c= then set $c=c and use the number to build the mysql query;
same for p= and s= - if they're valid build  the query, if not kick em out.

Can anyone offer any help?



I'd iterate over the $_GET array to build the query elements.  Then
implode those elements.

$array = array();

while( list( $k, $v ) = each( $_GET ) )
{
if( $k == 'somekeynotindb' )
{
continue;
}

$array[] = $k . =' . $v . ';
}

if( $array )
{
$and = implode( ', ', $array );
}

$sql = 
SELECT *
FROM table
WHERE 1
$and
;

$query = mysql_query( $sql );




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



Re: [PHP] Using GET to build multiple sql queries

2005-06-02 Thread Jack Jackson

SORRY - one small correction below:

SNIP

If that were instead an $s then I would do:

?php  //IF there is a valid query by subject, use $s to build the SQL
$fields = SELECT art.*,publisher.*,subject.*;
$from = FROM art,subject
LEFT JOIN publisher
 ON publisher.publisher_id=art.publisher_id;
   $where = WHERE publisher.publisher_id=art.publisher_id AND
 art.subject_id = '$s' AND
 art.subject_id=subject.subject_id;
?

/SNIP
I had accidentally put a number 1 in place of the $s in the above 
example. Apologies for the extra mail and thanks in advance.





Greg Donald wrote:

On 6/2/05, Jack Jackson [EMAIL PROTECTED] wrote:


 I'd love some help with http://hashphp.org/pastebin?pid=3443 if anyone
can...

Basically I want to make it so that, if the get in the url specifies no
query or a query to a nonexistent row, send to vanilla index. If url
specifies c= then set $c=c and use the number to build the mysql query;
same for p= and s= - if they're valid build  the query, if not kick em out.

Can anyone offer any help?



I'd iterate over the $_GET array to build the query elements.  Then
implode those elements.

$array = array();

while( list( $k, $v ) = each( $_GET ) )
{
if( $k == 'somekeynotindb' )
{
continue;
}

$array[] = $k . =' . $v . ';
}

if( $array )
{
$and = implode( ', ', $array );
}

$sql = 
SELECT *
FROM table
WHERE 1
$and
;

$query = mysql_query( $sql );




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



Re: [PHP] Best way to use other objects within classes?

2005-06-02 Thread Greg Donald
On 6/2/05, Murray @ PlanetThoughtful [EMAIL PROTECTED] wrote:
 private $db;

PHP4 doesn't have member visibility.

-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



[PHP] RE: Questionary Development - Continued

2005-06-02 Thread Allan, David (ThomasTech)
I've just been looking at phpSurveyor. Would that help at all?

It's PHP, with mySQL database . . .


 -Original Message-
 From: ...helmut [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, May 31, 2005 4:35 PM
 To: php-general@lists.php.net
 Subject: Questionary Development - Continued
 
 
 Hello All,
 
 Thank you for all the wonderful ideas, there are so many 
 things that can be
 over look when working by yourself.
 
 When I asked help for a questionary, in reallity I meant a 
 long form. With
 that said I apologize for having some people in mind more 
 like a question
 answer type of thing(school test and similar).
 
 So, after reviewing this project I have come out with the 
 final descicion...
 
 In order to fill out a form the user must have an UN and 
 PASS, so that I can
 write their answers to the DB as they are filling out the 
 form, reason for
 this is in case they have to stop in the middle of the form 
 they can come
 back on a later time to finish with their UN and PASS, they 
 should be able
 to continue their form or to start all over.
 
 I decided to divide the forms into 5 different sections, and 
 as some one
 suggested divide the sections by groups so people can fill 
 out the form and
 concentrate in the section they are working on.
 
 Similar to when you have to fill out your taxes online:
 https://taxes.hrblock.com/hrblock/login/LoginRegistration.aspx
 
 the difference is that this has been done with ASP (ewww! :) )
 
 Thank you everyone for your input. Any more suggestions are welcome
 
 -- 
 ...helmut
 helmutgranda.com
 
 
 
 ...helmut [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 I have a form that contains 100 questions. To make it easier 
 on the user, I
 will divide it into 5 sections (20 questions per section), 
 then all the
 information will be written to a db. What is the best way to 
 carry along
 through the pages the information that has already been 
 submitted? Cookies?
 Writing to a DB after each section? Session Variables?
 
  I read that writing to a database as i go along could be 
 too much of a
  hazzle for the db, specially if I have multiple people 
 filling out the
  form at the same time.
 
  TIA
 
  -- 
  helmut
  helmutgranda.com 
 

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



Re: [PHP] Delay?

2005-06-02 Thread Greg Donald
On 6/2/05, GamblerZG [EMAIL PROTECTED] wrote:
 I don't understand why everyone like these mailing lists so much.
 Web-forums more convenient.

What's keeping you..


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



Re: [PHP] Best way to use other objects within classes?

2005-06-02 Thread Murray @ PlanetThoughtful

Greg Donald wrote:

On 6/2/05, Murray @ PlanetThoughtful [EMAIL PROTECTED] wrote:


   private $db;



PHP4 doesn't have member visibility.



Hi Greg,

Thanks for this tip!

Regards,

Murray

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



Re: [PHP] Using GET to build multiple sql queries

2005-06-02 Thread Jack Jackson

Greg, thank you for all this... See below

Greg Donald wrote:

On 6/2/05, Jack Jackson [EMAIL PROTECTED] wrote:


Thanks for the reply, Greg,

I see how that is useful. I am confused as to how I would implement it
here. Please bear with me as I am a newbie and am now perhaps more
confused than ever!:



Bummer, sorry.

Twasn't you; were me.





I'm trying to use the number given in the $_GET URL to build one piece
of the sql:

If there is anything set in the $_GET field other than ?c=[valid int] or
?p=[valid int] or ?s=[valid int] then I want to bounce to a plain index.



if( !(  isset( $_GET[ 'c' ] )  is_int( $_GET[ 'c' ] )
|| isset( $_GET[ 'p' ] )  is_int( $_GET[ 'p' ] )
|| isset( $_GET[ 's' ] )  is_int( $_GET[ 's' ] ) ) )
{
header( 'Location: index.php' );
exit;
}


Of course, that almost did it. But I wanted to do it it *weren't* an 
int. I put a ! in front and that works like a charm!




If it's a valid int (a positive int which corresponds to a valid row)
then I want to set its value to the appropriate variable: either $c, $p
or $s,



If it's in the URL it's already set as $_GET[ 'c' ], $_GET[ 'p' ], or
$_GET[ 's' ].


I get it. Thanks for that. Including it in the sql didn't work as you 
suggested:




?php  //IF there is a valid query by cartoon, use $c to build the SQL
$fields = 'SELECT art.*,publisher.*,subject.*';
$from = 'FROM art,subject
LEFT JOIN publisher
 ON publisher.publisher_id=art.publisher_id';
$sort = ORDER BY art.art_pub_date;
$where = WHERE art.art_id = '$c' AND



WHERE art.art_id = '$_GET[c]'


I guess it was missing a print command or something. I did this up top 
though:


$c = intval($_GET['c']);
$p = intval($_GET['p']);
$s = intval($_GET['s']);

and then did it as I had it in the sample above and it worked like a 
charm, too.






 subject.subject_id=art.subject_id;
?

If that were instead a $p then I would do:

?php   //IF there is a valid query by publisher, use $p to build the SQL
$fields = SELECT art.*,publisher.*,subject.*;
$from = FROM art,subject
LEFT JOIN publisher
 ON publisher.publisher_id=art.publisher_id;
   $where = WHERE publisher.publisher_id=art.publisher_id AND
 art.publisher_id = '$p' AND



art.publisher_id = '$_GET[p]' AND



 subject.subject_id=art.subject_id;

?
If that were instead an $s then I would do:

?php  //IF there is a valid query by subject, use $s to build the SQL
$fields = SELECT art.*,publisher.*,subject.*;
$from = FROM art,subject
LEFT JOIN publisher
 ON publisher.publisher_id=art.publisher_id;
   $where = WHERE publisher.publisher_id=art.publisher_id AND
 art.subject_id = '1' AND
 art.subject_id=subject.subject_id;
?

I'm sure your method works ( ;) ). If I understand it, as my friend
Darrell said about your suggestion:

'...We iterate through the array seeing if there's a submitted HTML form
field name that matches the current database column name. If so, we add
the column name and the value submitted in the form to a string that is
being built into a database query.'



It's just a matter of checking for variables in the $_GET array and
doing what you need to do if they exist and are valid or not.  Do you
know about print_r() yet?

echo 'pre';
print_r( $_GET );
echo '/pre';


I did and thank you. This is close to working, though I still have to 
deal with what happens once I run those queries. But thanks for sorting 
out that mess for me,. I really appreciate it.









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



[PHP] How to find random records in a subset?

2005-06-02 Thread Brian Dunning
I am using a routine to find 50 random records in a large MySQL  
database (about a million records) where I generate a list of 50  
random unique ID's, and then use MySQL's in command to find them. I  
can't use order by rand() due to its performance hit.


But I have to take it one more step: I want to first limit my found  
set to those matching a different search criteria, and then find 50  
of those.


Anyone? Can this be done all within MySQL, or is it going to require  
some humongo PHP arrays?


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



Re: [PHP] Exporting to MS Word or Excel

2005-06-02 Thread tg-php
To export it exactly as displayed (like when you print to a virtual printer to 
generate a PDF) might be tricky, but you can definitely create Excel and I 
believe Word files without even having Excel or Word installed.   If you DO 
have Excel or Word installed on your server, then you can always use a COM 
connection to handle this.

First, maybe check out the Excel Writer PEAR package.  Here's a link to a post 
I made about it a while ago with instructions on how to install it:

http://marc.theaimsgroup.com/?l=php-generalm=111409575703230w=2

Excel Writer uses another PEAR package called OLE which is used to generate 
older format MS Office files in general.  Both can be found at 
http://pear.php.net


Also, try searching the archives, I know this question has been asked many 
times (even recently) and I'm sure you'll find some good stuff in there.

PHP-General archives:
http://marc.theaimsgroup.com/?l=php-general

PHP-Windows archives:
http://marc.theaimsgroup.com/?l=php-windows

PHP-Databases archives (never know eh?):
http://marc.theaimsgroup.com/?l=php-db

And of course, the links to all these can be found on the PHP mailing lists 
page:
http://www.php.net/mailing-lists.php


Good luck!

-TG


= = = Original message = = =

Hi!!!

Are there any chances that I could export a dynamic created web page into MS
Word or Excel?
I know this can be done with PDF!!

I'm using LAMP!!

---
Miguel Guirao Aguilera
Logistica R8 TELCEL
Tel. (999) 960.7994
Cel. 9931 600.

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


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP] Delay?

2005-06-02 Thread Danny Brow
On Thu, 2005-06-02 at 15:32 -0400, GamblerZG wrote:
 Sebastian wrote:
  yea.. takes hours... sometimes 6+ or more.
  i dont post that much to the list for this reason.. if it stays like 
  this i'll just unsubscribe.. its pointless... this is suppose to be 
  E-mail, not post office mail.
 
 I don't understand why everyone like these mailing lists so much. 
 Web-forums more convenient.
 

Convenient for your maybe, I personally hate web forums. 



signature.asc
Description: This is a digitally signed message part


[PHP] Re: What Works Works Validator

2005-06-02 Thread JB


Simple, blank page with just content, thats the only true way,
Anyway why you wanna be backward compatible that far is beyond me cus 
they handle HTML even worse so its a losing battle!,

use the CSS @import
rule for style sheets and older browsers will simply ignore the CSS, you 
could then just give your page a basic look that older browsers could 
handle well while overriding the HTML styling with CSS for newer browsers.


Also answer to your other question... try use PHP's built in validator 
tool to auto replace any errors in your code.


Also table height, no other way I know sorry,



HTH





Richard Lynch wrote:

This is OT in that it's more about HTML than PHP, but solutions involving
PHP would be particularly welcome.

After playing with the W3C validator again for an hour or so...

The thing is, I really want to be backwards compatible with ancient
browsers.  Like, REALLY ancient.

Like, say, going back as far as 3.0 browsers.

So, relying on CSS to do my layout is a non-option.  It's just not there.

But I LIKE the idea of having HTML validated to catch tag imbalance, typos
in attributes, and maybe even layout problems in weird versions of
browsers (eg Netscape 4.7 or IE on the Mac).

I don't really want to be compatible with the W3C standards, however,
since the penalty is layout that just plain doesn't work in ancient
browsers.

For example, I simply can't validate with a 100% height table, but that's
the only way to get the layout I want on both ancient and current
browsers.

Does anybody know of a What Works Works Validator which checks for
maxiumum browser compatibility rather than the W3C standard?

Or even just some tools that check HTML tag balancing, and maybe
spell-check attributes.  It has to be post-PHP URL-based on not IDE/editor
based, unless there's a PHP interpreter built into the editor to figure
out the HTML I'm spitting out...

Failing all that, does anybody know a non-CSS way to get a table to be
100% tall so I can get rid of this last error?

Or, perhaps, a way between JavaScript and PHP to calculate how much
white-space I need to make a spacer image to be the right height?

Or...

PS
Please let's not start a flame war about browser versions, browser makers,
standards-compliance, etc.

You can do whatever you want ; I just happen to believe that backwards
compatibility is more important than compliance with standards that aren't
even implemented correctly at this time.

So if your answer doesn't actually match my question, just hit delete 
Thanks.




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



[PHP] Mailing list delays

2005-06-02 Thread Rasmus Lerdorf
We found a problem caused by a recent disk failure that wiped out a
named pipe qmail needed.  I am hoping the mailing list delays should be
fixed now.

-Rasmus

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



[PHP] Re: What Works Works Validator

2005-06-02 Thread JB05UK
A small example, using the code below all older browser who cant 
understand CSS will ignore it because its within a comment block...


style type=text/css
!--
@import url(MyStyleSheet.css);
--
/style

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



[PHP] Re: what is -- $this variable - $this other variable -- means?

2005-06-02 Thread JB05UK

http://php.net/manual/en/language.oop.php

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



Re: [PHP] sanitizing get vars

2005-06-02 Thread Marek Kilimajer

Sebastian wrote:

what is a safe way to clean a post/get before echoing it.
example. input form, user enters some text, hits enter.

.. next page i echo what they entered.
right now i just run the variables passed by htmlentities() which 
preseves any html. is that acceptable?




You might also want to use stripslashes() if magic_quotes_gpc is on, so 
the data is not double escaped.


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



[PHP] Re: php forum and (almost certainly 0T) client editor

2005-06-02 Thread JB05UK

Hello, I can answer your second question...

Frames can be used to achieve the effect of two seperate windows, one 
can refresh while the other stays as-is.


For a client editor...
Some javascript to add tags on the client side would be fairly simple to 
create, just create some custom tags for display to clients then when 
submitted use PHP's str_replace function to search for your custom tags 
then replace with some HTML before it hits the forums,



James





Ryan A wrote:

Hey guys (and girl...as we have one on the list...(that i know of)),

Can anybody recommend a real bare bones forum that i can modify
or
a tutorial for creating a forum
or
URLs/Classes etc to help me create a simple forum?

I checked on google but I couldnt find any tutorials or code, went to
hot-scripts and saw a   _c r a p l o a d_ of forums (for free and otherwise)
but I have a client who insists I build him a forum which must fall
_exactly_
to his specifications and work of our currently registered users database.

Worse scenario, I will dl a few of the forums from hotscrpts and go through
each of their code...but I would like to avoid that if anyone can give me a
better option.



2nd question
I will need a kind of client editor for when people write their messages
into the forum,
eg: make this bold and that italics and that centered and that with an image
and so on
I had actually seen a (dhtml, I think) form some time back where you could
preview your
message at the side as you made changes...somewhat like what google has for
their
ad-cents accounts where you can change the colors of your ad and immediatly
it shows the
changes at the side in a box.
I remember sometime back someone posting some WYSIWYG kind of editors which
loads
on the clients machine with just a textbox and the buttons to go bold,
italics,centered etc
unfortunatly looking into the archives i cant find it.

Thanks,
Ryan





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



Re: [PHP] Mailing list delays

2005-06-02 Thread Sebastian

Thanks.

*test*

Rasmus Lerdorf wrote:


We found a problem caused by a recent disk failure that wiped out a
named pipe qmail needed.  I am hoping the mailing list delays should be
fixed now.

-Rasmus

 



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



Re: [PHP] Delay?

2005-06-02 Thread dan

Danny Brow wrote:

On Thu, 2005-06-02 at 15:32 -0400, GamblerZG wrote:


Sebastian wrote:


yea.. takes hours... sometimes 6+ or more.
i dont post that much to the list for this reason.. if it stays like 
this i'll just unsubscribe.. its pointless... this is suppose to be 
E-mail, not post office mail.


I don't understand why everyone like these mailing lists so much. 
Web-forums more convenient.





Convenient for your maybe, I personally hate web forums. 


(six hours later of course)

I agree.

Thanks
-dant

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



Re: [PHP] Mailing list delays

2005-06-02 Thread Sebastian

wow, got that in 20 seconds.. can we go for a record? ;)

Sebastian wrote:


Thanks.

*test*

Rasmus Lerdorf wrote:


We found a problem caused by a recent disk failure that wiped out a
named pipe qmail needed.  I am hoping the mailing list delays should be
fixed now.

-Rasmus

 





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



[PHP] Re: Can't Get PHP to work

2005-06-02 Thread JB05UK
 You need to insert these two lines to your Apache httpd.conf 
configuration file to set up the PHP module for Apache 2.0:


Example 6-6. PHP and Apache 2.0 as Module


# For PHP 5 do something like this:
LoadModule php5_module c:/php/php5apache2.dll
AddType application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir C:/php













Subscriber wrote:

Hi,

I sure hope someone here can help me.  I spent the entire day yesterday 
and most of the evening setting up a webserver on my Windows 2000 Pro 
system. 
I've got PHP 5.04, MySQL 4.1.12, ActivePerl 5.8.6, Java Runtime 
Environment, Tomcat 5.5.9, ZendOptimizer 2.5.10, MyODBC 3.5.11 and 
phpMyAdmin 2.6.2 all installed.


 From what I can tell, all is working well except PHP and phpMyAdmin.

I added PHP to my path like this:

C:\Perl\bin\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\php;C:\Apache2\bin;C:\mysql\bin;C:\php\dlls;C:\Program 
Files\Common Files\Ulead Systems\MPEG;C:\Program Files\Zone 
Labs\ZoneAlarm\MailFrontier


I've got a copy of php.ini in both my c:/php directory and in 
c://winnt.  I've listed my user directory as c:/apache/apache2/htdocs 
and I've placed phpmyadmin in htdocs.


But when I try to view a php page I get an error or page cannot be 
displayed.  On a couple of occassions I viewed the raw php data in my 
browser.


Also, when I try to add a php extension using LoadModule in my 
httd.conf file I get an error loading Apache telling me that the file 
cannot be found (but I've verified it exists - like php5apache.dll and 
php5ts.dll).


Can someone please help me figure out where I'm screwing up at?

Thanks in advance!

Edited to say I'm getting Closer!!!

Now when I go to 
[url=http://localhost/phpmyadmin]http://localhost/phpmyadmin[/url] I get 
the following info:


cannot load mysqli extension;
please check PHP configuration
[u]Documentation[/u]

And the documentation says:
[b][1.20] I receive the error cannot load MySQL extension, please check 
PHP Configuration. [/b]To connect to a MySQL server, PHP needs a set of 
MySQL functions called MySQL extension. This extension may be part of 
the PHP distribution (compiled-in), otherwise it needs to be loaded 
dynamically. Its name is probably mysql.so or php_mysql.dll. phpMyAdmin 
tried to load the extension but failed.


Usually, the problem is solved by installing a software package called 
PHP-MySQL or something similar.


I have tried using both mysql and mysqli in config.inc.php (phpmyadmin 
config file) and either way I get the same error message.  And in 
php.ini I have enabled the following extensions:


extension=php_mysql.dll
extension=php_mysqli.dll



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



Re: [PHP] Quick q, most prolly 0T

2005-06-02 Thread Chris Shiflett

Ryan A wrote:

Basically I am waiting for the client to pay me...till he does,
I am displaying the index page which is a under construction
page...but he also wants to play with the site so I need to
direct all calls to main.php...


You want to only show an under construction page, but you also want the 
client to be able to use the application? I don't understand how these 
conditions can coexist.


Can you clarify?

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

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



[PHP] Site Design Strategy

2005-06-02 Thread asinning

This is my first post to this group.  I've been trying to figure this
out on my own, but I keep running into complications, so I've decided
to get some help.  Much thanks for any help!

I've been writing php server application for a couple of years, but now
I'm turning my attention to re-building our company's aging website.
This is a big project and is going to require a solid foundation.

At the crux of this post is the following question:  How do you develop
a very robust, dynamic web-site, but also allow non-technical people to
contribute? There must be an easier way.

Here are my working assumptions and my strategy.  Please help me if I'm
thinking down the wrong path.

Assumptions:

1) Non-technical people in the company need to be able to build pages,
and they should be able to post their pages without bothering me.  We
have a tech-support person who will be able to help them, but she has
zero programming knowledge and only a superficial understanding of
HTML.

2) Every page needs to reside within he shell of the web site.  This
includes

  header(the top-level menu)
  left-side menu (a dynamic, context-specific menu)
  content (this is what the non-technical people will produce)
  footer (your standard fare text-based links)

3) I don't want to use frames, and I don't want to use Dreamweaver
templates.

Strategy:  Currently, I am working on the following model:

 There is a top-level index.php page.  This is the target of EVERY
page on the site.

 The page that gets loaded in depends on the parameters of
query-string.  It's very simple, if the query string reads
?target=products/gsp, then my php will look for a site-relative
document such as products/gsp.htm OR products/gsp/index.hml.  Then,
this document will get included as the content in my shell.

 Well, this works to a degree, but it requires that people use
site-relative paths for all of their graphics and links, which is
way, way to much to ask.  After all, people are using WYSIWIG editors
such as Dreamweaver and even Word to build their pages.  Typically,
site-relative paths don't work in these environments.  They shouldn't
need to upload their document to preview it.

 It also requires that they put their page within a 550 pixel wide
-td- tag.  I'd love to drop that requirement.

So, now I considering the following:  A parser that will convert any
content into includable form.  Relative paths will be translated to
the site-root, etc.  I'm a bit stuck here.

There's got to be a better way.

Thanks.

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



[PHP] Re: Unit testing ?

2005-06-02 Thread Matthew Weier O'Phinney
* mbneto [EMAIL PROTECTED]:
 I am trying the phpunit2 for unit testing but the examples found in
 the documentation are few and do not address, for example, tests when
 database access is involved.

 Perhaps this belongs to a more general question (i.e strategies for
 unit testing) so any urls, docs would be great.

Jason Sweat covered this at php|Tropics, using SimpleTest as the unit
testing framework. I use phpt unit tests (developed for testing php
itself, and used by the PEAR project for regression tests). The
principles are the same regardless of framework, however.

The fundamental problem is: your code may depend on the results of a DB
operation -- it's primary purpose may even be to perform a DB operation.
While you can test the code, you still need to test whether or not your
code can successfully perform the DB operation as well. A common problem
I find is that I'm building SQL on the fly -- and that process may build
shoddy SQL. It may be building exactly what I designed it to do, but the
RDBMS will never be able to actually utilize the SQL I build. Tests can
help catch these issues.

Basically, when testing code that interacts with a database, you've got
two basic strategies: (1) test against the DB, or (2) use mock objects.
The latter is a tricky subject, as it assumes you're using a DB
abstraction layer, and because you then have to mimic how that
abstraction layer works. Basically, you end up doing a lot of code
simply to test.

Which brings us back to (1), test against the DB. 

The way to do this is to have some code that sets up and tears down a
TEST database -- not the one with your live data. It should likely
create and populate any tables you need, and then be able to tear them
down again. The reason behind this is that you can then have a set of
consistent data to test against -- once you run tests, chances are
likely that you've altered the data.  Each test you run should tear down
the DB and then recreate and/or repopulate it.

If you use the phpt unit tests, the place to do this is in your
setup.php.inc file. I then create a file with the raw SQL for
setting up and populating a test table, slurp it in with
file_get_contents, and pass it on to the DB from within a function in
that setup file. Then another function can truncate or delete all
records from the tables utilized.

The code within the test might then look like this:

?php
include_once dirname(__FILE__) . '/setup.php.inc';

setupDb();
// do a test
teardownDb();

setupDb();
// do another test
teardownDb();
?

That's kind of a long-winded answer to your question, but it's not
something you see a lot of information on. I hope that it helps.

-- 
Matthew Weier O'Phinney   | WEBSITES:
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED] | http://vermontbotanical.org

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



[PHP] Re: Best way to use other objects within classes?

2005-06-02 Thread Matthew Weier O'Phinney
* Murray @ PlanetThoughtful [EMAIL PROTECTED]:
snip
 (Note: my development environment is PHP 5.0.3, but the production 
 environment is 4.3.10. This is my first project built with 5.x local and 
 4.1.x remote, so if anyone with more experience spots any fatal flaws 
 where I'm using 5.x specific methods etc, I'd appreciate knowing about them)
snip
 ?
   $db = connectMDB2(); // function that returns instantiated MDB2 object

   $comments = new displayComments(); // class that performs displaying 
 of comments
   $comments-set_db($db); // passing the MDB2 object to the class

   $comments-doSomethingElse();
 ?

 The displayComments() class might then look something like:

 class displayComments{
   private $db;

   public function set_db($db){
   $this-db = $db;
   }

The above is the nut you need, and you're doing it right. As Greg
pointed out, you'll need to change that from 'private $db' to 'var $db'
as PHP4 doesn't have member visibility. However, you're correctly
passing by reference -- something required by PHP4 if you want to share
the same object amongst several classes. (In PHP5, objects are passed by
reference by default, and the above code will actually generate some
notices -- but since you're developing for PHP4, you can safely ignore
them).

-- 
Matthew Weier O'Phinney   | WEBSITES:
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED] | http://vermontbotanical.org

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



RE: [PHP] Delay?

2005-06-02 Thread mayo
My average post takes 2+ hours.

mayo

-Original Message-
From: Chris W. Parker [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 02, 2005 4:22 PM
To: Chris Boget; Jason Sweeney
Cc: php-general@lists.php.net
Subject: RE: [PHP] Delay?

Chris Boget mailto:[EMAIL PROTECTED]
on Thursday, June 02, 2005 12:16 PM said:

 Has anyone else noticed significant delays in messages getting
 posted? No, no delay on my end. 
 
 At least 4hrs on my end...

Uhh.. I think he was joking... Take another read of his next sentence.
:)



Chris.

-- 
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] Newbie - Request interface for PHP 5 website

2005-06-02 Thread [EMAIL PROTECTED]

For PHP 4.x sites I used my index page to capture the HTTP request and use a
switch statement to call the content or task based on the $_GET and $_POST
arrays.  That was very inefficient and the Switch case became totally
unmanageable along with the rest of the site.

I am re-designing the site using PHP5 and OO design patterns like Composite
and Builder as an example.  I know these are basic patterns but its a start.
Anyway I am not sure how to capture the HTTP request and pass it to the
relevant objects.  Is there a generic Œway¹ developers process the request
to call the classes and generate the needed objects in PHP5?

Thanks for your help!

T


Re: [PHP] Mailing list delays

2005-06-02 Thread Danny Brow
On Thu, 2005-06-02 at 17:15 -0700, Rasmus Lerdorf wrote:
 We found a problem caused by a recent disk failure that wiped out a
 named pipe qmail needed.  I am hoping the mailing list delays should be
 fixed now.
 
 -Rasmus
 
test


signature.asc
Description: This is a digitally signed message part


Re: [PHP] Japanese with UTF-8 and mysql

2005-06-02 Thread Mark Sargent

Richard Davey wrote:


Hello Mark,

Thursday, June 2, 2005, 4:18:30 AM, you wrote:

MS ?php
MS session_start();
MS include(database.php);
?

I would recommend setting UTF-8 as the Content-type via PHP itself:
header('Content-type: UTF-8') - do it as one of the first things when
you're ready to output the HTML.
 


Yes, have already tried it. No success.


MS !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN
MS http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;

This may well be a cause of the problem - your HTML doesn't look like
it's XTHML Strict compatible at all, so browsers are going to
re-render it (IE into Quirks mode). I would remove the DocType for now
or fix the mark-up errors.
 


Can't c that as it, as static J renders fine.


MS ?php
MS if (isset($_REQUEST[product_id])) {
MS$product_id = $_REQUEST[product_id];

See the previous reply about why this isn't safe, but also it should
be: $_REQUEST['product_id'] (note the quotes) to avoid PHP scanning
for constants.
 

Ok, will look into that stuff a little more, once I get J rendering 
correctly.



MS for ($i=0; $i$num; $i++){
MS echo tr align=\center\tdPRODUCT 
MS NAME/tdtd.$rows['product_name']./tdbrtr 


From a code point of view this is correct. Let's check a few obvious
things: does PHP have the mb extension installed?


Yes, installed.


If so what is the
default character-set in php.ini?

Best regards,

Richard Davey
 


httpd.conf:

AddDefaultCharset utf-8
AddCharset ISO-8859-1  .iso8859-1  .latin1
AddCharset ISO-8859-2  .iso8859-2  .latin2 .cen
AddCharset ISO-8859-3  .iso8859-3  .latin3
AddCharset ISO-8859-4  .iso8859-4  .latin4
AddCharset ISO-8859-5  .iso8859-5  .latin5 .cyr .iso-ru
AddCharset ISO-8859-6  .iso8859-6  .latin6 .arb
AddCharset ISO-8859-7  .iso8859-7  .latin7 .grk
AddCharset ISO-8859-8  .iso8859-8  .latin8 .heb
AddCharset ISO-8859-9  .iso8859-9  .latin9 .trk
AddCharset ISO-2022-JP .iso2022-jp .jis
AddCharset ISO-2022-KR .iso2022-kr .kis
AddCharset ISO-2022-CN .iso2022-cn .cis
AddCharset Big5.Big5   .big5
# For russian, more than one charset is used (depends on client, mostly):
AddCharset WINDOWS-1251 .cp-1251   .win-1251
AddCharset CP866   .cp866
AddCharset KOI8-r  .koi8-r .koi8-ru
AddCharset KOI8-ru .koi8-uk .ua
AddCharset ISO-10646-UCS-2 .ucs2
AddCharset ISO-10646-UCS-4 .ucs4
AddCharset UTF-8   .utf8

php.ini:

output_handler = mb_output_handler

;; Set HTTP header charset
default_charset  = UTF-8

[mbstring]
; language for internal character representation.
mbstring.language = Neutral

; internal/script encoding.
; Some encoding cannot work as internal encoding.
; (e.g. SJIS, BIG5, ISO-2022-*)
mbstring.internal_encoding = UTF-8

; http input encoding.
mbstring.http_input = auto

; http output encoding. mb_output_handler must be
; registered as output buffer to function
mbstring.http_output = UTF-8

; enable automatic encoding translation accoding to
; mbstring.internal_encoding setting. Input chars are
; converted to internal encoding by setting this to On.
; Note: Do _not_ use automatic encoding translation for
;   portable libs/applications.
mbstring.encoding_translation = On

; automatic encoding detection order.
; auto means
mbstring.detect_order = auto

; substitute_character used when character cannot be converted
; one from another
mbstring.substitute_character = none

Cheers.

Mark Sargent.

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