Re: [PHP] convert (windows-1250) to (utf-8)

2007-08-12 Thread Alain Roger
and why not :
$out = iconv('windows-1250','UTF-8', $in); ???

Alain

On 8/12/07, brian [EMAIL PROTECTED] wrote:

 Alain Roger wrote:
  Hi,
 
  I import a csv file (which includes characters from windows-1250
 charset)
  to postgreSQL database which is in UTF-8.
  How can i convert windows-1250 to utf-8 charset ?
 

 Try the iconv functions:

 http://www.php.net/manual/en/function.iconv.php

 $out = iconv('ISO-8859-2', 'UTF-8', $in);

 This page may be of use, as well:
 http://en.wikipedia.org/wiki/Windows-1250

 Windows-1250 is *similar* to ISO-8859-2 ...

 brian

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




-- 
Alain

Windows XP SP2
PostgreSQL 8.2.3
Apache 2.2.4
PHP 5.2.3


[PHP] PostgreSQL and select nextval

2007-08-12 Thread Alain Roger
Hi,

I'm getting an error message when i run the following SQL request :
$sql = INSERT INTO tmp_importedxls (rec_id, publisher) VALUES (SELECT
nextval('tmp_importedxls_rec_id_seq'),'$pb');

Error in SQL query: ERROR: syntax error at or near SELECT LINE 2: VALUES
(SELECT nextval('tmp_importedxls_rec_id_seq'),' ^

I have the feeling that we can not use the select nextval(...) SQL request
in an INSERT INTO one under PHP.
Is it true?

thanks
-- 
Alain

Windows XP SP2
PostgreSQL 8.2.3
Apache 2.2.4
PHP 5.2.3


[PHP] What's is the needed configuration to enable SOAP?

2007-08-12 Thread Brice
Hello all,

I have a little problem with Soap. I programmed a script which works
well on all server except one. I had an 'HTTP Error : Couldn't open
socket connection to server' Too bad for me it's the main one.

I wonder if  there is a configuration problem? I just saw that socket
is disabled on the main server. Is soap extension needs to enable
socket? Google and php documentation said nothing about that.

Thanks in advance for your help.

Brice Favre

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



Re: [PHP] manual vs. meta refresh

2007-08-12 Thread Tijnema
On 8/12/07, Robert Cummings [EMAIL PROTECTED] wrote:
 On Sat, 2007-08-11 at 22:11 -0500, Richard Lynch wrote:
  You don't do it there.
 
  You do whatever it is you have to do in the URL before you re-direct.
 
  Though I guess if you want different output on that page, you would
  need to set something somewhere, be it session, database, or a cookie.

 I think you're missing the point Richard. Yes you can detect the meta
 redirect or manual refresh using your method. But only the first can be
 detected because when the page is served up to the browser again either
 the special meta redirect URL is active, non special normal URL is
 active, or a super special I'm redirecting but don't count me URL is
 active. Now what happens when the user does a manual refresh again? It's
 not about output, it's about detecting subsequent refreshes and
 determining again the source of the refresh. You must have some kind of
 session tracking system in place, be it a regular session or a database
 query that can check if an ID was already detected that indicates to
 discount the page load from any statistics.

 Cheers,
 Rob.

I think you Rob missed a part of Richard's first reply:
You would then need to re-direct back to the URL *without* the GET
parameter from_meta_tag=1 so that their refresh button would not be
going to that URL with from_meta_tag in it.

Tijnema
-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



Re: [PHP] convert (windows-1250) to (utf-8)

2007-08-12 Thread Tijnema
On 8/12/07, Alain Roger [EMAIL PROTECTED] wrote:
 and why not :
 $out = iconv('windows-1250','UTF-8', $in); ???

 Alain

Did you test if that works? I doubt it, as windows-1250 isn't listed
on the homepage of libiconv:
http://www.gnu.org/software/libiconv/

Tijnema

 On 8/12/07, brian [EMAIL PROTECTED] wrote:
 
  Alain Roger wrote:
   Hi,
  
   I import a csv file (which includes characters from windows-1250
  charset)
   to postgreSQL database which is in UTF-8.
   How can i convert windows-1250 to utf-8 charset ?
  
 
  Try the iconv functions:
 
  http://www.php.net/manual/en/function.iconv.php
 
  $out = iconv('ISO-8859-2', 'UTF-8', $in);
 
  This page may be of use, as well:
  http://en.wikipedia.org/wiki/Windows-1250
 
  Windows-1250 is *similar* to ISO-8859-2 ...
 
  brian
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


 --
 Alain
 
 Windows XP SP2
 PostgreSQL 8.2.3
 Apache 2.2.4
 PHP 5.2.3



-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



Re: [PHP] convert (windows-1250) to (utf-8)

2007-08-12 Thread Alain Roger
I've tested it and it works well.
i got some issue when i used ISO-8859-2.

Al

On 8/12/07, Tijnema [EMAIL PROTECTED] wrote:

 On 8/12/07, Alain Roger [EMAIL PROTECTED] wrote:
  and why not :
  $out = iconv('windows-1250','UTF-8', $in); ???
 
  Alain

 Did you test if that works? I doubt it, as windows-1250 isn't listed
 on the homepage of libiconv:
 http://www.gnu.org/software/libiconv/

 Tijnema
 
  On 8/12/07, brian [EMAIL PROTECTED] wrote:
  
   Alain Roger wrote:
Hi,
   
I import a csv file (which includes characters from windows-1250
   charset)
to postgreSQL database which is in UTF-8.
How can i convert windows-1250 to utf-8 charset ?
   
  
   Try the iconv functions:
  
   http://www.php.net/manual/en/function.iconv.php
  
   $out = iconv('ISO-8859-2', 'UTF-8', $in);
  
   This page may be of use, as well:
   http://en.wikipedia.org/wiki/Windows-1250
  
   Windows-1250 is *similar* to ISO-8859-2 ...
  
   brian
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
 
  --
  Alain
  
  Windows XP SP2
  PostgreSQL 8.2.3
  Apache 2.2.4
  PHP 5.2.3
 


 --
 Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info




-- 
Alain

Windows XP SP2
PostgreSQL 8.2.3
Apache 2.2.4
PHP 5.2.3


[PHP] very strange behavior.... incomplete query performed

2007-08-12 Thread Alain Roger
Hi,

I'm still working on importing CSV file content (20.000 records) to database
PostgreSQL.

when i run the query, once i stored into my table  5218 records, another
time 5231 another time 4713 and so on
every time the amount of records imported to DB is different.

Do you have any idea from where it could come ?

Here is my PHP code :

 while (($data = fgetcsv($handle, 1000, ,)) !== FALSE)
 {
 $num = count($data);

 if($row1)
 {

 $charsetIN ='windows-1250';
 $charsetOUT = 'UTF-8';

 $publisher = iconv($charsetIN, $charsetOUT,
 $data[0]);
 $program = iconv($charsetIN, $charsetOUT,
 $data[1]);
 $version = iconv($charsetIN, $charsetOUT,
 $data[2]);
 $path=iconv($charsetIN,
 $charsetOUT, $data[4]);
 $path = str_replace(\\,,$path);
 $licensing_file = iconv($charsetIN, $charsetOUT,
 $data[5]);
 $barcode = iconv($charsetIN, $charsetOUT,
 $data[6]);
 $pcinfo_id= iconv($charsetIN, $charsetOUT,
 $data[8]);

 $date_audit= iconv($charsetIN, $charsetOUT,
 trim(str_replace( ,,$data[11])));

 $locality = iconv($charsetIN, $charsetOUT,
 $data[13]);
 $area= iconv($charsetIN,
 $charsetOUT, $data[12]);
 $username= iconv($charsetIN, $charsetOUT,
 $data[14]);
 $personal_number= iconv($charsetIN, $charsetOUT,
 $data[15]);


 $result = pg_query($dbconn,set search_path = sw_audit;);
 echo result (set search_path) = .$result.br/br/;
 $res=pg_query(SELECT nextval('tmp_importedxls_rec_id_seq') as
 key);
 $row=pg_fetch_array($res, 0);
 $key=$row['key'];

 $sql = INSERT INTO tmp_importedxls (rec_id, publisher, program,
 version, path, licensing_file, date_audit, barcode, pcinfo_ident, area,
 locality, users, personal_number)
  VALUES ($key,
  '$publisher',
  '$program',
  '$version',
  '$path',

 '$licensing_file','.SplitDate(.,$date_audit).',
  '$barcode',
  '$pcinfo_id',
  '$area',
  '$locality',
  '$username',
  '$personal_number');;

 //echo SQL :  .$sql.br/br/;

 $result = pg_query($dbconn,$sql);
 if (!$result)
 {
  die(Error in SQL query:  . pg_last_error());
 }
 else
 {
 echo result (INSERT INTO) = .$result.br /;
 }

 }
 $row++;
 }
 fclose($handle);

 pg_close($dbconn);



thanks a lot for any help.


-- 
Alain

Windows XP SP2
PostgreSQL 8.2.3
Apache 2.2.4
PHP 5.2.3


Re: [PHP] very strange behavior.... incomplete query performed

2007-08-12 Thread Tijnema
On 8/12/07, Alain Roger [EMAIL PROTECTED] wrote:
 Hi,

 I'm still working on importing CSV file content (20.000 records) to database
 PostgreSQL.

 when i run the query, once i stored into my table  5218 records, another
 time 5231 another time 4713 and so on
 every time the amount of records imported to DB is different.

 Do you have any idea from where it could come ?

 Here is my PHP code :

snip

 thanks a lot for any help.


 --
 Alain

Might it be that your script times out?
try setting the time limit to unlimited:
set_time_limit(0);

Apache (or w/e your server is) might still timeout, but these values
are a lot higher.. :)

