OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 8 Feb 2004 16:58:49 -0000 Issue 2578

php-general-digest-helplists.php.net
Date: Sun Feb 08 2004 - 10:58:49 CST


php-general Digest 8 Feb 2004 16:58:49 -0000 Issue 2578

Topics (messages 177121 through 177146):

Re: how to conver a string to float
        177121 by: Michal Migurski
        177123 by: Adam Bregenzer

Re: refresh page (might be 0t)
        177122 by: Adam Bregenzer

Re: Use a Server or Client Socket?
        177124 by: Tan Ai Leen
        177125 by: Tan Ai Leen
        177143 by: Raditha Dissanayake

Can I do this?
        177126 by: John Taylor-Johnston
        177127 by: John Taylor-Johnston
        177128 by: Adam Bregenzer

Revised: RE: [PHP] Re: Can I do this?
        177129 by: PHP Email List
        177130 by: Adam Bregenzer
        177136 by: Andrew Séguin
        177144 by: Raditha Dissanayake

mcrypt don't work.
        177131 by: francesco.automationsoft.biz
        177132 by: "Miguel J. Jiménez"

Application-level variables
        177133 by: Lloyd Bayley
        177134 by: Justin French
        177135 by: Shaunak Kashyap

PHP Image : resolutions differs between platform
        177137 by: jun

connecting with C-code
        177138 by: E.H.Terwiel
        177141 by: Marek Kilimajer

Question About Date Function in PHP/MySQL
        177139 by: Freedomware
        177142 by: John W. Holmes
        177145 by: Freedomware

Re: How can I run php 5 beta 3 on windows?
        177140 by: omer katz

.html or.php extension
        177146 by: E.H.Terwiel

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


>> Is there a possibility to convert a string like "10*500" (parsed from a
>> XML-File) to a float? When i try to store this String in a float
>> variable it only coverts the "10" but nothing after the "*"-sign, but i
>> need the result of this expresison... Is there a function to calculate
>> such string expressions?

Another possibility is to pipe the expression to bc, which could do the
input check for you, and probably covers a lot of syntactic ground.
Slightly less resource-efficient, but you don't have to reinvent the
wheel (untested, unix only):
        $result = shell_exec("echo '${expr}' | bc");

---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html

attached mail follows:


On Sat, 2004-02-07 at 23:50, Michal Migurski wrote:
> Another possibility is to pipe the expression to bc, which could do the
> input check for you, and probably covers a lot of syntactic ground.
> Slightly less resource-efficient, but you don't have to reinvent the
> wheel (untested, unix only):
> $result = shell_exec("echo '${expr}' | bc");

Both eval and piping to bc via the shell work but open up big security
holes if you are not careful. If you have bcmath or gmp enabled in php
I recommend looking at these functions:
http://www.php.net/manual/en/function.gmp-mul.php
http://www.php.net/manual/en/function.bcmul.php

--
Adam Bregenzer
adambregenzer.net
http://adam.bregenzer.net/

attached mail follows:


On Sat, 2004-02-07 at 23:03, Ryan A wrote:
> Heres what I am doing:
> I give the client a control panel where he can add,edit and delete accounts,
> after each of the actions I have a link back to
> the index page of the contol panel...problem is, unless he presses the
> refresh button it shows him the same cached content.
> How do i force the browser to display the new updated accounts after and
> edit or the new list of accounts after a delete?

It sounds like you may want to set the page to not be cached. Here's
what I use to prevent pages from being cached:

