php-general Digest 13 Aug 2007 01:05:52 -0000 Issue 4958
Topics (messages 260728 through 260740):
Re: convert (windows-1250) to (utf-8)
260728 by: Tijnema
260729 by: Alain Roger
very strange behavior.... incomplete query performed
260730 by: Alain Roger
260731 by: Tijnema
260734 by: Stut
Re: question about note on php.net
260732 by: Stut
Re: What's is the needed configuration to enable SOAP?
260733 by: Stut
260735 by: Tijnema
Re: javascript in <head> or in <body> ?
260736 by: David Robley
Re: PostgreSQL and select nextval
260737 by: brian
Re: manual vs. meta refresh
260738 by: Robert Cummings
Re: magic quotes
260739 by: Nisse Engström
Re: Friday morning brain farts....
260740 by: tedd
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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($row>1)
> {
>
> $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
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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/
--- End Message ---
--- Begin Message ---
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/
--- End Message ---
--- Begin Message ---
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/
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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!
...........................................................
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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
--- End Message ---