Tijnema

-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



Re: [PHP] question about note on php.net

2007-08-12 Thread Stut

brian wrote:

Michael Cooper wrote:

Hello, I have a question--is the note from equazcion here correct? It
is left unchallenged on the page but I can't see how it is correct 
since I am under the impression that the environment is refreshed each 
page load and the function or method definitions (including those for 
session_set_save_handler) would need to be re-established each page, 
not each session.  I am having tremendous difficulty debugging some 
code I wrote and eliminating my uncertainty regarding this point would 
be greatly helpful.  Any advice would be appreciated. Thanks!


Because i'm already procrastinating ...

google site:php.net equazcion

http://www.php.net/session_set_save_handler

wherein:


equazcion
10-Mar-2007 02:44
I know this might be obvious, but session_set_save_handler() should
only be called once per session, or else your saved data will keep
getting reset.

If your script doesn't have a predictable start page that will only
be called only once per session, place the session_set_save_handler
statement in an include file, and call it via require_once().


I doubt that this is correct. The save handler that is being set is not, 
in itself, a part of the session, but a function that is to be used to 
act upon the session. That is, there isn't anything inherent to the 
session in the function. Thus, it wouldn't be saved as *a part of* the 
session. It's just a handler. It's not as if the function, itself, were 
a container for the session vars.