function noCacheHeaders() {
 header('Expires: Tue, 1 Jan 1980 12:00:00 GMT');
 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
 header('Cache-Control: no-store, no-cache, must-revalidate,
post-check=0, pre-check=0, no-transform');
 header('Pragma: no-cache');
}

This should prevent proxies, browsers, etc from caching your pages.

--
Adam Bregenzer
adambregenzer.net
http://adam.bregenzer.net/

attached mail follows:


Hi Raditha,

Thanks, I have a better idea of how to write the codes. But I wonder, to
check that the connection to the external server is on, where should I
place the code? I need to do this every 10 minutes. If the connection is
dropped, I have to reconnect. Where should I place this check? If I
place it in the while(true) loop, I will be checking every few
miliseconds rite? That will be too frequent. What about in another
script? Will I be able to check that the connection is on?

Regards,
Ai Leen

Raditha Dissanayake wrote:
> Hi Tan,
>
> If you are connecting to another server you are using a client socket
> you do not need to make a server socket. If you need to listen for
> connections make use of a server socket. To give you an example your
> browser makes use of client sockets while apache makes use of server
> sockets. That is an over simplified view of things but hope it helps you
> understand things better.
>
> Generally working with client sockets is easier.
>
> best regards
> raditha
>
>
> Tan Ai Leen wrote:
>
>> Hi all,
>> I have this situation now that requires socket programming. But I am not
>> sure how to realise the requirements in programming whether as a
>> client or
>> server
>> The requirement is like this.
>> I have to connect to an external server constantly to listen for incoming
>> data. How can I make sure that the connection is there all the time? Upon
>> receiving the message, I will have to response back an acknowledgement
>> that
>> the message is received. I can also send data to the server. From my
>> requirements, I understand that there will only be one connection.
>> Therefore
>> the data exchange need not be in sequence.
>>
>> Currently, what I have is a server programmed using the socket library.
>> Server logic :
>> socket_create
>> socket_bind
>> socket_listen
>> while(true)
>> {
>> socket_select
>> if(new connection)
>> {
>> add to connections array
>> }
>> else
>> {
>> if(can read)
>> {
>> read incoming
>> response back
>> }
>> else
>> {
>> //error or connection close
>> if(error)
>> {
>> print error
>> }
>> else
>> {
>> print connection close
>> remove from connections array
>> }
>> }
>> }
>> }
>> I am planning to include a check somewhere in the codes for
>> maintaining the
>> connection between my server and the other server. Where should I
>> place it?
>> Also, I need to initiate a connection to the external server and then
>> listen. Where should this piece of code be insert at? Is this the right
>> approach? Or I am over killing by writing a server if this can be
>> handle in
>> easier manner.
>> Hope that I have been clear in the above.
>>
>> Thanks for helping
>> Ai Leen
>>
>>
>>
>
>

attached mail follows:


Hi Raditha,

Thanks, I have a better idea of how to write the codes. But I wonder, to
check that the connection to the external server is on, where should I
place the code? I need to do this every 10 minutes. If the connection is
dropped, I have to reconnect. Where should I place this check? If I
place it in the while(true) loop, I will be checking every few
miliseconds rite? That will be too frequent. What about in another
script? Will I be able to check that the connection is on?

Regards,
Ai Leen

Raditha Dissanayake wrote:
> Hi Tan,
>
> If you are connecting to another server you are using a client socket
> you do not need to make a server socket. If you need to listen for
> connections make use of a server socket. To give you an example your
> browser makes use of client sockets while apache makes use of server
> sockets. That is an over simplified view of things but hope it helps you
> understand things better.
>
> Generally working with client sockets is easier.
>
> best regards
> raditha
>
>
> Tan Ai Leen wrote:
>
>> Hi all,
>> I have this situation now that requires socket programming. But I am not
>> sure how to realise the requirements in programming whether as a
>> client or
>> server
>> The requirement is like this.
>> I have to connect to an external server constantly to listen for incoming
>> data. How can I make sure that the connection is there all the time? Upon
>> receiving the message, I will have to response back an acknowledgement
>> that
>> the message is received. I can also send data to the server. From my
>> requirements, I understand that there will only be one connection.
>> Therefore
>> the data exchange need not be in sequence.
>>
>> Currently, what I have is a server programmed using the socket library.
>> Server logic :
>> socket_create
>> socket_bind
>> socket_listen
>> while(true)
>> {
>> socket_select
>> if(new connection)
>> {
>> add to connections array
>> }
>> else
>> {
>> if(can read)
>> {
>> read incoming
>> response back
>> }
>> else
>> {
>> //error or connection close
>> if(error)
>> {
>> print error
>> }
>> else
>> {
>> print connection close
>> remove from connections array
>> }
>> }
>> }
>> }
>> I am planning to include a check somewhere in the codes for
>> maintaining the
>> connection between my server and the other server. Where should I
>> place it?
>> Also, I need to initiate a connection to the external server and then
>> listen. Where should this piece of code be insert at? Is this the right
>> approach? Or I am over killing by writing a server if this can be
>> handle in
>> easier manner.
>> Hope that I have been clear in the above.
>>
>> Thanks for helping
>> Ai Leen
>>
>>
>>
>
>

attached mail follows:


Hi,

If you only need to make a connection to the server every ten minutes
you will be saving a lot of resources if you use a cron job to connect
at intervals instead of keeping a permanently open connections. Creating
a cron job is quite simple, if you type

man 5 crontab

you will be able to read more about it (at least in linux - a poor
substitute exists in windows called scheduled tasks)

With this approach you just need to call fsockopen to do connect to your
server and do the needful.

Tan Ai Leen wrote:

> Hi Raditha,
>
> Thanks, I have a better idea of how to write the codes. But I wonder,
> to check that the connection to the external server is on, where
> should I place the code? I need to do this every 10 minutes. If the
> connection is dropped, I have to reconnect. Where should I place this
> check? If I place it in the while(true) loop, I will be checking every
> few miliseconds rite? That will be too frequent. What about in another
> script? Will I be able to check that the connection is on?
>
> Regards,
> Ai Leen
>
> Raditha Dissanayake wrote:
>
>> Hi Tan,
>>
>> If you are connecting to another server you are using a client socket
>> you do not need to make a server socket. If you need to listen for
>> connections make use of a server socket. To give you an example your
>> browser makes use of client sockets while apache makes use of server
>> sockets. That is an over simplified view of things but hope it helps
>> you understand things better.
>>
>> Generally working with client sockets is easier.
>>
>> best regards
>

--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB | with progress bar.

attached mail follows:


Can I include a script on another server doing this?

$sql = 'SELECT * FROM '.$table.' where number like '.$number.';';

http://foo.com?list.php?number=16

include("http://elsewhere.com/list.php");

My $sql is error-ing - obviously. http://elsewhere.com/list.php is not receiving $number. Can I even do this?

attached mail follows:


Ah! A little experimenting ... Yes I can :) Answered my own question.

