php-general Digest 12 Feb 2010 09:17:55 -0000 Issue 6586

Topics (messages 302012 through 302035):

Re: PHP will NOT display this on my dev machine: Warning: session_start()...
        302012 by: Adam Richardson
        302013 by: Ashley Sheridan
        302015 by: John Black

Re: Persistent flag in memory
        302014 by: Jochem Maas

Mysql statement works in phpmyadmin but not in php page
        302016 by: james stojan
        302017 by: Joseph Thayne
        302018 by: Kim Madsen
        302019 by: Mari Masuda
        302020 by: james stojan
        302021 by: Joseph Thayne
        302022 by: James McLean
        302023 by: Joseph Thayne
        302024 by: Jochem Maas
        302025 by: James McLean
        302026 by: James McLean
        302027 by: Joseph Thayne
        302030 by: Paul M Foster
        302032 by: Joseph Thayne
        302034 by: Paul M Foster

Re: PHP Manual problems
        302028 by: clancy_1.cybec.com.au
        302031 by: Paul M Foster

the limitation of upload_max_filesize, post_max_size
        302029 by: pinate

Checking correct usage of fopen(), stream_set_timeout() and fread() [newbie]
        302033 by: Mark White

expression engine
        302035 by: Sudhakar

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Do you have output buffering turned on?

On Thu, Feb 11, 2010 at 1:19 PM, John Black
<s...@network-technologies.org>wrote:

> I am running into a strange problem and I hope someone might have an
> idea why this is happening.
>
> My installation of PHP will *NOT* display the warning message below on my
> development machine where it should display it (sample code at the bottom).
> Warning: session_start() [function.session-start]: Cannot send session
> cache limiter ....
>
> After receiving a bug report from a customer I tested my code on a XAMPP
> setup and, sure enough, it displayed the warning message.
> But on my machine, I can't find a message in my php log, it is as if this
> problem does not even exist (on my dev machine).
>
> My dev setup is:
> OS: ARCH 64bit (about a month out of date)
> PHP Dev stuff:
>  Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8k DAV/2 SVN/1.6.6
>  PHP/5.3.1 with Suhosin-Patch
>  xdebug-2.0.5-2-x86_64
>
> php.ini
>  error_reporting = E_ALL | E_STRICT
>  display_errors = On
>  display_startup_errors = On
>  log_errors = On
>  html_errors = On
>  ....
>
> phpinfo() confirms that these settings are in effect
>        display_errors  On      On
>        error_reporting 32767   32767
>
> So does anybody have any clue as to what could be causing this problem of
> not getting a warning message?
>
> Here is sample code:
> <p>The warning should be below this line</p>
> <?PHP session_start(); ?>
> <p>The warning should be above this line</p>
>
> Which should produce the message below between the lines:
> Warning: session_start() [function.session-start]: Cannot send session
> cache limiter - headers already sent ( output started at <file_name> on
> line 2 )
>
> but on my machine all I get is this in html source of the output:
> <p>The warning should be below this line</p>
> <p>The warning should be above this line</p>
>
> thx
> --
> John
> Staat heißt das kälteste aller kalten Ungeheuer.  Kalt lügt es auch; und
> diese Lüge kriecht aus seinem Munde: 'Ich, der Staat, bin das Volk.'
> [Friedrich Nietzsche]
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com

--- End Message ---
--- Begin Message ---
On Thu, 2010-02-11 at 19:19 +0100, John Black wrote:

> I am running into a strange problem and I hope someone might have an
> idea why this is happening.
> 
> My installation of PHP will *NOT* display the warning message below on 
> my development machine where it should display it (sample code at the 
> bottom).
> Warning: session_start() [function.session-start]: Cannot send session
> cache limiter ....
> 
> After receiving a bug report from a customer I tested my code on a XAMPP
> setup and, sure enough, it displayed the warning message.
> But on my machine, I can't find a message in my php log, it is as if 
> this problem does not even exist (on my dev machine).
> 
> My dev setup is:
> OS: ARCH 64bit (about a month out of date)
> PHP Dev stuff:
>    Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8k DAV/2 SVN/1.6.6
>    PHP/5.3.1 with Suhosin-Patch
>    xdebug-2.0.5-2-x86_64
> 
> php.ini
>    error_reporting = E_ALL | E_STRICT
>    display_errors = On
>    display_startup_errors = On
>    log_errors = On
>    html_errors = On
>    ....
> 
> phpinfo() confirms that these settings are in effect
>       display_errors  On      On
>       error_reporting 32767   32767
> 
> So does anybody have any clue as to what could be causing this problem 
> of not getting a warning message?
> 
> Here is sample code:
> <p>The warning should be below this line</p>
> <?PHP session_start(); ?>
> <p>The warning should be above this line</p>
> 
> Which should produce the message below between the lines:
> Warning: session_start() [function.session-start]: Cannot send session
> cache limiter - headers already sent ( output started at <file_name> on
> line 2 )
> 
> but on my machine all I get is this in html source of the output:
> <p>The warning should be below this line</p>
> <p>The warning should be above this line</p>
> 
> thx
> -- 
> John
> Staat heißt das kälteste aller kalten Ungeheuer.  Kalt lügt es auch; und
> diese Lüge kriecht aus seinem Munde: 'Ich, der Staat, bin das Volk.'
> [Friedrich Nietzsche]
> 
> 