Looking at the source in head for that function[1] it would appear to 
fail if a session has already been started, in which case equizcion's 
comment would be wrong.


If the OP is concerned about it I suggest they try it and see what happens.

-Stut

[1] http://lxr.php.net/source/php-src/ext/session/session.c#1473

--
http://stut.net/

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



Re: [PHP] What's is the needed configuration to enable SOAP?

2007-08-12 Thread Stut

Brice wrote:

I have a little problem with Soap. I programmed a script which works
well on all server except one. I had an 'HTTP Error : Couldn't open
socket connection to server' Too bad for me it's the main one.

I wonder if  there is a configuration problem? I just saw that socket
is disabled on the main server. Is soap extension needs to enable
socket? Google and php documentation said nothing about that.


Just a guess, but maybe it's slightly within the realms of possibility 
that the server cannot make a connection to the other server for some 
network-related reason. Are you sure that server has a route to the 
server it's trying to talk to? No firewalls in the way? Is the target 
server working properly?


If you were missing a component required for your code to work PHP would 
tell you that. The error you're getting simply indicates that it cannot 
make a connection to the target server.


-Stut

--
http://stut.net/

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



Re: [PHP] very strange behavior.... incomplete query performed

2007-08-12 Thread Stut

Tijnema wrote:

On 8/12/07, Alain Roger [EMAIL PROTECTED] wrote:

Hi,

I'm still working on importing CSV file content (20.000 records) to database
PostgreSQL.

when i run the query, once i stored into my table  5218 records, another
time 5231 another time 4713 and so on
every time the amount of records imported to DB is different.

Do you have any idea from where it could come ?

Here is my PHP code :


snip

thanks a lot for any help.


--
Alain