include("http://elsewhere.com/list.php?number=$number");

André Cerqueira wrote:

> John Taylor-Johnston wrote:
>
> > Can I include a script on another server doing this?
> >
> > $sql = 'SELECT * FROM '.$table.' where number like '.$number.';';
> >
> > http://foo.com?list.php?number=16
> >
> > include("http://elsewhere.com/list.php");
> >
> > My $sql is error-ing - obviously. http://elsewhere.com/list.php is not receiving $number. Can I even do this?
>
> No, you cant.
> Even if you could, if the server where the include file is located runs
> PHP, the include file would run there, and you would end up including
> the output of it instead of the code.
> Why would you want to do that? Maybe what you really want to do dont
> need that...

--
John Taylor-Johnston
-----------------------------------------------------------------------------
"If it's not Open Source, it's Murphy's Law or broken."

  ' ' ' Collège de Sherbrooke
 ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/
   - Université de Sherbrooke
          http://compcanlit.ca/
          819-569-2064

attached mail follows:


On Sun, 2004-02-08 at 03:18, John Taylor-Johnston wrote:
> Ah! A little experimenting ... Yes I can :) Answered my own question.
>
> include("http://elsewhere.com/list.php?number=$number");

Careful with that. If someone were to stumble upon your list.php script
they would be able to see your php code. You would probably be better
off having a local copy of that file.

--
Adam Bregenzer
adambregenzer.net
http://adam.bregenzer.net/

attached mail follows:


Ok so on this topic, I do something similar to this with my scripts, and if
my includes are vulnerable... I need to know how?

I have tested this and the includes parse the information as it includes it,
I can't see the code, so how is this possible where you say:

        {
"If someone were to stumble upon your list.php script they would be able to
see your php code."
        }

I have tested this pulling it from the server without parsing the file, I
only saw the html source with the include directory in it. Even if someone
was to get ahold of that the only variable is a "get" variable correct,
what's the difference from them having this information there or typing it
into a Web browser? And if they did try anything with that variable, I have
the script checking for valid input. Am I not safe in doing this?