Is your system setup with session autostart enabled? That would cause
PHP to ignore you manually starting them I believe, as they should have
already been started. I'm not 100% certain on this though.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
Adam Richardson wrote:
Do you have output buffering turned on?

THANK YOU!
That was it, for some reason ARCH has a "tweaked" php.ini in their main
repo, that sucks.

Thank you, I have been looking all over to fix this!

--
John


--- End Message ---
--- Begin Message ---
Op 2/11/10 3:48 PM, Teus Benschop schreef:
>> On Thu, 2010-02-11 at 09:27 -0500, Bastien Koert wrote:
>> Could the app be converted to an Adobe AIR app or use PHPdock (
>> http://www.nusphere.com/products/phpdock.htm ) to run local? There are
>> a number of security issues that surround installing a webserver and a
>> database locally on a users machine that may become issues.
> 
> It probably could be converted into a local application using these
> technologies, interesting technologies, by the way. The snag that will
> be hit though is that the application is licensed under the GPL v 3.
> Both tools you mention are closed source, I believe, and in addition I
> am not sure whether these work for Windows only, leaving Mac and Unix
> out. Will contributors to the applications be willing to buy the
> technologies? The security issues that you mention should be taken
> seriously. Teus.

Adobe AIR is a free platform - incl. a free SDK, it runs on Win, Mac and Linux.
AFAICT there is no restriction for developing GPL code that runs on the Air
platform ... obviously you'll not be using PHP inside Air - javascript and/or
actionscript would be the language in which the app logic is written.

> 


--- End Message ---
--- Begin Message ---
I'm at my wits end trying to make this mysql statement insert work in
PHP. I'm not getting any errors from PHP or mysql but the insert fails
(nothing is inserted) error reporting is on and is reporting other
errors. When I echo out the query and manually paste it into PHP
myAdmin the query inserts without a problem. I know that I am
connecting to the database as well part of the data being inserted
comes from the same database and that the mysql user has permission to
do inserts (even tried as root no luck).

$query="INSERT INTO upload_history (v_id,hour,visits,date) VALUES
(".$v_id.",".$hour.",".$visits.",'$date1'".");";

$r2=mysql_query($query) or die("<b>A fatal MySQL error
occured</b>.\n<br />Query: " . $query . "<br />\nError: (" .
mysql_errno() . ") " . mysql_error());

This is an echo of $query and runs in phpmyadmin.

INSERT INTO history (v_id,hour,visits,date) VALUES (45,0,59,'2010 01 27');


Any idea what is going on here?

--- End Message ---
--- Begin Message --- Try putting tick marks (`) around the field and table names. So your SQL query would then look like:

INSERT INTO `history` (`v_id`, `hour`, `visits`, `date`) VALUES (45, 0, 59, '2010 01 27');

This is a good practice to get into. The problem is that MySQL allows you to create tables and fields with the same name as functions. If the tick marks are not there, then it assumes you mean to try using the function. In your case, hour is a function in mysql. I would assume that the reason it works in phpmyadmin is that it filters the query somehow to add the tick marks in.

Joseph

james stojan wrote:
I'm at my wits end trying to make this mysql statement insert work in
PHP. I'm not getting any errors from PHP or mysql but the insert fails
(nothing is inserted) error reporting is on and is reporting other
errors. When I echo out the query and manually paste it into PHP
myAdmin the query inserts without a problem. I know that I am
connecting to the database as well part of the data being inserted
comes from the same database and that the mysql user has permission to
do inserts (even tried as root no luck).

$query="INSERT INTO upload_history (v_id,hour,visits,date) VALUES
(".$v_id.",".$hour.",".$visits.",'$date1'".");";

$r2=mysql_query($query) or die("<b>A fatal MySQL error
occured</b>.\n<br />Query: " . $query . "<br />\nError: (" .
mysql_errno() . ") " . mysql_error());

This is an echo of $query and runs in phpmyadmin.

INSERT INTO history (v_id,hour,visits,date) VALUES (45,0,59,'2010 01 27');


Any idea what is going on here?


--- End Message ---
--- Begin Message ---
james stojan wrote on 11/02/2010 22:21:

$query="INSERT INTO upload_history (v_id,hour,visits,date) VALUES
(".$v_id.",".$hour.",".$visits.",'$date1'".");";

The ,'$date1'"." is not correct syntax, change it to ,'".$date."'


--
Kind regards
Kim Emax - masterminds.dk

--- End Message ---
--- Begin Message ---
Also, in PHP you should NOT put the last semi-colon at the end of your SQL 
statement.  http://www.php.net/manual/en/function.mysql-query.php

On Feb 11, 2010, at 1:26 PM, Joseph Thayne wrote:

> Try putting tick marks (`) around the field and table names.  So your SQL 
> query would then look like:
> 
> INSERT INTO `history` (`v_id`, `hour`, `visits`, `date`) VALUES (45, 0, 59, 
> '2010 01 27');
> 
> This is a good practice to get into.  The problem is that MySQL allows you to 
> create tables and fields with the same name as functions.  If the tick marks 
> are not there, then it assumes you mean to try using the function.  In your 
> case, hour is a function in mysql.  I would assume that the reason it works 
> in phpmyadmin is that it filters the query somehow to add the tick marks in.
> 
> Joseph
> 
> james stojan wrote:
>> I'm at my wits end trying to make this mysql statement insert work in
>> PHP. I'm not getting any errors from PHP or mysql but the insert fails
>> (nothing is inserted) error reporting is on and is reporting other
>> errors. When I echo out the query and manually paste it into PHP
>> myAdmin the query inserts without a problem. I know that I am
>> connecting to the database as well part of the data being inserted
>> comes from the same database and that the mysql user has permission to
>> do inserts (even tried as root no luck).
>> 
>> $query="INSERT INTO upload_history (v_id,hour,visits,date) VALUES
>> (".$v_id.",".$hour.",".$visits.",'$date1'".");";
>> 
>> $r2=mysql_query($query) or die("<b>A fatal MySQL error
>> occured</b>.\n<br />Query: " . $query . "<br />\nError: (" .
>> mysql_errno() . ") " . mysql_error());
>> 
>> This is an echo of $query and runs in phpmyadmin.
>> 
>> INSERT INTO history (v_id,hour,visits,date) VALUES (45,0,59,'2010 01 27');
>> 
>> 
>> Any idea what is going on here?
>> 
>>  
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


--- End Message ---
--- Begin Message ---
Thank you.
You were right on the money, "hour" was the problem and the tick marks
solved it. I spent 3 hours trying to figure out why I never got an error but
there was no insert and  php myadmin does add the tick marks automatically.
 Probably a good habit to always use the tick marks.

Learn something new everyday.

On Thu, Feb 11, 2010 at 4:26 PM, Joseph Thayne <webad...@thaynefam.org>wrote:

> Try putting tick marks (`) around the field and table names.  So your SQL
> query would then look like:
>
>
> INSERT INTO `history` (`v_id`, `hour`, `visits`, `date`) VALUES (45, 0, 59,
> '2010 01 27');
>
> This is a good practice to get into.  The problem is that MySQL allows you
> to create tables and fields with the same name as functions.  If the tick
> marks are not there, then it assumes you mean to try using the function.  In
> your case, hour is a function in mysql.  I would assume that the reason it
> works in phpmyadmin is that it filters the query somehow to add the tick
> marks in.
>
> Joseph
>
>
> james stojan wrote:
>
>> I'm at my wits end trying to make this mysql statement insert work in
>> PHP. I'm not getting any errors from PHP or mysql but the insert fails
>> (nothing is inserted) error reporting is on and is reporting other
>> errors. When I echo out the query and manually paste it into PHP
>> myAdmin the query inserts without a problem. I know that I am
>> connecting to the database as well part of the data being inserted
>> comes from the same database and that the mysql user has permission to
>> do inserts (even tried as root no luck).
>>
>> $query="INSERT INTO upload_history (v_id,hour,visits,date) VALUES
>> (".$v_id.",".$hour.",".$visits.",'$date1'".");";
>>
>> $r2=mysql_query($query) or die("<b>A fatal MySQL error
>> occured</b>.\n<br />Query: " . $query . "<br />\nError: (" .
>> mysql_errno() . ") " . mysql_error());
>>
>> This is an echo of $query and runs in phpmyadmin.
>>
>> INSERT INTO history (v_id,hour,visits,date) VALUES (45,0,59,'2010 01 27');
>>
>>
>> Any idea what is going on here?
>>
>>
>>
>

--- End Message ---
--- Begin Message ---

Actually, the syntax is just fine. I personally would prefer it the way you mention, but there actually is nothing wrong with the syntax.

The ,'$date1'"." is not correct syntax, change it to ,'".$date."'

--- End Message ---
--- Begin Message ---
On Fri, Feb 12, 2010 at 8:27 AM, Joseph Thayne <webad...@thaynefam.org> wrote:
>
> Actually, the syntax is just fine.  I personally would prefer it the way you
> mention, but there actually is nothing wrong with the syntax.
>
>> The ,'$date1'"." is not correct syntax, change it to ,'".$date."'

My personal preference these days is to use Curly braces around
variables in strings such as this, I always find excessive string
concatenation such as is often used when building SQL queries hard to
read, and IIRC there was performance implications to it as well
(though I don't have access to concrete stats right now).

In your case, the variable would be something like this:

$query="INSERT INTO upload_history (v_id,hour,visits,date) VALUES
({$v_id}, {$hour}, {$visits}, '{$date}')";

Much more readable and maintainable IMO.

No need for the trailing semicolon in SQL that uses an API like you
are using so save another char there too.
Backticks around column names are not required and IMO again they just
make the code hard to read. Just because phpMyAdmin uses them, doesn't
mean we all need to.

Cheers

--- End Message ---
--- Begin Message --- That is a good idea to use the curly braces. I consistently forget about them, and fell like an idiot every time I am reminded of them.

As for the backticks, they are required because of MySQL, not because of phpMyAdmin. The issue was not that phpMyAdmin uses backticks, it is that MySQL pretty much requires them when naming a field the same as an internal function to my knowledge. If someone else knows of another way to designate to MySQL that a field named HOUR is the name of a field rather than the name of the internal function, I would love to know.

James McLean wrote:
On Fri, Feb 12, 2010 at 8:27 AM, Joseph Thayne <webad...@thaynefam.org> wrote:
Actually, the syntax is just fine.  I personally would prefer it the way you
mention, but there actually is nothing wrong with the syntax.

The ,'$date1'"." is not correct syntax, change it to ,'".$date."'

My personal preference these days is to use Curly braces around
variables in strings such as this, I always find excessive string
concatenation such as is often used when building SQL queries hard to
read, and IIRC there was performance implications to it as well
(though I don't have access to concrete stats right now).

In your case, the variable would be something like this:

$query="INSERT INTO upload_history (v_id,hour,visits,date) VALUES
({$v_id}, {$hour}, {$visits}, '{$date}')";

Much more readable and maintainable IMO.

No need for the trailing semicolon in SQL that uses an API like you
are using so save another char there too.
Backticks around column names are not required and IMO again they just
make the code hard to read. Just because phpMyAdmin uses them, doesn't
mean we all need to.

Cheers


--- End Message ---
--- Begin Message ---
Op 2/11/10 10:51 PM, James McLean schreef:
> On Fri, Feb 12, 2010 at 8:27 AM, Joseph Thayne <webad...@thaynefam.org> wrote:
>>
>> Actually, the syntax is just fine.  I personally would prefer it the way you
>> mention, but there actually is nothing wrong with the syntax.
>>
>>> The ,'$date1'"." is not correct syntax, change it to ,'".$date."'
> 
> My personal preference these days is to use Curly braces around
> variables in strings such as this, I always find excessive string
> concatenation such as is often used when building SQL queries hard to
> read, and IIRC there was performance implications to it as well
> (though I don't have access to concrete stats right now).
> 
> In your case, the variable would be something like this:
> 
> $query="INSERT INTO upload_history (v_id,hour,visits,date) VALUES
> ({$v_id}, {$hour}, {$visits}, '{$date}')";

actually IIRC the engine compiles that to OpCodes that equate to:


$query = 'INSERT INTO upload_history (v_id,hour,visits,date) VALUES ('.$v_id.', 
'.$hour.', '.$visits.', '\''.{$date}.'\')';

> 
> Much more readable and maintainable IMO.
> 
> No need for the trailing semicolon in SQL that uses an API like you
> are using so save another char there too.
> Backticks around column names are not required and IMO again they just
> make the code hard to read. Just because phpMyAdmin uses them, doesn't
> mean we all need to.
> 
> Cheers
> 


--- End Message ---
--- Begin Message ---
On Fri, Feb 12, 2010 at 9:31 AM, Jochem Maas <joc...@iamjochem.com> wrote:
> Op 2/11/10 10:51 PM, James McLean schreef:
>> My personal preference these days is to use Curly braces around
>> variables in strings such as this, I always find excessive string
>> concatenation such as is often used when building SQL queries hard to
>> read, and IIRC there was performance implications to it as well
>> (though I don't have access to concrete stats right now).
>>
>> In your case, the variable would be something like this:
>>
>> $query="INSERT INTO upload_history (v_id,hour,visits,date) VALUES
>> ({$v_id}, {$hour}, {$visits}, '{$date}')";
>
> actually IIRC the engine compiles that to OpCodes that equate to:
>
> $query = 'INSERT INTO upload_history (v_id,hour,visits,date) VALUES 
> ('.$v_id.', '.$hour.', '.$visits.', '\''.{$date}.'\')';

Interesting point, but the original code is still more readable, the
opcode's aren't our problem (at least in this case) :)

Cheers

--- End Message ---
--- Begin Message ---
On Fri, Feb 12, 2010 at 9:31 AM, Joseph Thayne <webad...@thaynefam.org> wrote:
> As for the backticks, they are required because of MySQL, not because of
> phpMyAdmin.  The issue was not that phpMyAdmin uses backticks, it is that
> MySQL pretty much requires them when naming a field the same as an internal
> function to my knowledge.  If someone else knows of another way to designate
> to MySQL that a field named HOUR is the name of a field rather than the name
> of the internal function, I would love to know.

Ahh I see :) Wasn't aware of that. Personally i've always been
over-descriptive when designing my tables which is possibly why I've
never run into that limitation :)

Thanks.

--- End Message ---
--- Begin Message --- Yeah, I am a lot more descriptive now. I ran into it quite a bit when I was first starting out.

James McLean wrote:
On Fri, Feb 12, 2010 at 9:31 AM, Joseph Thayne <webad...@thaynefam.org> wrote:
As for the backticks, they are required because of MySQL, not because of
phpMyAdmin.  The issue was not that phpMyAdmin uses backticks, it is that
MySQL pretty much requires them when naming a field the same as an internal
function to my knowledge.  If someone else knows of another way to designate
to MySQL that a field named HOUR is the name of a field rather than the name
of the internal function, I would love to know.

Ahh I see :) Wasn't aware of that. Personally i've always been
over-descriptive when designing my tables which is possibly why I've
never run into that limitation :)

Thanks.


--- End Message ---
--- Begin Message ---
On Fri, Feb 12, 2010 at 09:44:47AM +1030, James McLean wrote:

> On Fri, Feb 12, 2010 at 9:31 AM, Joseph Thayne <webad...@thaynefam.org> wrote:
> > As for the backticks, they are required because of MySQL, not because of
> > phpMyAdmin.  The issue was not that phpMyAdmin uses backticks, it is that
> > MySQL pretty much requires them when naming a field the same as an internal
> > function to my knowledge.  If someone else knows of another way to designate
> > to MySQL that a field named HOUR is the name of a field rather than the name
> > of the internal function, I would love to know.

Backticks are also required to preserve casing in MySQL, if you name
something in mixed or upper case; MySQL lowercases table and field names
otherwise. It's a silly misfeature of MySQL. 

I can't conceive of why a DBMS would assume something which should be
understood in the context of a field name should instead be interpreted
as a function call. Buy maybe that's just me.

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
I was going to write an example as to what should happen instead of what
actually does when id dawned on me why MySQL works the way it does.  One of
the biggest complaints people have with MySQL is in speed.  To demonstrate
what I just realized, take the following statement that will select the hour
from a given time as well as the value from the hour field:

SELECT HOUR('13:42:37') as thehour, hour FROM mytable;

Not a big deal and pretty straight forward.  What about the following?

SELECT HOUR(mydate) as thehour, hour FROM mytable;

Still pretty simple to determine which are the functions and which are the
field names.  However, take the following:

SELECT HOUR(NOW()) as thehour, hour FROM mytable;

As humans, glancing at it, it makes perfect sense to us as to which is
which.  However, try telling a computer how to interpret the above
statement.  You could look for parenthesis.  That would work fine on the
first two statements, but once you get to the third, you have to worry about
recursion and all possible permutations of the data that could come through.
This exponentially increases the complexity and processing time/power
required to run the query.  Granted, that query is a simple one, but plug it
into a query filled with multiple joins, and you have the potential of a
nightmare.  So why focus on adding in functionality that adds so much
complexity and will end up requiring that much extra support when a simple
character (the tick mark) will take care of the work for you and you can
then focus on other things such as data integrity and general processing
speed?

Joseph

-----Original Message-----
From: Paul M Foster [mailto:pa...@quillandmouse.com] 
Sent: Thursday, February 11, 2010 9:15 PM
To: php-gene...@lists.php.net
Subject: Re: [PHP] Mysql statement works in phpmyadmin but not in php page

On Fri, Feb 12, 2010 at 09:44:47AM +1030, James McLean wrote:

> On Fri, Feb 12, 2010 at 9:31 AM, Joseph Thayne <webad...@thaynefam.org>
wrote:
> > As for the backticks, they are required because of MySQL, not because of
> > phpMyAdmin.  The issue was not that phpMyAdmin uses backticks, it is
that
> > MySQL pretty much requires them when naming a field the same as an
internal
> > function to my knowledge.  If someone else knows of another way to
designate
> > to MySQL that a field named HOUR is the name of a field rather than the
name
> > of the internal function, I would love to know.

Backticks are also required to preserve casing in MySQL, if you name
something in mixed or upper case; MySQL lowercases table and field names
otherwise. It's a silly misfeature of MySQL. 

I can't conceive of why a DBMS would assume something which should be
understood in the context of a field name should instead be interpreted
as a function call. Buy maybe that's just me.

Paul

-- 
Paul M. Foster

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


--- End Message ---
--- Begin Message ---
On Thu, Feb 11, 2010 at 09:49:02PM -0600, Joseph Thayne wrote:

> I was going to write an example as to what should happen instead of what
> actually does when id dawned on me why MySQL works the way it does.  One of
> the biggest complaints people have with MySQL is in speed.  

The much-vaunted speed of MySQL is the biggest complaint? Sheesh.

> To demonstrate
> what I just realized, take the following statement that will select the hour
> from a given time as well as the value from the hour field:
> 
> SELECT HOUR('13:42:37') as thehour, hour FROM mytable;
> 
> Not a big deal and pretty straight forward.  What about the following?
> 
> SELECT HOUR(mydate) as thehour, hour FROM mytable;
> 
> Still pretty simple to determine which are the functions and which are the
> field names.  However, take the following:
> 
> SELECT HOUR(NOW()) as thehour, hour FROM mytable;
> 
> As humans, glancing at it, it makes perfect sense to us as to which is
> which.  However, try telling a computer how to interpret the above
> statement.  You could look for parenthesis.  That would work fine on the
> first two statements, but once you get to the third, you have to worry about
> recursion and all possible permutations of the data that could come through.
> This exponentially increases the complexity and processing time/power
> required to run the query.  Granted, that query is a simple one, but plug it
> into a query filled with multiple joins, and you have the potential of a
> nightmare.  So why focus on adding in functionality that adds so much
> complexity and will end up requiring that much extra support when a simple
> character (the tick mark) will take care of the work for you and you can
> then focus on other things such as data integrity and general processing
> speed?

I understand what you're saying, and you may be right about why MySQL
was built this way. However, it's like telling the programmers not to
build a better parser; just make the user backtick stuff so we don't
have to write a proper parser. For a one-off script only I was going to
use, I'd do this. But not for a professional level product used by
millions, speed or no speed. Imagine if K&R had tried to shortcut the C
parser this way; the C parser is almost endlessly re-entrant and must
accommodate some seriously obfuscated code. Which it does reliably.
Besides, if you've got a parser which understands joins, parsing things
like the distinction between hour (field name) and hour (function call)
is a piece of cake.

If a programmer working for me tried to pawn this off as a "done", I'd
make him redo it. Again, maybe it's just me.

Anyway, we're way off topic....

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
On Thu, 11 Feb 2010 10:18:18 +0000, a...@ashleysheridan.co.uk (Ashley Sheridan) 
wrote:

>On Thu, 2010-02-11 at 10:16 +1100, Ross McKay wrote:
>
...........
>
>There's a good reason for OpenOffice having some difficulties with MS
>Office documents. Back when MS rushed through getting their document
>standard ratified by ISO (which itself is a whole other story) they
>didn't explain all the details quite as well as they might have. Later
>on, MS found they were having some difficulty following their own
>'standard' and so altered it in various ways in Office2007. Needless to
>say, ISO weren't too happy when MS asked if they could just 'change the
>specs' for their file format, and quite rightly refused to do so.
>
>In short, this means that there is a MS ISO standard that MS is the only
>one not trying to follow, and software like OpenOffice is left to
>reverse engineering the format again.

When the first Word Macro virus appeared in the early 90s, the AV industry 
approached
Microsoft for the specifications of the internal structure of the Word 
documents. After
some discussion Microsoft agreed to make these available to firms who signed an 
NDA.
Several large firms did so, but when they got the specifications they 
immediately
discovered that they bore very little relation to the actual documents. When 
Microsoft was
approached about this their reply was "Well, that's all we've got!"  

The industry had to run a joint program to reverse engineer the specifications 
before they
could work out how to remove the virus.

The story that went around was that with each update Microsoft hired a new 
batch of young
graduates <aside>they don't have preconceived notions (a.k.a. experience), and 
they don't
have extravagant ideas of their own worth</aside>, told them vaguely what they 
wanted, and
left them to it. Then, as soon as they had something that sort of worked, they 
let them go
again. So there was no continuity, no documentation, no hope of bug fixes, and 
very little
likelihood that the next update would be improved in any meaningful sense.  I 
have seen
nothing to suggest that anything has changed.

And Bill actually likes it this way!  Someone who did a lot of support work for 
small and
medium enterprises told me that the biggest pressure for updating to the latest 
version
came from workers envious of the new employee, with his new computer and the 
new version
of the Microsoft rubbish --- sorry, wonder product.


--- End Message ---
--- Begin Message ---
On Fri, Feb 12, 2010 at 12:13:11PM +1100, clanc...@cybec.com.au wrote:

> On Thu, 11 Feb 2010 10:18:18 +0000, a...@ashleysheridan.co.uk (Ashley
> Sheridan) wrote:
> 
> >On Thu, 2010-02-11 at 10:16 +1100, Ross McKay wrote:
> >
> ...........
> >
> >There's a good reason for OpenOffice having some difficulties with MS
> >Office documents. Back when MS rushed through getting their document
> >standard ratified by ISO (which itself is a whole other story) they
> >didn't explain all the details quite as well as they might have. Later
> >on, MS found they were having some difficulty following their own
> >'standard' and so altered it in various ways in Office2007. Needless to
> >say, ISO weren't too happy when MS asked if they could just 'change the
> >specs' for their file format, and quite rightly refused to do so.
> >
> >In short, this means that there is a MS ISO standard that MS is the only
> >one not trying to follow, and software like OpenOffice is left to
> >reverse engineering the format again.
> 
> When the first Word Macro virus appeared in the early 90s, the AV industry
> approached
> Microsoft for the specifications of the internal structure of the Word
> documents. After
> some discussion Microsoft agreed to make these available to firms who
> signed an NDA.
> Several large firms did so, but when they got the specifications they
> immediately
> discovered that they bore very little relation to the actual documents. When
> Microsoft was
> approached about this their reply was "Well, that's all we've got!"
> 
> The industry had to run a joint program to reverse engineer the
> specifications before they
> could work out how to remove the virus.
> 
> The story that went around was that with each update Microsoft hired a
> new batch of young
> graduates <aside>they don't have preconceived notions (a.k.a. experience),
> and they don't
> have extravagant ideas of their own worth</aside>, told them vaguely what
> they wanted, and
> left them to it. Then, as soon as they had something that sort of worked,
> they let them go
> again. So there was no continuity, no documentation, no hope of bug fixes,
> and very little
> likelihood that the next update would be improved in any meaningful sense.
> I have seen
> nothing to suggest that anything has changed.

I suspect any lack of continuity was more due to the shifting of
personnel internally to differing projects, rather than the hiring of
all new coders each time.

But more importantly, I suspect MS coders just coded without writing any
docs. Coders usually suck at documentation and will avoid it unless
forced. And if forced to write docs, the docs were just a toss-off no
one ever actually looked at.

Microsoft's attitude, I'm sure was, "Why should we care about other
players in the market? Just buy our crap and you won't have to worry
about our formats." (Except until the next upgrade.)

I think ISO's policy should be that if you're a company forwarding a
standard, your off-the-shelf software should verifiably duplicate that
standard. Otherwise, go pound sand. Same if you're a community proposing
a standard. Produce some software which adheres to that standard or shut
up.

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
Hi,

I know that we can limit the size of upload file by specify
upload_max_filesize, post_max_size and even memory_limit parameters.
Though we can change these parameters, can someone please let me know what
the maximum value of these parameters can be? What is the factors we need to
take into account when specify these values.


Many thank,

Pinate
-- 
View this message in context: 
http://old.nabble.com/the-limitation-of-upload_max_filesize%2C-post_max_size-tp27556756p27556756.html
Sent from the PHP - General mailing list archive at Nabble.com.


--- End Message ---
--- Begin Message ---
Hi,

I have some code to download large files as part of a larger class. I've
been in a discussion with the developer of a library that I'm using who has
told me clearly that my code will not work at all, even though it does. He
is suggesting my problems are due to my not understanding the nature of
fread() even the code is very similar to examples on php.net.

I do get very rare timeout problems where the stream_set_timeout() does not
seem to be firing, and PHP exits on a general timeout. However I'm using
this under Tomcat and the logs are not giving me as much information as
under Apache webserver, where I have been unable to reproduce this problem.
So it's proving difficult to track down and I'm not able to reproduce the
error consistently. I would appreciate any comments about the validity of
the code (at the bottom) so I have a better idea whether it is my problem,
or not. It might be that I need to catch and handle the error, but that is
an area where I have no experience as yet.

I'm aware the code could be rewritten in CURL, but for now I'm more after an
understanding of what problems there might be, if any, with this approach.
The server is returning content-length in the header, and chunk encoding is
not an approach I'm intending to use right now.

Also, I'd appreciate any ideas on what the developer might mean by the
following quote. He's asked that I do not use his mailing list anymore and
should take my questions to php-general, so it would be impolite to ignore
this so I can ask him to explain further:

"3. The network buffer used by the PHP streams implementation reads data
eagerly. If you fread($socket, 1024) and the network buffer already
contains 24 bytes, PHP will try to read 1000 bytes nevertheless."

My understanding is the fread() will wait until is has 1024 bytes (in this
example) and then return that, unless EOF is encountered when the data up to
and including EOF is returned. I'm not sure what he's trying to say.

Many thanks for any advice on this.


Mark...

Code:
(The intentions are: used for downloading very large files while avoiding
memory problems, this is contained in a loop for a list of files, if the
socket is unavailable then the download is not attempted for that file, if
the socket is available but no data is received in a 30 second period, then
that download should be aborted and retried up to 5 times)

          $download_attempt = 1;
          do {
            $fs = fopen('http://' . $host . $file, "rb");

            if (!$fs) {
              $this->writeDebugInfo("FAILED to open stream for ", "http://";
. $host . $file);
            } else {

              $fm = fopen ($temp_file_name, "w");
              stream_set_timeout($fs, 30);

              while(!feof($fs)) {
                $contents = fread($fs, 4096); // Buffered download
                fwrite($fm, $contents);
                $info = stream_get_meta_data($fs);
                if ($info['timed_out']) {
                  break;
                }
              }
              fclose($fm);
              fclose($fs);

              if ($info['timed_out']) {
                // Delete temp file if fails
                unlink($temp_file_name);
                $this->writeDebugInfo("FAILED on attempt " .
$download_attempt . " - Connection timed out: ", $temp_file_name);
                $download_attempt++;
                if ($download_attempt < 5) {
                  $this->writeDebugInfo("RETRYING: ", $temp_file_name);
                }
              } else {
                // Move temp file if succeeds
                $media_file_name = str_replace('temp/', 'media/',
$temp_file_name);
                rename($temp_file_name, $media_file_name);
                $this->newDownload = true;
                $this->writeDebugInfo("SUCCESS: ", $media_file_name);
              }
            }
          } while ($download_attempt < 5 && $info['timed_out']);

--- End Message ---
--- Begin Message ---
hi

i am from auckland new zealand, has anyone worked on expression engine cms

please advice

thanks

--- End Message ---

Reply via email to