Might it be that your script times out?
try setting the time limit to unlimited:
set_time_limit(0);

Apache (or w/e your server is) might still timeout, but these values
are a lot higher.. :)


And if that is the case I would strongly recommend that you turn 
display_errors on and set error_reporting to E_ALL, at least for that 
script or if this is a development server do it in php.ini.


-Stut

--
http://stut.net/

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



Re: [PHP] What's is the needed configuration to enable SOAP?

2007-08-12 Thread Tijnema
On 8/12/07, Brice [EMAIL PROTECTED] wrote:
 Hello all,

 I have a little problem with Soap. I programmed a script which works
 well on all server except one. I had an 'HTTP Error : Couldn't open
 socket connection to server' Too bad for me it's the main one.

 I wonder if  there is a configuration problem? I just saw that socket
 is disabled on the main server. Is soap extension needs to enable
 socket? Google and php documentation said nothing about that.

 Thanks in advance for your help.

 Brice Favre


Is it the same server you are trying to do a SOAP request to? if so,
you should use 127.0.0.1/localhost to connect to, instead of the
server name/ip

Also keep in mind that you can not always connect through the external
IP of a server, but that you need to use internal IP sometimes when
they are in LAN or such..

Tijnema
-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



Re: [PHP] javascript in head or in body ?

2007-08-12 Thread David Robley
tedd wrote:

 At 9:29 PM +0200 8/7/07, Tijnema wrote:
On 8/7/07, Robert Cummings [EMAIL PROTECTED] wrote:
   Yeah!! This list is for public apologies and Copyright discussion.

  Cheers,
  Rob.
  --

Oh yeah, Tedd is only the first of thousands of people that need to
apologize... :P

Tijnema
 
 
 Ah crap, have I got something else to apologize for?
 
 At this rate, by the time I reach the end of my life, I'll know only
 two sentences, namely I'm sorry and Yes, Dear.

Seems to me you could rather easily condense that to just one sentence with
the same degree of functionality. :-)




Cheers
-- 
David Robley

This isn't hell, but I can see it from here.
Today is Prickle-Prickle, the 5th day of Bureaucracy in the YOLD 3173. 
Celebrate Zaraday

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



Re: [PHP] PostgreSQL and select nextval

2007-08-12 Thread brian

Alain Roger wrote:

Hi,

I'm getting an error message when i run the following SQL request :
$sql = INSERT INTO tmp_importedxls (rec_id, publisher) VALUES (SELECT
nextval('tmp_importedxls_rec_id_seq'),'$pb');

Error in SQL query: ERROR: syntax error at or near SELECT LINE 2: VALUES
(SELECT nextval('tmp_importedxls_rec_id_seq'),' ^

I have the feeling that we can not use the select nextval(...) SQL request
in an INSERT INTO one under PHP.
Is it true?



If rec_id is a SERIAL it will increment itself:

INSERT INTO tmp_importedxls (publisher) VALUES ('$pb');

brian

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



Re: [PHP] manual vs. meta refresh

2007-08-12 Thread Robert Cummings
On Sun, 2007-08-12 at 13:47 +0200, Tijnema wrote:
 On 8/12/07, Robert Cummings [EMAIL PROTECTED] wrote:
  On Sat, 2007-08-11 at 22:11 -0500, Richard Lynch wrote:
   You don't do it there.
  
   You do whatever it is you have to do in the URL before you re-direct.
  
   Though I guess if you want different output on that page, you would
   need to set something somewhere, be it session, database, or a cookie.
 
  I think you're missing the point Richard. Yes you can detect the meta
  redirect or manual refresh using your method. But only the first can be
  detected because when the page is served up to the browser again either
  the special meta redirect URL is active, non special normal URL is
  active, or a super special I'm redirecting but don't count me URL is
  active. Now what happens when the user does a manual refresh again? It's
  not about output, it's about detecting subsequent refreshes and
  determining again the source of the refresh. You must have some kind of
  session tracking system in place, be it a regular session or a database
  query that can check if an ID was already detected that indicates to
  discount the page load from any statistics.
 
  Cheers,
  Rob.
 
 I think you Rob missed a part of Richard's first reply:
 You would then need to re-direct back to the URL *without* the GET
 parameter from_meta_tag=1 so that their refresh button would not be
 going to that URL with from_meta_tag in it.

*SMACK* Yes, that was me smacking you upside the head :) Ok, let's
imagine I take your far too simplistic approach and re-direct BACK to
the URL WITHOUT the GET parameter... Oh Jebus, the script thinks a user
generated refresh just occurred. Now quickly... crawl back to your rock.
At the very least study closely all that has been said in this thread.