Maybe I'm being nieve here, but I thought I had covered most of my bases
with this. Please explain where the security hole is! Anyone?....I'm still
learning and need to know the ins and outs of security for what I am
scripting.

Sorry for all the questions, but I'm truely concerned now....I'd like to
know if I have to find alternative solutions to my include issues.

TIA
Wolf

-----Original Message-----
From: Adam Bregenzer [mailto:adambregenzer.net]
Sent: Sunday, February 08, 2004 2:39 AM
To: jt.johnstonUSherbrooke.ca
Cc: php-generallists.php.net; accerqueirasuperig.com.br
Subject: Re: [PHP] Re: Can I do this?

On Sun, 2004-02-08 at 03:18, John Taylor-Johnston wrote:
> Ah! A little experimenting ... Yes I can :) Answered my own question.
>
> include("http://elsewhere.com/list.php?number=$number");

Careful with that. If someone were to stumble upon your list.php script
they would be able to see your php code. You would probably be better
off having a local copy of that file.

--
Adam Bregenzer
adambregenzer.net
http://adam.bregenzer.net/

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

attached mail follows:


On Sun, 2004-02-08 at 04:14, PHP Email List wrote:
> Ok so on this topic, I do something similar to this with my scripts, and if
> my includes are vulnerable... I need to know how?
>
> I have tested this and the includes parse the information as it includes it,
> I can't see the code, so how is this possible where you say:

Are you referring to including a file locally, or including a file from
a remote server via http? From what I understand this thread is about
including a php script from a different server over http. In this case
the php code will be viewable if you open it via a web browser. If you
know of a way to include a file remotely with php, but not browse to it,
please let me know. Presumably you could use apache to restrict access
to the file by ip, however that can still be subverted by a man in the
middle attack. I would be curious to see an example where this method
of including a file would be necessary.

--
Adam Bregenzer
adambregenzer.net
http://adam.bregenzer.net/

attached mail follows:


The security hole is probably not existant in my opinion.

PHP is (normaly) parsed by the remote server(no source viewable) and the
result is being included, not the source.
When "http://.../script.php?var=value" was mentioned, it implies the
script is being parsed remotedly so that the http request variables are
being used within the script.

A test to confirm that, is to point the browser to the address being
included. See the source? vulnerable. See the results? not vulnerable.

HTH,
Andrew

> On Sun, 2004-02-08 at 04:14, PHP Email List wrote:
>> Ok so on this topic, I do something similar to this with my scripts, and
>> if
>> my includes are vulnerable... I need to know how?
>>
>> I have tested this and the includes parse the information as it includes
>> it,
>> I can't see the code, so how is this possible where you say:
>
> Are you referring to including a file locally, or including a file from
> a remote server via http? From what I understand this thread is about
> including a php script from a different server over http. In this case
> the php code will be viewable if you open it via a web browser. If you
> know of a way to include a file remotely with php, but not browse to it,
> please let me know. Presumably you could use apache to restrict access
> to the file by ip, however that can still be subverted by a man in the
> middle attack. I would be curious to see an example where this method
> of including a file would be necessary.
>
> --
> Adam Bregenzer
> adambregenzer.net
> http://adam.bregenzer.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

attached mail follows:


Hi,
As andrew has said there is no risk here. What you will see is the
parsed output (if the webserver has PHP installed) If this is indeed a
vulerability we can just add lines similar to

include("http://elsewhere.com/list.php");

in our code and be able to easily view other peoples php scripts.

Andrew Séguin wrote:

>The security hole is probably not existant in my opinion.
>
>PHP is (normaly) parsed by the remote server(no source viewable) and the
>result is being included, not the source.
>When "http://.../script.php?var=value" was mentioned, it implies the
>script is being parsed remotedly so that the http request variables are
>being used within the script.
>
>A test to confirm that, is to point the browser to the address being
>included. See the source? vulnerable. See the results? not vulnerable.
>
>HTH,
>Andrew
>
>
>
>>On Sun, 2004-02-08 at 04:14, PHP Email List wrote:
>>
>>
>>>Ok so on this topic, I do something similar to this with my scripts, and
>>>if
>>>my includes are vulnerable... I need to know how?
>>>
>>>I have tested this and the includes parse the information as it includes
>>>
>>>
>