:)

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] magic quotes

2007-08-12 Thread Nisse Engström
On Thu, 9 Aug 2007 00:29:15 -0500 (CDT), Richard Lynch wrote:

 Problem #7:
 Magic Quotes was designed for the ASCII character set, and is
 downright dangerous to use for anything else (Unicode/UTF-8/etc). 
 ...
 [Though maybe not, as maybe addslashes can't do any harm to Unicode if
 there's no ' nor \ to escape...  You'd have to ask a Unicode geek. 
 But they'd tell you to just turn off the Magic Quotes and be done with
 it anyway.]

   UTF-8 was designed to avoid collision with ASCII.
Code points above U+7f only contain octets in the
range 0x80 to 0xff, so magic quotes should work
just fine for UTF-8 (if magic quotes can be said to
work fine at all).

   The situation is different when it comes to
UTF-16 and -32, where magic quotes could insert
octets inside code units. Example: U+0100 (A with
macron) is 01 00 in UTF-16BE which addslashes()
turns into 01 5c 00 --.

 -  -  - 

   I mention addslashes() in the example because
I don't know how to provoke a browser to make a
form submission in UTF-16. Has anyone ever seen
a form submission using anything other than UTF-8
or one of the extended ASCII encodings?


/Nisse

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



Re: [PHP] Friday morning brain farts....

2007-08-12 Thread tedd

At 4:54 PM +0200 8/11/07, Tijnema wrote:

On 8/11/07, tedd [EMAIL PROTECTED] wrote:

 At 7:21 PM +0200 8/10/07, Tijnema wrote:
 On 8/10/07, Robert Cummings [EMAIL PROTECTED] wrote:
 

 if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )

 

  if(!isset($argv[1],$argv[2],$argv[3])) // Bit shorter ;)


 But a bit harder to recognize IMO. :-)

 Cheers,

 tedd
 --


But less confusing :)


Perhaps for you boy wonder, but for us old farts (or at least me) 
it's a bit more confusing.


I'm going to show my ignorance now -- if I see this:

if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )

or this

if( !isset( $argv[1] )  !isset( $argv[2] )  !isset( $argv[3] ) )

Then I understand what that means.

But, if I see this:

if(!isset($argv[1],$argv[2],$argv[3])))

My first thought is Is this OR or AND? And my second thought is If 
this is OR, then what's AND?


Being dyslexic I'm easily confused that way (seriously, that's the 
reason I never use an else-if).


Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] javascript in head or in body ?

2007-08-12 Thread tedd

At 1:26 PM -0400 8/11/07, Robert Cummings wrote:

On Sat, 2007-08-11 at 12:15 -0400, tedd wrote:
  Always (fishing for another apology opportunity) place javascript in

 external files and call them in via the header. Keep the code
 unobtrusive. There are ways to use javascript without having to mix
 it into your html -- look up DOM scripting.


I absolutely agree with unobtrusive JavaScript, but I do disagree with
you slightly on using external files. Generally speaking i keep large
bits of code (Especially libs) in external files, but a few lines of
script for a form that appears on one page I'll often be put in the head
section. This way the JavaScript is in the same file as the template for
which it is associated. My template engine will relocate the JavaScript
to the head section at compile time.


That's clever. I assume that for production work (i.e., for a 
client), you can isolate the files you need and be totally 
unobtrusive if you want.


I just described my method off-list to another person and it went like this:

I have a system for my site development work such that I simply 
include one header and one footer and no matter where the project 
directory is that I'm currently working on, the process will find the 
one main common header and common footer and will add them to my demo 
automagically.


My code to start, looks like this:

?php include('../header.php') ?
   h1 Hi /h1
?php include('../footer.php') ?

From there I have a complete page -- from doctype to copyright, it's 
all there and it validates.


If I need a javascript file locally, then I add it to the local 
working directory by naming the file a.js. Likewise, if I need an 
additional css file, then I name it a.css and it's also included in 
the call.


However, if I don't need those files, then none are included in my 
local working directory and attempts to load those files will fail -- 
however -- it doesn't matter if an attempt to load fails or not as 
long as the files are not needed.