--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB | with progress bar.

attached mail follows:


Hi all,
I have problem with mcrypt function.
There is always an error that I don't know how to correct this.
This is my code:

$string = "Text string";
$key= "My key";
$encrypted = mcrypt_cfb(MCRYPT_RIJNDAEL-256, $key, $string, MCRYPT_ENCRYPT);
echo"stringa cifrata= $encrypted";
$key = "My key";
$string = mcrypt_cfb(MCRYPT_RIJNDAEL-256, $key, $encrypted, MCRYPT_DECRYPT);
echo"stringa decifrata= $string";

And the errore message is

Warning: mcrypt_cfb(): Module initialization failed in /web/htdocs/www.automationsoft.biz/home/critto.php on line 55
stringa cifrata=
Warning: mcrypt_cfb(): Module initialization failed in /web/htdocs/www.automationsoft.biz/home/critto.php on line 58
stringa decifrata=

I see, with phpinfo(), that my server support mcrypt and RIJNDAEL-256.
I don't know why there is this error message.
All helps are precious.
Thanks in advance
Francesco
francescoautomationsoft.biz
(P.S. this is the link for a view in real time of the problem www.automationsoft.biz/critto.php)
 

attached mail follows:


Mmm this same problem happen to me also... I use Apache 1.3.29 for Win32
and PHP v4.3.4 ... I do not know why but mcrypt module failed to
initialize....

francescoautomationsoft.biz wrote:

>Hi all,
>I have problem with mcrypt function.
>There is always an error that I don't know how to correct this.
>This is my code:
>
>$string = "Text string";
>$key= "My key";
>$encrypted = mcrypt_cfb(MCRYPT_RIJNDAEL-256, $key, $string, MCRYPT_ENCRYPT);
>echo"stringa cifrata= $encrypted";
>$key = "My key";
>$string = mcrypt_cfb(MCRYPT_RIJNDAEL-256, $key, $encrypted, MCRYPT_DECRYPT);
>echo"stringa decifrata= $string";
>
>And the errore message is
>
>Warning: mcrypt_cfb(): Module initialization failed in /web/htdocs/www.automationsoft.biz/home/critto.php on line 55
>stringa cifrata=
>Warning: mcrypt_cfb(): Module initialization failed in /web/htdocs/www.automationsoft.biz/home/critto.php on line 58
>stringa decifrata=
>
>I see, with phpinfo(), that my server support mcrypt and RIJNDAEL-256.
>I don't know why there is this error message.
>All helps are precious.
>Thanks in advance
>Francesco
>francescoautomationsoft.biz
>(P.S. this is the link for a view in real time of the problem www.automationsoft.biz/critto.php)
>
>
>

attached mail follows:


Greetings Everyone,

I am still new to PHP but am progressing nicely. I has helped a lot that I
have had vast experience with ColdFusion (sorry) but have seen the light
and am now doing rather nicely in PHP.

My question is as follows...

I have certain functions, variables etc that I would like to be active in
an application-wide state.
CF has an "application.cfm" file that is read in (if it exists in the
directory) which is used for this purpose.

Is there a similar creature in PHP? If not, how is it best to define
application-level stuff?

Many Thanks In Advance,

Lloyd. :-)

attached mail follows:


You can auto-prepend a file to all PHP scripts as they are called, in
which you could store some application-wide variables like database
usernames and passwords, config irectives, etc, BUT it's important to
note that this file is loaded into PHP on every call basically as an
include, and each instance of the script being called is separate to
the others, and the PHP application remains stateless.

Since you used the word DEFINE in your post, my guess is this would be
sufficient. However, if you need something with state, or something
more dynamic, then this may not be enough.

FWIW, auto-prepended files can also include logic, database queries,
include other files, or anything else that you can do with an include
file... so it's not just a list of variables -- it's a PHP script.

You can set the php.ini directive auto_prepend_file to the full path of
the file at a server level (eg a dedicated server), or at a directory
level using a .htaccess file, with something like:

---
<IfModule mod_php4.c>
        php_value auto_prepend_file '/path/to/file.php'
</IfModule>
---

Or you can do it the old-fashioned-way at script level with
<? include('path/to/file.php'); ?>