I think that's kind of clever, but I like Rocky and Bullwinkle as well.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] OT Re: [PHP] javascript in head or in body ?

2007-08-12 Thread tedd

At 10:21 PM +0930 8/12/07, David Robley wrote:

tedd wrote:

 

 At this rate, by the time I reach the end of my life, I'll know only
 two sentences, namely I'm sorry and Yes, Dear.


Seems to me you could rather easily condense that to just one sentence with
the same degree of functionality. :-)



Unfortunately, it doesn't work that way. You must keep them in two 
separate sentences.


For example, if your wife says (and you're not listening as usual) 
Do these pants make my butt look big? Neither answer is going to 
help much. But, if said separately, you at least have a chance of 
surviving the ordeal.


Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] PHP Books - A poll of sorts

2007-08-12 Thread Jay Blanchard
Evening all! (at least it is evening here in Texas)

We all have our favorite PHP books and resources but there is one tome
that seems to be missing from the group...a best practices book. We
all have our preferences for what we call best practices and it seems at
this stage in the life of PHP that there would be a guide to the best of
the best.

I am not talking about the holy wars here (like bracket placement) I am
talking about things like testing variable in conditional situations or
the proper use of constructors or ways to leverage the power of PHP with
databases.

If there was a best practices book would you buy it? (I am showing
complete disregard for the thread on copyright infringement v. theft.)
Or do you rely on other sources like this list, articles, etc to derive
your own set of practices? Thanks for indulging me.

Thanks

Jay

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



Re: [PHP] Concatenation vs. Interpolation

2007-08-12 Thread Danial Rahmanzadeh
In my opinion, concatenation reduces code readability because unlike
java(that uses + operator), php uses dot(.) for concatenation consider the
following codes:
//java
String mystr=hello+world;
is more readable from:
//php
$mystr=hello.world;

if you only need echoing something to output(which is not usually the case
in MVC and/or other effective methods), the fastest way is using comma:
echo 'hello',$mystr,blah,blah ;


Re: [PHP] javascript in head or in body ?

2007-08-12 Thread Robert Cummings
On Sun, 2007-08-12 at 21:27 -0400, tedd wrote:
 At 1:26 PM -0400 8/11/07, Robert Cummings wrote:
 On Sat, 2007-08-11 at 12:15 -0400, tedd wrote:
Always (fishing for another apology opportunity) place javascript in
   external files and call them in via the header. Keep the code
   unobtrusive. There are ways to use javascript without having to mix
   it into your html -- look up DOM scripting.
 
 I absolutely agree with unobtrusive JavaScript, but I do disagree with
 you slightly on using external files. Generally speaking i keep large
 bits of code (Especially libs) in external files, but a few lines of
 script for a form that appears on one page I'll often be put in the head
 section. This way the JavaScript is in the same file as the template for
 which it is associated. My template engine will relocate the JavaScript
 to the head section at compile time.
 
 That's clever. I assume that for production work (i.e., for a 
 client), you can isolate the files you need and be totally 
 unobtrusive if you want.
 
 I just described my method off-list to another person and it went like this:
 
 I have a system for my site development work such that I simply 
 include one header and one footer and no matter where the project 
 directory is that I'm currently working on, the process will find the 
 one main common header and common footer and will add them to my demo 
 automagically.
 
 My code to start, looks like this:
 
 ?php include('../header.php') ?
 h1 Hi /h1
 ?php include('../footer.php') ?
 
  From there I have a complete page -- from doctype to copyright, it's 
 all there and it validates.
 
 If I need a javascript file locally, then I add it to the local 
 working directory by naming the file a.js. Likewise, if I need an 
 additional css file, then I name it a.css and it's also included in 
 the call.
 
 However, if I don't need those files, then none are included in my 
 local working directory and attempts to load those files will fail -- 
 however -- it doesn't matter if an attempt to load fails or not as 
 long as the files are not needed.
 
 I think that's kind of clever, but I like Rocky and Bullwinkle as well.

I don't use a script to find my JavaScript files and CSS but I do
something similar to your includes for header and footer. The difference
being that my template engine will pull them in at compile time and not
at run-time. A lot of static content is pulled in this way and relocated
using compile-time accumulators. Then I use run-time accumulators to
flush content at run-time into the appropriate areas if necessary. This
allows me to create a layout that is compiled once at compile time but
with flush hooks for run-time. For instance for simplicity I use the
following tag in the head area to set up JavaScript:

jinn:javaScriptSystem/

This is the same as doing the following manually:


jinn:accumulatorFlush name=javaScriptTags/
jinn:accumulatorFlush name=javaScriptTags dynamic=true/

jinn:javaScript
jinn:accumulatorFlush name=javaScript/
jinn:accumulatorFlush name=javaScript dynamic=true/

function javaScriptOnLoad()
{
jinn:accumulatorFlush name=javaScriptOnLoad/
jinn:accumulatorFlush name=javaScriptOnLoad dynamic=true/
}

/jinn:javaScript
-

The body tag will have an onload=javaScriptOnLoad(). Then in a content
file I can add the following:

jinn:accumulate name=javaScriptOnLoad

// some javascript code to modify the DOM

/jinn:accumulate

And it will get relocated at compile time to the location of the static
flush statement: jinn:accumulatorFlush name=javaScriptOnLoad/

Similarly within my code at run-time I can do the following:

$mAcc = $this-getServiceRef( 'accManager' );
$acc = $mAcc-getRef( 'javaScriptOnLoad' );

$acc-append
(
' // some javascript to modify the DOM '
)

And it will be get flushed into the content at the location of the
dynamic flush statement:

jinn:accumulatorFlush name=javaScriptOnLoad dynamic=true/

So all in all, it's very simple for me to put JavaScript (and any
content for that matter) anywhere I please. I often use it for layout
areas (such as left pane, right pane, etc), menus, visitor notices, etc.

BTW if you're wondering why I have a jinn:javaScript tag it's because
who wants to remember the following:

---
script type=text/javascript!--//--![CDATA[//!--

//--!]]/script
---

:)

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] PHP Books - A poll of sorts

2007-08-12 Thread Robert Cummings
On Sun, 2007-08-12 at 20:52 -0500, Jay Blanchard wrote:
 Evening all! (at least it is evening here in Texas)
 
 We all have our favorite PHP books and resources but there is one tome
 that seems to be missing from the group...a best practices book. We
 all have our preferences for what we call best practices and it seems at
 this stage in the life of PHP that there would be a guide to the best of
 the best.
 
 I am not talking about the holy wars here (like bracket placement) I am
 talking about things like testing variable in conditional situations or
 the proper use of constructors or ways to leverage the power of PHP with
 databases.
 
 If there was a best practices book would you buy it? (I am showing
 complete disregard for the thread on copyright infringement v. theft.)
 Or do you rely on other sources like this list, articles, etc to derive
 your own set of practices? Thanks for indulging me.

I don't buy books on tech. I search the web and read what people post
*shrug*. All the knowledge is out there for free. I'm not the type to
need it all bundled up fancy schmancy.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] PHP Books - A poll of sorts

2007-08-12 Thread Larry Garfield
The vast majority of my work these days is done using the Drupal CMS, which 
has its own coding standards and best practices and conventions that are 
(IMO) pretty darned good.  I've adopted most of it in my non-Drupal work, 
too, for simplicity.  

So um, maybe, but I probably wouldn't jump at it as I feel I'm already 
using good enough practices.

On Sunday 12 August 2007, Jay Blanchard wrote:
 Evening all! (at least it is evening here in Texas)

 We all have our favorite PHP books and resources but there is one tome
 that seems to be missing from the group...a best practices book. We
 all have our preferences for what we call best practices and it seems at
 this stage in the life of PHP that there would be a guide to the best of
 the best.

 I am not talking about the holy wars here (like bracket placement) I am
 talking about things like testing variable in conditional situations or
 the proper use of constructors or ways to leverage the power of PHP with
 databases.

 If there was a best practices book would you buy it? (I am showing
 complete disregard for the thread on copyright infringement v. theft.)
 Or do you rely on other sources like this list, articles, etc to derive
 your own set of practices? Thanks for indulging me.

 Thanks

 Jay


-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



Re: [PHP] PHP Books - A poll of sorts

2007-08-12 Thread Janet Valade

Jay Blanchard wrote:


Evening all! (at least it is evening here in Texas)