If you want your scripts to be as portable as possible, the last option
is fail-safe. Option requires you to basically be the sys admin of
your server, and option 2 requires your sysadmin to allow .htaccess
files with tweaking of PHP (quite common, but not always).

Justin French

On Sunday, February 8, 2004, at 09:54 PM, Lloyd Bayley wrote:

> Greetings Everyone,
>
> I am still new to PHP but am progressing nicely. I has helped a lot
> that I have had vast experience with ColdFusion (sorry) but have seen
> the light and am now doing rather nicely in PHP.
>
> My question is as follows...
>
> I have certain functions, variables etc that I would like to be active
> in an application-wide state.
> CF has an "application.cfm" file that is read in (if it exists in the
> directory) which is used for this purpose.
>
> Is there a similar creature in PHP? If not, how is it best to define
> application-level stuff?
>
>
> Many Thanks In Advance,
>
>
> Lloyd. :-)
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


I haven't worked with ColdFusion much so I'm not quite sure what
application-level variables are. However, I did do some quick research and I
believe they are basically variables that are available to all scripts
running on the server (correct me if I'm wrong).

Assuming the above definition of application variables, I would say that I
don't know of any PHP mechanism that allows such functionality. However, I
did find an article that talks about alternatives. Here it is:
http://php.weblogs.com/php_application_variables

HTH,

Shaunak

----- Original Message -----
From: "Lloyd Bayley" <lloydspeednet.com.au>
To: <php-generallists.php.net>
Sent: Sunday, February 08, 2004 5:54 AM
Subject: [PHP] Application-level variables

> Greetings Everyone,
>
> I am still new to PHP but am progressing nicely. I has helped a lot that I
> have had vast experience with ColdFusion (sorry) but have seen the light
> and am now doing rather nicely in PHP.
>
> My question is as follows...
>
> I have certain functions, variables etc that I would like to be active in
> an application-wide state.
> CF has an "application.cfm" file that is read in (if it exists in the
> directory) which is used for this purpose.
>
> Is there a similar creature in PHP? If not, how is it best to define
> application-level stuff?
>
>
> Many Thanks In Advance,
>
>
> Lloyd. :-)
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


I created a script that creates a thumbnail based on the script .
I tested the scripting using WinXP/Apache/PHP/php_gd ... the resolution
is desirable .. but when I finally deployed my script on the web.. where
the Host runs on Linux/Apache/PHP/php_gd ... the resolution of the
resized image is not good at all. What happened?

jun

attached mail follows:


I have a tried-and-tested (15 years of it) piece of C code that I
could port from Windows to Linux, and I thought I put a PHP front on
it.
Is there a way to interface the C-code with PHP 4.3.4 ?
If so, could you point me to docs ?

frgr
Erik

attached mail follows:


E.H.Terwiel wrote:
> I have a tried-and-tested (15 years of it) piece of C code that I
> could port from Windows to Linux, and I thought I put a PHP front on
> it.
> Is there a way to interface the C-code with PHP 4.3.4 ?
> If so, could you point me to docs ?
>
> frgr
> Erik
>

Hello, there are two ways - you can execute a compiled exectable and
talk to the executable with command line arguments and/or using popen()
function. Another way is to wrap the code in a php extension.

attached mail follows:


I'm using PHP to display a MySQL table. I've got everything working fine
except the date function.

I designated the first two fields VARCHAR. Those columns display just
fine when I preview my web page, as do all the other columns except the
third. I designated that one DATE. (The field name is "Birthday.")

When I view my data in phpMyAdmin, all I see in that column is NULL.
When I preview it in a webpage, nothing displays at all. If I change it
to NOT NULL, I see 0000-00-00 in every cell.

Here's a row of text from the CSV file I imported into my MySQL table:

"Alberta","Edmonton","1905-09-01",11,"NWT","AB","CAN"

As you can see, the date is listed as "1905-09-01."

I've altered my MySQL table every way I can think of, and nothing works.
The MySQL Manual doesn't shed any light on it. So I'm wondering if
there's something wrong with my PHP code.

Below's the source code from my web page. Do you see anything that would
cause the third column - echo $myrow["Birthday"]; - to malfunction,
while everything else works fine?

Thanks.

<?php
$db = mysql_connect("localhost", "USERNAME", "PASSWORD");
mysql_select_db("test",$db);
$result = mysql_query("SELECT * FROM states",$db);
echo "<table>";
echo"<tr><td><b>Name</b><td><b>Capital</b><td><b>Birthday</b><td><b>Rank</b><b>Origin</b><b>Code</b><td><b>Nation</b></tr>";
while($myrow = mysql_fetch_array($result))
{
echo "<tr><td>";
echo $myrow["Name"];
echo "</td><td>";
echo $myrow["Capital"];
echo "</td><td>";
echo $myrow["Birthday"];
echo "</td><td>";
echo $myrow["Rank"];
echo "</td><td>";
echo $myrow["Origin"];
echo "</td><td>";
echo $myrow["Code"];
echo "</td><td>";
echo $myrow["Bigcode"];
echo "</td></tr>";
}
echo "</table>";
?>

attached mail follows:


Freedomware wrote:

> When I view my data in phpMyAdmin, all I see in that column is NULL.
> When I preview it in a webpage, nothing displays at all. If I change it
> to NOT NULL, I see 0000-00-00 in every cell.
>
> Here's a row of text from the CSV file I imported into my MySQL table:
>
> "Alberta","Edmonton","1905-09-01",11,"NWT","AB","CAN"
>
> As you can see, the date is listed as "1905-09-01."

Well, that's the right format for a MySQL date; YYYY-MM-DD, so I don't
know why it wouldn't load from your CSV file. Can you show the command
that you use to import the file? If the fields are NULL (or 0000-00-00)
in the database, then MySQL is not accepting your data (for the date
field at least).

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

attached mail follows:


John W. Holmes wrote:

> Freedomware wrote:
>
>> When I view my data in phpMyAdmin, all I see in that column is NULL.
>> When I preview it in a webpage, nothing displays at all. If I change
>> it to NOT NULL, I see 0000-00-00 in every cell.
>>
>> Here's a row of text from the CSV file I imported into my MySQL table:
>>
>> "Alberta","Edmonton","1905-09-01",11,"NWT","AB","CAN"
>>
>> As you can see, the date is listed as "1905-09-01."
>
>
> Well, that's the right format for a MySQL date; YYYY-MM-DD, so I don't
> know why it wouldn't load from your CSV file. Can you show the command
> that you use to import the file? If the fields are NULL (or 0000-00-00)
> in the database, then MySQL is not accepting your data (for the date
> field at least).

Wow, I think you solved it! I went to retrieve the link to the screen
shots I put online when I was first trying to figure this stuff out - at
http://geowebworks.geobop.org/test/php/

Towards the bottom of the page (#6) is a screen shot of something I was
oblivious to this time around - Date and Time Formats. (I'm using a
trial version of EMS MySQL Manager.)

I'll bet that's my problem, though I'm still a bit confused.

EMS lists the following:

Short Date: M/d/yyyy
Long Date: dddd, MMMM dd, yyyy

Day followed by month, followed by another day, then year???

I thought it was supposed to be year first, followed by month and day,
as in the example from CSV table - 1905-09-01.

Should I change Long Date so that it reads YYYY-MM-DD, or something like
that? Or maybe I can figure out how to do it in phpMyAdmin. I downloaded
EMS phpMySQL because I couldn't create error-free tables with
phpMyAdmin, but maybe I can use it to tweak my tables.

Thanks for the tip!

attached mail follows:


plz Help
"Omer Katz" <katz_obezeqint.net> ëúá
áäåãòä:20040206234733.44705.qmailpb1.pair.com...
> Help!!!
> "Omer Katz" <katz_obezeqint.net> ëúá
> áäåãòä:20040205174529.25612.qmailpb1.pair.com...
> > Can I update PHPTraid's php files?

attached mail follows:


My PHP system demands that files to be interpreted by PHP MUST have
the .php extension.
If I have an .html file with <?php ....?> in it, it won't interpret
the PHP code.
Unlike JavaScript, f.i.
Is there a way to make the server do the PHP code anyway, in an HTML
file ? Or must the action yes-php/no-php be taken before looking into
the file ?

The other way around is ok: put HTML code in a .php file...

frgr
Erik