We all have our favorite PHP books and resources but there is one tome
that seems to be missing from the group...a best practices book. We
all have our preferences for what we call best practices and it seems at
this stage in the life of PHP that there would be a guide to the best of
the best.

I am not talking about the holy wars here (like bracket placement) I am
talking about things like testing variable in conditional situations or
the proper use of constructors or ways to leverage the power of PHP with
databases.

If there was a best practices book would you buy it? (I am showing
complete disregard for the thread on copyright infringement v. theft.)
Or do you rely on other sources like this list, articles, etc to derive
your own set of practices? Thanks for indulging me.

Thanks

Jay



I would buy it. But, I buy tons of books.

Janet


--
Janet Valade -- janet.valade.com

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



[PHP] Strip numerical indices from array

2007-08-12 Thread Dave M G

PHP General list,

I've got an associative array that also includes a numerical index. The 
numerical index was automatically generated from the mysql_fetch_array 
command, so it the values are the duplicates of the associative key names.


Is there a way to simply strip off the numerical index, leaving only the 
associative key names?


--
Dave M G

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



[PHP] phpinfo problem

2007-08-12 Thread Rick Knight
I have just installed PHP-5.2.3 on my Kubuntu Feisty box. I removed all 
the debian php first and then compiled php with the options I needed. 
Now everything seems to be working except phpinfo.php which consists of 
one line.


? phpinfo(); ?


I get a blank screen.

If I delete the php.ini file it get the usual phpinfo output.

php -r phpinfo(); works as does php -i and my php scripts run fine. 
What would cause phpinfo.php to not work? It's set rw for the apache2 
user so I think the permissions are right. Is there a phpinfo 
enable/disable in the php.ini? Or in ./configure?


Thanks.
Rick Knight

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



Re: [PHP] phpinfo problem

2007-08-12 Thread Chris
You probably just have short_open_tags set to Off in your php.ini file. 
If so, either turn it On, or change the file to be:


?php phpinfo(); ?

Chris

Rick Knight wrote:
I have just installed PHP-5.2.3 on my Kubuntu Feisty box. I removed 
all the debian php first and then compiled php with the options I 
needed. Now everything seems to be working except phpinfo.php which 
consists of one line.


? phpinfo(); ?


I get a blank screen.

If I delete the php.ini file it get the usual phpinfo output.

php -r phpinfo(); works as does php -i and my php scripts run fine. 
What would cause phpinfo.php to not work? It's set rw for the apache2 
user so I think the permissions are right. Is there a phpinfo 
enable/disable in the php.ini? Or in ./configure?


Thanks.
Rick Knight



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



Re: [PHP] Strip numerical indices from array

2007-08-12 Thread Larry Garfield
There is, but you want to be using mysql_fetch_assoc() instead which gives you 
just the keyed indexes in the first place.

Or, better yet, use mysqli_ or PDO which offer better security than mysql_ if 
you're running PHP 5 (which you are, right? g)

On Sunday 12 August 2007, Dave M G wrote:
 PHP General list,

 I've got an associative array that also includes a numerical index. The
 numerical index was automatically generated from the mysql_fetch_array
 command, so it the values are the duplicates of the associative key names.

 Is there a way to simply strip off the numerical index, leaving only the
 associative key names?

 --
 Dave M G


-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



Re: [PHP] PHP Books - A poll of sorts

2007-08-12 Thread Paul Scott

On Sun, 2007-08-12 at 20:52 -0500, Jay Blanchard wrote:
 If there was a best practices book would you buy it? (I am showing
 complete disregard for the thread on copyright infringement v. theft.)
 Or do you rely on other sources like this list, articles, etc to derive
 your own set of practices? Thanks for indulging me.

The team that delivers the Chisimba framework (http://avoir.uwc.ac.za),
has also developed our own best practices, as well as documentation
standards and coding standards. These standards are pretty much in line
with most of the large projects out there (I have never needed to look
at Drupal, so I cannot comment there), but I am willing to bet that
there isn't much of a difference.

We publish our coding and doc standards, as well as a bunch of HOWTO's
etc to get started, under a CC BY-SA license, so that if people would
like to adopt that, or build on it, they are free to do so.

I would not mind seeing at least *some* homogeneity in PHP code, across
projects, but I still don't think that *all* projects need stick to the
same standards - this will ultimately stifle creativity, which is what
PHP is all about anyway.

Just my R0.02

--Paul

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm 

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