[PHP] Re: Dynamic Titles

2009-06-12 Thread David Robley
Austin Caudill wrote:

> Hello, im trying to make the CMS system im using more SEO friendly by
> giving each page it's own title. Right now, the system assigns all pages
> the same general title. I would like to use PHP to discertain which page
> is being viewed and in turn, which title should be used.
> 
> I have put in the title tags the variable "$title". As for the PHP im
> using, I scripted the following:
> 
> $url = "http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']'";
> switch ( $url )
> {
> default:
> $title = "Photoshop tutorials, Flash tutorials, and more! Newtuts Tutorial
> Search"; break;
> 
> case "$config[HTTP_SERVER]help.php" :
> $title = "Newtuts Help";
> break;
> }
> 
> Right now, im getting this error:
> Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
> T_STRING or T_VARIABLE or T_NUM_STRING in
> /home/a7201901/public_html/includes/classes/tutorial.php on line 803
> 
> Can someone please help me with this?
> 
> 
> 
> Thanks!
I'm guessing that line 803 is

$url = "http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']'";

which is full of mismatched quotes :-) Try any of

$url = "http://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}";
$url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];

Cheers
-- 
David Robley

Life is only as long as you live it.
Today is Pungenday, the 17th day of Confusion in the YOLD 3175. 


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



[PHP] 3d image rotating

2009-06-12 Thread דניאל דנון
Hello.

I'm looking for way to rotate normal images, but not x/y, but with Z also.
I get a source image (png, jpg, gif...) and I want to rotate it. assuming
the "depth" of the image is 1 pixel for example...

I'm looking for a way to do it without using imagemagick - only GD. I know
it might be slower, but its need to run on a server without imagemagick.

I've searched information about it, also in PEAR, but I couldn't find
anything that takes a normal image and rotate it..

Thanks, Daniel

-- 
Use ROT26 for best security


[PHP] Re: Dynamic Titles

2009-06-12 Thread Peter Ford
David Robley wrote:
> Austin Caudill wrote:
> 
>> Hello, im trying to make the CMS system im using more SEO friendly by
>> giving each page it's own title. Right now, the system assigns all pages
>> the same general title. I would like to use PHP to discertain which page
>> is being viewed and in turn, which title should be used.
>>
>> I have put in the title tags the variable "$title". As for the PHP im
>> using, I scripted the following:
>>
>> $url = "http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']'";
>> switch ( $url )
>> {
>> default:
>> $title = "Photoshop tutorials, Flash tutorials, and more! Newtuts Tutorial
>> Search"; break;
>>
>> case "$config[HTTP_SERVER]help.php" :
>> $title = "Newtuts Help";
>> break;
>> }
>>
>> Right now, im getting this error:
>> Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
>> T_STRING or T_VARIABLE or T_NUM_STRING in
>> /home/a7201901/public_html/includes/classes/tutorial.php on line 803
>>
>> Can someone please help me with this?
>>
>>
>>
>> Thanks!
> I'm guessing that line 803 is
> 
> $url = "http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']'";
> 
> which is full of mismatched quotes :-) Try any of
> 
> $url = "http://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}";
> $url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
> $url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
> 
> Cheers

Also the line:

  case "$config[HTTP_SERVER]help.php" :

probably won't work very well : should be either

  case $config[HTTP_SERVER].'help.php':

or

  case "{$config[HTTP_SERVER]}help.php":

according to whether you like interpolation in quotes or not.


I recommend finding a development environment or editor that does syntax
highlighting - that would catch all of these problems before you even save the 
file.

-- 
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Field type for american money

2009-06-12 Thread Andrew Ballard
On Thu, Jun 11, 2009 at 4:08 PM, revDAVE wrote:
> Php - MySQL - newbie question
>
> - Field type for american money - int(11) seems to work fine
>
> - but also I tried decimal(10,2)
>
> Is one a better choice than another for american money usage?
>
>
> --
> Thanks - RevDave
> Cool @ hosting4days . com
> [db-lists 09]

It depends on what you need to store, honestly. If all your dollar
amounts are integers, int would work fine. If you need decimals,
decimal(10, 2) would be fine for a lot of applications. However, a lot
of financial applications need a little more precision. SQL Server has
a money datatype that looks like it's about equivalent to decimal(19,
4) and a smallmoney type that looks like it's equivalent to
decimal(10, 4). That handles things like gas prices that always have
that extra 9/10 of a penny tacked onto them, or items that are 3 for a
dollar. If you enter a price of 0.33 in a decimal(10, 2) field,
multiplying that by 3 will result in 0.99, whereas three items priced
at 0. will come to 0., which when formatted to two digits will
round to 1.00.

Andrew

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



[PHP] How do I Upload XML file using cUrl?

2009-06-12 Thread Rahul S. Johari

Ave,

I have a client who used Lead360.Com to manage their Leads. We have a  
Leads Management application in place that creates an XML file of the  
lead which give the client manually to download.


What are client is requesting is to POST the XML File directly to  
their Leads360.Com account. We have a POST Url from Leads360 where we  
can send the lead, but I'm not sure what kind of a cUrl script I need  
to use to POST an XML file. I've handled POST Data before using cUrl  
but I haven't written a cUrl script that uploads a file to a URL.


From what I have gathered so far ... this is what I have ...

[CODE]

$filename = "file.xml";
$handle = fopen($filename, "r");
$XPost = fread($handle, filesize($filename));
fclose($handle);

$url = "https://secure.leads360.com/Import.aspx";;
$ch = curl_init(); // initialize curl handle

curl_setopt($ch, CURLOPT_VERBOSE, 1); // set url to post to
curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 40); // times out after 4s
curl_setopt($ch, CURLOPT_POSTFIELDS, $XPost); // add POST fields
curl_setopt($ch, CURLOPT_POST, 1);

$result = curl_exec($ch); // run the whole process

[END CODE]

Am I on the right track here or am I missing something?

Thanks Guys!

---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com





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



Re: [PHP] Re: Dynamic Titles

2009-06-12 Thread Martin Scotta
PHP complains (usually) after the error.

1.
2. for( $i=0; $i<10; ++$i )
3. echo $i, "\n"   # missing ;
4.
5. unset( $i );

PHP will complain about unexpected T_UNSET at line 5

Why? Because PHP is expecting a anything different to unset.

So, when PHP says that an error was found at line x take a look at line x-1

Mrtn

On Fri, Jun 12, 2009 at 7:44 AM, Peter Ford  wrote:

> David Robley wrote:
> > Austin Caudill wrote:
> >
> >> Hello, im trying to make the CMS system im using more SEO friendly by
> >> giving each page it's own title. Right now, the system assigns all pages
> >> the same general title. I would like to use PHP to discertain which page
> >> is being viewed and in turn, which title should be used.
> >>
> >> I have put in the title tags the variable "$title". As for the PHP im
> >> using, I scripted the following:
> >>
> >> $url = "http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']'";
> >> switch ( $url )
> >> {
> >> default:
> >> $title = "Photoshop tutorials, Flash tutorials, and more! Newtuts
> Tutorial
> >> Search"; break;
> >>
> >> case "$config[HTTP_SERVER]help.php" :
> >> $title = "Newtuts Help";
> >> break;
> >> }
> >>
> >> Right now, im getting this error:
> >> Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
> expecting
> >> T_STRING or T_VARIABLE or T_NUM_STRING in
> >> /home/a7201901/public_html/includes/classes/tutorial.php on line 803
> >>
> >> Can someone please help me with this?
> >>
> >>
> >>
> >> Thanks!
> > I'm guessing that line 803 is
> >
> > $url = "http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']'";
> >
> > which is full of mismatched quotes :-) Try any of
> >
> > $url = "http://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}";
> > $url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
> > $url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
> >
> > Cheers
>
> Also the line:
>
>  case "$config[HTTP_SERVER]help.php" :
>
> probably won't work very well : should be either
>
>  case $config[HTTP_SERVER].'help.php':
>
> or
>
>  case "{$config[HTTP_SERVER]}help.php":
>
> according to whether you like interpolation in quotes or not.
>
>
> I recommend finding a development environment or editor that does syntax
> highlighting - that would catch all of these problems before you even save
> the file.
>
> --
> Peter Ford  phone: 01580 89
> Developer   fax:   01580 893399
> Justcroft International Ltd., Staplehurst, Kent
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Martin Scotta


Re: [PHP] [php] read/write error

2009-06-12 Thread HELP!
I can not get the stream_get_contents() to work.  it's returning empty.
If you have a login details "ALOGINPASS 1A" cant you just fwrite($ft,
"ALOGINPASS 1A"); or do you need to add other things


what is the meaning of this string" GET / HTTP/1.0\r\nHost:
www.example.com\r\nAccept : */*\r\n\r\n"

On Wed, Jun 10, 2009 at 3:51 PM, Robin Vickery  wrote:

> 2009/6/8 HELP! 
>
>> opening of the sorket is ok and writting LOGIN packet to the sorket is
>> also
>> ok but reading the response to know if the login is accepted or rejected
>> is
>> a not OK.
>
>
> Don't use fread() to read from sockets, use stream_get_contents(). Example
> 3 on the fread() manual page tells you why.
>
> -robin
>



-- 
www.bemycandy.com


[PHP] socket communication programming

2009-06-12 Thread HELP!
hi
I can not get the stream_get_contents() to work.  it's returning empty.
If you have a login details "ALOGINPASS 1A" cant you just fwrite($ft,
"ALOGINPASS 1A"); or do you need to add other things


what is the meaning of this string" GET / HTTP/1.0\r\nHost:
www.example.com\r\nAccept : */*\r\n\r\n"

www.bemycandy.com


[PHP] truncate a mb-string to a given octet length?

2009-06-12 Thread Tom Worster
say a table in the db has a varchar(255) column, 255 being the max number of
octets of strings that can go in the column. now say the php script very
occasionally has to deal with utf8 input strings with octet length > 255 --
it needs to select rows matching the input string or insert the input
string.

so what i think i need is a function to truncate a utf8 string to the
longest valid utf8 string that has octet length <= 255.

is this what mb_strcut() is for? i'm having a hard time understanding the
man page for that function.



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



Re: [PHP] socket communication programming

2009-06-12 Thread Shawn McKenzie
HELP! wrote:
> hi
> I can not get the stream_get_contents() to work.  it's returning empty.
> If you have a login details "ALOGINPASS 1A" cant you just fwrite($ft,
> "ALOGINPASS 1A"); or do you need to add other things
> 
Depends upon what the server is expecting.
> 
> what is the meaning of this string" GET / HTTP/1.0\r\nHost:
> www.example.com\r\nAccept : */*\r\n\r\n"

Those are some header from a get request, though looking malformed maybe.

> www.bemycandy.com
> 

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] truncate a mb-string to a given octet length?

2009-06-12 Thread Eddie Drapkin
Correct me if I'm wrong, but should varchar 255 with a utf8 character set
mean 255 unicode characters, not octets?

On Fri, Jun 12, 2009 at 11:50 AM, Tom Worster  wrote:

> say a table in the db has a varchar(255) column, 255 being the max number
> of
> octets of strings that can go in the column. now say the php script very
> occasionally has to deal with utf8 input strings with octet length > 255 --
> it needs to select rows matching the input string or insert the input
> string.
>
> so what i think i need is a function to truncate a utf8 string to the
> longest valid utf8 string that has octet length <= 255.
>
> is this what mb_strcut() is for? i'm having a hard time understanding the
> man page for that function.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] [php] read/write error

2009-06-12 Thread Robin Vickery
Hello Mr HELP!

2009/6/12 HELP! 
>
> I can not get the stream_get_contents() to work.  it's returning empty.

Is that simply because there's nothing to read from the socket?

> If you have a login details "ALOGINPASS 1A" cant you just fwrite($ft, 
> "ALOGINPASS 1A"); or do you need to add other things

You've not told us what protocol you're using, but a quick google
search seems to indicate that you're trying to send a login request
message for a market data stream.

You appear to using the character 'A' as the request terminator,
whereas market data streams generally use 0x0A, which is a linefeed
character.

If the stream hasn't realised you've finished sending your login
request, then it won't send a response.

> what is the meaning of this string" GET / HTTP/1.0\r\nHost: 
> www.example.com\r\nAccept: */*\r\n\r\n"

It's a HTTP 1.0 GET request, but that doesn't seem to be consistent
with the rest of the data you've mentioned.

-robin

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



Re: [PHP] [php] read/write error

2009-06-12 Thread HELP!
ALSO TRYING 0X0A or A still no respond. its realy frustrating becuase
written or readiing is a simple straight foward

On Wed, Jun 10, 2009 at 3:51 PM, Robin Vickery  wrote:

> 2009/6/8 HELP! 
>
>> opening of the sorket is ok and writting LOGIN packet to the sorket is
>> also
>> ok but reading the response to know if the login is accepted or rejected
>> is
>> a not OK.
>
>
> Don't use fread() to read from sockets, use stream_get_contents(). Example
> 3 on the fread() manual page tells you why.
>
> -robin
>



-- 
www.bemycandy.com


[PHP] phpMyAdmin, localhost, mysql overhead

2009-06-12 Thread Jônatas Zechim
Hi there, i have this table running on my localhost:

CREATE TABLE `caffecheckout_compra_itens` (
  `compra_key` varchar(23) NOT NULL,
  `item_id` int(5) NOT NULL,
  `item_valor` decimal(10,2) NOT NULL,
  `item_peso` decimal(5,3) NOT NULL,
  `item_qtd` int(3) NOT NULL,
  `item_data` int(10) NOT NULL,
  `item_obs` varchar(100) NOT NULL,
  PRIMARY KEY  (`item_id`),
  KEY `compra_key` (`compra_key`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


It's on my Server, but when I add a row and after remove that I'd overhead this 
table (58bytes/row), anyone know why is this happening?

I run this SQL:

INSERT INTO 
caffecheckout_compra_itens 
(compra_key,item_id,item_valor,item_peso,item_qtd,item_data) 
VALUES 
('12448259804a32897ce1116','2','19.90','0.250',1,'1244825980') 
ON DUPLICATE KEY UPDATE 
item_qtd=item_qtd+1

And after:

DELETE FROM 
caffecheckout_compra_itens 
WHERE 
compra_key='12448259804a32897ce1116'


Zechim


-Mensagem original-
De: Andrew Ballard [mailto:aball...@gmail.com] 
Enviada em: sexta-feira, 12 de junho de 2009 09:38
Para: revDAVE
Cc: php-general@lists.php.net
Assunto: Re: [PHP] Field type for american money

On Thu, Jun 11, 2009 at 4:08 PM, revDAVE wrote:
> Php - MySQL - newbie question
>
> - Field type for american money - int(11) seems to work fine
>
> - but also I tried decimal(10,2)
>
> Is one a better choice than another for american money usage?
>
>
> --
> Thanks - RevDave
> Cool @ hosting4days . com
> [db-lists 09]

It depends on what you need to store, honestly. If all your dollar
amounts are integers, int would work fine. If you need decimals,
decimal(10, 2) would be fine for a lot of applications. However, a lot
of financial applications need a little more precision. SQL Server has
a money datatype that looks like it's about equivalent to decimal(19,
4) and a smallmoney type that looks like it's equivalent to
decimal(10, 4). That handles things like gas prices that always have
that extra 9/10 of a penny tacked onto them, or items that are 3 for a
dollar. If you enter a price of 0.33 in a decimal(10, 2) field,
multiplying that by 3 will result in 0.99, whereas three items priced
at 0. will come to 0., which when formatted to two digits will
round to 1.00.

Andrew

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


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



Re: [PHP] truncate a mb-string to a given octet length?

2009-06-12 Thread Tom Worster
On 6/12/09 11:52 AM, "Eddie Drapkin"  wrote:

> Correct me if I'm wrong, but should varchar 255 with a utf8 character set mean
> 255 unicode characters, not octets?

in mysql, the length refers to the storage space of the string, not the
decoded character count. i don't know about other dbms.


> On Fri, Jun 12, 2009 at 11:50 AM, Tom Worster  wrote:
> say a table in the db has a varchar(255) column, 255 being the max number of
>> octets of strings that can go in the column. now say the php script very
>> occasionally has to deal with utf8 input strings with octet length > 255 --
>> it needs to select rows matching the input string or insert the input
>> string.
>> 
>> so what i think i need is a function to truncate a utf8 string to the
>> longest valid utf8 string that has octet length <= 255.
>> 
>> is this what mb_strcut() is for? i'm having a hard time understanding the
>> man page for that function.



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



Re: [PHP] phpMyAdmin, localhost, mysql overhead

2009-06-12 Thread Nitsan Bin-Nun
I haven't read all your mail, I'm sorry for it in advance, but I think that
you should know that "overheard" is just a blasting phrase for something
which was made up by phpmyadmin.

Basically, when you run a lot of DELETE or UPDATE queries on a table an
"overhead" is created, generally speaking this "overhead" is a space between
rows in the database file, which will cause mysql engine to insert rows into
this space on future INSERT queries.

You can imagine your table as a hard drive, every couple of months (some may
say weeks) you have to run a de-fragment on it, you can do the same with
your database table, look up the query OPTIMIZE TABLE which will do the
de-frag for you :)

If you have any further questions feel free to bring them up.

Regards,
Nitsan

On Fri, Jun 12, 2009 at 7:02 PM, Jônatas Zechim wrote:

> Hi there, i have this table running on my localhost:
>
> CREATE TABLE `caffecheckout_compra_itens` (
>  `compra_key` varchar(23) NOT NULL,
>  `item_id` int(5) NOT NULL,
>  `item_valor` decimal(10,2) NOT NULL,
>  `item_peso` decimal(5,3) NOT NULL,
>  `item_qtd` int(3) NOT NULL,
>  `item_data` int(10) NOT NULL,
>  `item_obs` varchar(100) NOT NULL,
>  PRIMARY KEY  (`item_id`),
>  KEY `compra_key` (`compra_key`)
> ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
>
>
> It's on my Server, but when I add a row and after remove that I'd overhead
> this table (58bytes/row), anyone know why is this happening?
>
> I run this SQL:
>
> INSERT INTO
>caffecheckout_compra_itens
>(compra_key,item_id,item_valor,item_peso,item_qtd,item_data)
> VALUES
>('12448259804a32897ce1116','2','19.90','0.250',1,'1244825980')
> ON DUPLICATE KEY UPDATE
>item_qtd=item_qtd+1
>
> And after:
>
> DELETE FROM
>caffecheckout_compra_itens
> WHERE
>compra_key='12448259804a32897ce1116'
>
>
> Zechim
>
>
> -Mensagem original-
> De: Andrew Ballard [mailto:aball...@gmail.com]
> Enviada em: sexta-feira, 12 de junho de 2009 09:38
> Para: revDAVE
> Cc: php-general@lists.php.net
> Assunto: Re: [PHP] Field type for american money
>
> On Thu, Jun 11, 2009 at 4:08 PM, revDAVE wrote:
> > Php - MySQL - newbie question
> >
> > - Field type for american money - int(11) seems to work fine
> >
> > - but also I tried decimal(10,2)
> >
> > Is one a better choice than another for american money usage?
> >
> >
> > --
> > Thanks - RevDave
> > Cool @ hosting4days . com
> > [db-lists 09]
>
> It depends on what you need to store, honestly. If all your dollar
> amounts are integers, int would work fine. If you need decimals,
> decimal(10, 2) would be fine for a lot of applications. However, a lot
> of financial applications need a little more precision. SQL Server has
> a money datatype that looks like it's about equivalent to decimal(19,
> 4) and a smallmoney type that looks like it's equivalent to
> decimal(10, 4). That handles things like gas prices that always have
> that extra 9/10 of a penny tacked onto them, or items that are 3 for a
> dollar. If you enter a price of 0.33 in a decimal(10, 2) field,
> multiplying that by 3 will result in 0.99, whereas three items priced
> at 0. will come to 0., which when formatted to two digits will
> round to 1.00.
>
> Andrew
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] Re: truncate a mb-string to a given octet length?

2009-06-12 Thread Tom Worster
On 6/12/09 11:50 AM, "Tom Worster"  wrote:

> say a table in the db has a varchar(255) column, 255 being the max number of
> octets of strings that can go in the column. now say the php script very
> occasionally has to deal with utf8 input strings with octet length > 255 -- it
> needs to select rows matching the input string or insert the input string.
> 
> so what i think i need is a function to truncate a utf8 string to the longest
> valid utf8 string that has octet length <= 255.
> 
> is this what mb_strcut() is for? i'm having a hard time understanding the man
> page for that function.

i satisfied myself that mb_cutstr() probably does what i need with the
following:

$default_locale = setlocale(LC_ALL, 'en_US.UTF-8');
ini_set('default_charset', 'UTF-8' );

$strs = array(
'Iñtërnâtiônàlizætiøn',
'החמאס: רוצים להשלים את עסקת שליט במהירות האפשרית',
'ايران لا ترى تغييرا في الموقف الأمريكي',
'独・米で死傷者を出した銃の乱射事件',
'國會預算處公布驚人的赤字數據後',
'이며 세계 경제 회복에 걸림돌이 되고 있다',
'В дагестанском лесном массиве южнее села Какашура',
'นายประสิทธิ์ รุ่งสะอาด ปลัดเทศบาล รักษาการแทนนายกเทศมนตรี
ต.ท่าทองใหม่',
'ભારતીય ટીમનો સુવર્ણ યુગ : કિવીઝમાં પણ કમાલ',
'ཁམས་དཀར་མཛེས་ས་ཁུལ་དུ་རྒྱ་གཞུང་ལ་ཞི་བའི་ངོ་རྒོལ་',
'Χιόνια, βροχές και θυελλώδεις άνεμοι συνθέτουν το',
'Հայաստանում սկսվել է դատական համակարգի ձեւավորումը',
'რუსეთი ასევე გეგმავს სამხედრო');

foreach ( $strs as $s ) {

for ( $i=10; $i<100; $i+=10) {
$t = mb_strcut($s, 0, $i);
$ok = mb_check_encoding($t, 'UTF-8') ? 'OK' : 'Bad';
print("$i\t" . mb_strlen($t, 'ISO-8859-1') . "\t"
. mb_strlen($t, 'UTF-8') . "\t$ok\t$t\n");
}

}



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



RES: [PHP] phpMyAdmin, localhost, mysql overhead

2009-06-12 Thread Jônatas Zechim
I have other tables running but only this give me ‘overhead’.

 

I’d know why this table does this and if is bad for my MySQL Server?

Is there anyway to avoid it?

 

Zechim

 

De: nit...@binnun.co.il [mailto:nit...@binnun.co.il] Em nome de Nitsan
Bin-Nun
Enviada em: sexta-feira, 12 de junho de 2009 14:33
Para: Jônatas Zechim
Cc: php-general@lists.php.net
Assunto: Re: [PHP] phpMyAdmin, localhost, mysql overhead

 

I haven't read all your mail, I'm sorry for it in advance, but I think that
you should know that "overheard" is just a blasting phrase for something
which was made up by phpmyadmin.

Basically, when you run a lot of DELETE or UPDATE queries on a table an
"overhead" is created, generally speaking this "overhead" is a space between
rows in the database file, which will cause mysql engine to insert rows into
this space on future INSERT queries. 

You can imagine your table as a hard drive, every couple of months (some may
say weeks) you have to run a de-fragment on it, you can do the same with
your database table, look up the query OPTIMIZE TABLE which will do the
de-frag for you :)

If you have any further questions feel free to bring them up.

Regards,
Nitsan

On Fri, Jun 12, 2009 at 7:02 PM, Jônatas Zechim 
wrote:

Hi there, i have this table running on my localhost:

CREATE TABLE `caffecheckout_compra_itens` (
 `compra_key` varchar(23) NOT NULL,
 `item_id` int(5) NOT NULL,
 `item_valor` decimal(10,2) NOT NULL,
 `item_peso` decimal(5,3) NOT NULL,
 `item_qtd` int(3) NOT NULL,
 `item_data` int(10) NOT NULL,
 `item_obs` varchar(100) NOT NULL,
 PRIMARY KEY  (`item_id`),
 KEY `compra_key` (`compra_key`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


It's on my Server, but when I add a row and after remove that I'd overhead
this table (58bytes/row), anyone know why is this happening?

I run this SQL:

INSERT INTO
   caffecheckout_compra_itens
   (compra_key,item_id,item_valor,item_peso,item_qtd,item_data)
VALUES
   ('12448259804a32897ce1116','2','19.90','0.250',1,'1244825980')
ON DUPLICATE KEY UPDATE
   item_qtd=item_qtd+1

And after:

DELETE FROM
   caffecheckout_compra_itens
WHERE
   compra_key='12448259804a32897ce1116'


Zechim


-Mensagem original-
De: Andrew Ballard [mailto:aball...@gmail.com]
Enviada em: sexta-feira, 12 de junho de 2009 09:38
Para: revDAVE
Cc: php-general@lists.php.net
Assunto: Re: [PHP] Field type for american money

On Thu, Jun 11, 2009 at 4:08 PM, revDAVE wrote:
> Php - MySQL - newbie question
>
> - Field type for american money - int(11) seems to work fine
>
> - but also I tried decimal(10,2)
>
> Is one a better choice than another for american money usage?
>
>
> --
> Thanks - RevDave
> Cool @ hosting4days . com
> [db-lists 09]

It depends on what you need to store, honestly. If all your dollar
amounts are integers, int would work fine. If you need decimals,
decimal(10, 2) would be fine for a lot of applications. However, a lot
of financial applications need a little more precision. SQL Server has
a money datatype that looks like it's about equivalent to decimal(19,
4) and a smallmoney type that looks like it's equivalent to
decimal(10, 4). That handles things like gas prices that always have
that extra 9/10 of a penny tacked onto them, or items that are 3 for a
dollar. If you enter a price of 0.33 in a decimal(10, 2) field,
multiplying that by 3 will result in 0.99, whereas three items priced
at 0. will come to 0., which when formatted to two digits will
round to 1.00.

Andrew

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


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

 



Re: [PHP] phpMyAdmin, localhost, mysql overhead

2009-06-12 Thread Nitsan Bin-Nun
There is no way to avoid it since whenever you delete a row in a myisam
table you create a space in the order of the rows, this space is expressed
by a little bit of extra file size of the database.
This extra file size is called in phpmyadmin as "overhead", you can kill
this over head either by running some INSERT queries which will fill the
space with the inserted rows or running an OPTIMISE query.

In general, I don't think that there is anything that you should do or take
care of, it is not rocket science and your tables will be good with or
without the overhead ;)

Nitsan

On Fri, Jun 12, 2009 at 7:41 PM, Jônatas Zechim wrote:

> I have other tables running but only this give me ‘overhead’.
>
>
>
> I’d know why this table does this and if is bad for my MySQL Server?
>
> Is there anyway to avoid it?
>
>
>
> Zechim
>
>
>
> De: nit...@binnun.co.il [mailto:nit...@binnun.co.il] Em nome de Nitsan
> Bin-Nun
> Enviada em: sexta-feira, 12 de junho de 2009 14:33
> Para: Jônatas Zechim
> Cc: php-general@lists.php.net
> Assunto: Re: [PHP] phpMyAdmin, localhost, mysql overhead
>
>
>
> I haven't read all your mail, I'm sorry for it in advance, but I think that
> you should know that "overheard" is just a blasting phrase for something
> which was made up by phpmyadmin.
>
> Basically, when you run a lot of DELETE or UPDATE queries on a table an
> "overhead" is created, generally speaking this "overhead" is a space
> between
> rows in the database file, which will cause mysql engine to insert rows
> into
> this space on future INSERT queries.
>
> You can imagine your table as a hard drive, every couple of months (some
> may
> say weeks) you have to run a de-fragment on it, you can do the same with
> your database table, look up the query OPTIMIZE TABLE which will do the
> de-frag for you :)
>
> If you have any further questions feel free to bring them up.
>
> Regards,
> Nitsan
>
> On Fri, Jun 12, 2009 at 7:02 PM, Jônatas Zechim 
> wrote:
>
> Hi there, i have this table running on my localhost:
>
> CREATE TABLE `caffecheckout_compra_itens` (
>  `compra_key` varchar(23) NOT NULL,
>  `item_id` int(5) NOT NULL,
>  `item_valor` decimal(10,2) NOT NULL,
>  `item_peso` decimal(5,3) NOT NULL,
>  `item_qtd` int(3) NOT NULL,
>  `item_data` int(10) NOT NULL,
>  `item_obs` varchar(100) NOT NULL,
>  PRIMARY KEY  (`item_id`),
>  KEY `compra_key` (`compra_key`)
> ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
>
>
> It's on my Server, but when I add a row and after remove that I'd overhead
> this table (58bytes/row), anyone know why is this happening?
>
> I run this SQL:
>
> INSERT INTO
>   caffecheckout_compra_itens
>   (compra_key,item_id,item_valor,item_peso,item_qtd,item_data)
> VALUES
>   ('12448259804a32897ce1116','2','19.90','0.250',1,'1244825980')
> ON DUPLICATE KEY UPDATE
>   item_qtd=item_qtd+1
>
> And after:
>
> DELETE FROM
>   caffecheckout_compra_itens
> WHERE
>   compra_key='12448259804a32897ce1116'
>
>
> Zechim
>
>
> -Mensagem original-
> De: Andrew Ballard [mailto:aball...@gmail.com]
> Enviada em: sexta-feira, 12 de junho de 2009 09:38
> Para: revDAVE
> Cc: php-general@lists.php.net
> Assunto: Re: [PHP] Field type for american money
>
> On Thu, Jun 11, 2009 at 4:08 PM, revDAVE wrote:
> > Php - MySQL - newbie question
> >
> > - Field type for american money - int(11) seems to work fine
> >
> > - but also I tried decimal(10,2)
> >
> > Is one a better choice than another for american money usage?
> >
> >
> > --
> > Thanks - RevDave
> > Cool @ hosting4days . com
> > [db-lists 09]
>
> It depends on what you need to store, honestly. If all your dollar
> amounts are integers, int would work fine. If you need decimals,
> decimal(10, 2) would be fine for a lot of applications. However, a lot
> of financial applications need a little more precision. SQL Server has
> a money datatype that looks like it's about equivalent to decimal(19,
> 4) and a smallmoney type that looks like it's equivalent to
> decimal(10, 4). That handles things like gas prices that always have
> that extra 9/10 of a penny tacked onto them, or items that are 3 for a
> dollar. If you enter a price of 0.33 in a decimal(10, 2) field,
> multiplying that by 3 will result in 0.99, whereas three items priced
> at 0. will come to 0., which when formatted to two digits will
> round to 1.00.
>
> Andrew
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>


Re: [PHP] phpMyAdmin, localhost, mysql overhead

2009-06-12 Thread Eddie Drapkin
The better question is why are you using MyISAM tables?  Unless there's a
legitimate reason to prefer MyISAM over InnoDB, you should be using InnoDB.

On Fri, Jun 12, 2009 at 2:01 PM, Nitsan Bin-Nun  wrote:

> There is no way to avoid it since whenever you delete a row in a myisam
> table you create a space in the order of the rows, this space is expressed
> by a little bit of extra file size of the database.
> This extra file size is called in phpmyadmin as "overhead", you can kill
> this over head either by running some INSERT queries which will fill the
> space with the inserted rows or running an OPTIMISE query.
>
> In general, I don't think that there is anything that you should do or take
> care of, it is not rocket science and your tables will be good with or
> without the overhead ;)
>
> Nitsan
>
> On Fri, Jun 12, 2009 at 7:41 PM, Jônatas Zechim  >wrote:
>
> > I have other tables running but only this give me ‘overhead’.
> >
> >
> >
> > I’d know why this table does this and if is bad for my MySQL Server?
> >
> > Is there anyway to avoid it?
> >
> >
> >
> > Zechim
> >
> >
> >
> > De: nit...@binnun.co.il [mailto:nit...@binnun.co.il] Em nome de Nitsan
> > Bin-Nun
> > Enviada em: sexta-feira, 12 de junho de 2009 14:33
> > Para: Jônatas Zechim
> > Cc: php-general@lists.php.net
> > Assunto: Re: [PHP] phpMyAdmin, localhost, mysql overhead
> >
> >
> >
> > I haven't read all your mail, I'm sorry for it in advance, but I think
> that
> > you should know that "overheard" is just a blasting phrase for something
> > which was made up by phpmyadmin.
> >
> > Basically, when you run a lot of DELETE or UPDATE queries on a table an
> > "overhead" is created, generally speaking this "overhead" is a space
> > between
> > rows in the database file, which will cause mysql engine to insert rows
> > into
> > this space on future INSERT queries.
> >
> > You can imagine your table as a hard drive, every couple of months (some
> > may
> > say weeks) you have to run a de-fragment on it, you can do the same with
> > your database table, look up the query OPTIMIZE TABLE which will do the
> > de-frag for you :)
> >
> > If you have any further questions feel free to bring them up.
> >
> > Regards,
> > Nitsan
> >
> > On Fri, Jun 12, 2009 at 7:02 PM, Jônatas Zechim 
> > wrote:
> >
> > Hi there, i have this table running on my localhost:
> >
> > CREATE TABLE `caffecheckout_compra_itens` (
> >  `compra_key` varchar(23) NOT NULL,
> >  `item_id` int(5) NOT NULL,
> >  `item_valor` decimal(10,2) NOT NULL,
> >  `item_peso` decimal(5,3) NOT NULL,
> >  `item_qtd` int(3) NOT NULL,
> >  `item_data` int(10) NOT NULL,
> >  `item_obs` varchar(100) NOT NULL,
> >  PRIMARY KEY  (`item_id`),
> >  KEY `compra_key` (`compra_key`)
> > ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
> >
> >
> > It's on my Server, but when I add a row and after remove that I'd
> overhead
> > this table (58bytes/row), anyone know why is this happening?
> >
> > I run this SQL:
> >
> > INSERT INTO
> >   caffecheckout_compra_itens
> >   (compra_key,item_id,item_valor,item_peso,item_qtd,item_data)
> > VALUES
> >   ('12448259804a32897ce1116','2','19.90','0.250',1,'1244825980')
> > ON DUPLICATE KEY UPDATE
> >   item_qtd=item_qtd+1
> >
> > And after:
> >
> > DELETE FROM
> >   caffecheckout_compra_itens
> > WHERE
> >   compra_key='12448259804a32897ce1116'
> >
> >
> > Zechim
> >
> >
> > -Mensagem original-
> > De: Andrew Ballard [mailto:aball...@gmail.com]
> > Enviada em: sexta-feira, 12 de junho de 2009 09:38
> > Para: revDAVE
> > Cc: php-general@lists.php.net
> > Assunto: Re: [PHP] Field type for american money
> >
> > On Thu, Jun 11, 2009 at 4:08 PM, revDAVE wrote:
> > > Php - MySQL - newbie question
> > >
> > > - Field type for american money - int(11) seems to work fine
> > >
> > > - but also I tried decimal(10,2)
> > >
> > > Is one a better choice than another for american money usage?
> > >
> > >
> > > --
> > > Thanks - RevDave
> > > Cool @ hosting4days . com
> > > [db-lists 09]
> >
> > It depends on what you need to store, honestly. If all your dollar
> > amounts are integers, int would work fine. If you need decimals,
> > decimal(10, 2) would be fine for a lot of applications. However, a lot
> > of financial applications need a little more precision. SQL Server has
> > a money datatype that looks like it's about equivalent to decimal(19,
> > 4) and a smallmoney type that looks like it's equivalent to
> > decimal(10, 4). That handles things like gas prices that always have
> > that extra 9/10 of a penny tacked onto them, or items that are 3 for a
> > dollar. If you enter a price of 0.33 in a decimal(10, 2) field,
> > multiplying that by 3 will result in 0.99, whereas three items priced
> > at 0. will come to 0., which when formatted to two digits will
> > round to 1.00.
> >
> > Andrew
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> > --
> > PHP General Mailing Li

RES: [PHP] phpMyAdmin, localhost, mysql overhead

2009-06-12 Thread Jônatas Zechim
Thank u Nitsan. I’ll proceed with my app now.

 

Zechim

 

De: nit...@binnun.co.il [mailto:nit...@binnun.co.il] Em nome de Nitsan
Bin-Nun
Enviada em: sexta-feira, 12 de junho de 2009 15:01
Para: Jônatas Zechim
Cc: php-general@lists.php.net
Assunto: Re: [PHP] phpMyAdmin, localhost, mysql overhead

 

There is no way to avoid it since whenever you delete a row in a myisam
table you create a space in the order of the rows, this space is expressed
by a little bit of extra file size of the database.
This extra file size is called in phpmyadmin as "overhead", you can kill
this over head either by running some INSERT queries which will fill the
space with the inserted rows or running an OPTIMISE query.

In general, I don't think that there is anything that you should do or take
care of, it is not rocket science and your tables will be good with or
without the overhead ;)

Nitsan

On Fri, Jun 12, 2009 at 7:41 PM, Jônatas Zechim 
wrote:

I have other tables running but only this give me ‘overhead’.



I’d know why this table does this and if is bad for my MySQL Server?

Is there anyway to avoid it?



Zechim



De: nit...@binnun.co.il [mailto:nit...@binnun.co.il] Em nome de Nitsan
Bin-Nun
Enviada em: sexta-feira, 12 de junho de 2009 14:33
Para: Jônatas Zechim

Cc: php-general@lists.php.net

Assunto: Re: [PHP] phpMyAdmin, localhost, mysql overhead




I haven't read all your mail, I'm sorry for it in advance, but I think that
you should know that "overheard" is just a blasting phrase for something
which was made up by phpmyadmin.

Basically, when you run a lot of DELETE or UPDATE queries on a table an
"overhead" is created, generally speaking this "overhead" is a space between
rows in the database file, which will cause mysql engine to insert rows into
this space on future INSERT queries.

You can imagine your table as a hard drive, every couple of months (some may
say weeks) you have to run a de-fragment on it, you can do the same with
your database table, look up the query OPTIMIZE TABLE which will do the
de-frag for you :)

If you have any further questions feel free to bring them up.

Regards,
Nitsan

On Fri, Jun 12, 2009 at 7:02 PM, Jônatas Zechim 
wrote:

Hi there, i have this table running on my localhost:

CREATE TABLE `caffecheckout_compra_itens` (
 `compra_key` varchar(23) NOT NULL,
 `item_id` int(5) NOT NULL,
 `item_valor` decimal(10,2) NOT NULL,
 `item_peso` decimal(5,3) NOT NULL,
 `item_qtd` int(3) NOT NULL,
 `item_data` int(10) NOT NULL,
 `item_obs` varchar(100) NOT NULL,
 PRIMARY KEY  (`item_id`),
 KEY `compra_key` (`compra_key`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


It's on my Server, but when I add a row and after remove that I'd overhead
this table (58bytes/row), anyone know why is this happening?

I run this SQL:

INSERT INTO
  caffecheckout_compra_itens
  (compra_key,item_id,item_valor,item_peso,item_qtd,item_data)
VALUES
  ('12448259804a32897ce1116','2','19.90','0.250',1,'1244825980')
ON DUPLICATE KEY UPDATE
  item_qtd=item_qtd+1

And after:

DELETE FROM
  caffecheckout_compra_itens
WHERE
  compra_key='12448259804a32897ce1116'


Zechim


-Mensagem original-
De: Andrew Ballard [mailto:aball...@gmail.com]
Enviada em: sexta-feira, 12 de junho de 2009 09:38
Para: revDAVE
Cc: php-general@lists.php.net
Assunto: Re: [PHP] Field type for american money

On Thu, Jun 11, 2009 at 4:08 PM, revDAVE wrote:
> Php - MySQL - newbie question
>
> - Field type for american money - int(11) seems to work fine
>
> - but also I tried decimal(10,2)
>
> Is one a better choice than another for american money usage?
>
>
> --
> Thanks - RevDave
> Cool @ hosting4days . com
> [db-lists 09]

It depends on what you need to store, honestly. If all your dollar
amounts are integers, int would work fine. If you need decimals,
decimal(10, 2) would be fine for a lot of applications. However, a lot
of financial applications need a little more precision. SQL Server has
a money datatype that looks like it's about equivalent to decimal(19,
4) and a smallmoney type that looks like it's equivalent to
decimal(10, 4). That handles things like gas prices that always have
that extra 9/10 of a penny tacked onto them, or items that are 3 for a
dollar. If you enter a price of 0.33 in a decimal(10, 2) field,
multiplying that by 3 will result in 0.99, whereas three items priced
at 0. will come to 0., which when formatted to two digits will
round to 1.00.

Andrew

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


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




 



RES: [PHP] phpMyAdmin, localhost, mysql overhead

2009-06-12 Thread Jônatas Zechim
I really don’t know the differences betwen MyISAM and InnoDB yet but I’ll
google for it right now.

 

Thank u.

 

Zechim

 

De: Eddie Drapkin [mailto:oorza...@gmail.com] 
Enviada em: sexta-feira, 12 de junho de 2009 15:05
Para: Nitsan Bin-Nun
Cc: Jônatas Zechim; php-general@lists.php.net
Assunto: Re: [PHP] phpMyAdmin, localhost, mysql overhead

 

The better question is why are you using MyISAM tables?  Unless there's a
legitimate reason to prefer MyISAM over InnoDB, you should be using InnoDB.

On Fri, Jun 12, 2009 at 2:01 PM, Nitsan Bin-Nun  wrote:

There is no way to avoid it since whenever you delete a row in a myisam
table you create a space in the order of the rows, this space is expressed
by a little bit of extra file size of the database.
This extra file size is called in phpmyadmin as "overhead", you can kill
this over head either by running some INSERT queries which will fill the
space with the inserted rows or running an OPTIMISE query.

In general, I don't think that there is anything that you should do or take
care of, it is not rocket science and your tables will be good with or
without the overhead ;)

Nitsan

On Fri, Jun 12, 2009 at 7:41 PM, Jônatas Zechim wrote:


> I have other tables running but only this give me ‘overhead’.
>
>
>
> I’d know why this table does this and if is bad for my MySQL Server?
>
> Is there anyway to avoid it?
>
>
>
> Zechim
>
>
>
> De: nit...@binnun.co.il [mailto:nit...@binnun.co.il] Em nome de Nitsan
> Bin-Nun
> Enviada em: sexta-feira, 12 de junho de 2009 14:33
> Para: Jônatas Zechim
> Cc: php-general@lists.php.net
> Assunto: Re: [PHP] phpMyAdmin, localhost, mysql overhead
>
>
>
> I haven't read all your mail, I'm sorry for it in advance, but I think
that
> you should know that "overheard" is just a blasting phrase for something
> which was made up by phpmyadmin.
>
> Basically, when you run a lot of DELETE or UPDATE queries on a table an
> "overhead" is created, generally speaking this "overhead" is a space
> between
> rows in the database file, which will cause mysql engine to insert rows
> into
> this space on future INSERT queries.
>
> You can imagine your table as a hard drive, every couple of months (some
> may
> say weeks) you have to run a de-fragment on it, you can do the same with
> your database table, look up the query OPTIMIZE TABLE which will do the
> de-frag for you :)
>
> If you have any further questions feel free to bring them up.
>
> Regards,
> Nitsan
>
> On Fri, Jun 12, 2009 at 7:02 PM, Jônatas Zechim 
> wrote:
>
> Hi there, i have this table running on my localhost:
>
> CREATE TABLE `caffecheckout_compra_itens` (
>  `compra_key` varchar(23) NOT NULL,
>  `item_id` int(5) NOT NULL,
>  `item_valor` decimal(10,2) NOT NULL,
>  `item_peso` decimal(5,3) NOT NULL,
>  `item_qtd` int(3) NOT NULL,
>  `item_data` int(10) NOT NULL,
>  `item_obs` varchar(100) NOT NULL,
>  PRIMARY KEY  (`item_id`),
>  KEY `compra_key` (`compra_key`)
> ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
>
>
> It's on my Server, but when I add a row and after remove that I'd overhead
> this table (58bytes/row), anyone know why is this happening?
>
> I run this SQL:
>
> INSERT INTO
>   caffecheckout_compra_itens
>   (compra_key,item_id,item_valor,item_peso,item_qtd,item_data)
> VALUES
>   ('12448259804a32897ce1116','2','19.90','0.250',1,'1244825980')
> ON DUPLICATE KEY UPDATE
>   item_qtd=item_qtd+1
>
> And after:
>
> DELETE FROM
>   caffecheckout_compra_itens
> WHERE
>   compra_key='12448259804a32897ce1116'
>
>
> Zechim
>
>
> -Mensagem original-
> De: Andrew Ballard [mailto:aball...@gmail.com]
> Enviada em: sexta-feira, 12 de junho de 2009 09:38
> Para: revDAVE
> Cc: php-general@lists.php.net
> Assunto: Re: [PHP] Field type for american money
>
> On Thu, Jun 11, 2009 at 4:08 PM, revDAVE wrote:
> > Php - MySQL - newbie question
> >
> > - Field type for american money - int(11) seems to work fine
> >
> > - but also I tried decimal(10,2)
> >
> > Is one a better choice than another for american money usage?
> >
> >
> > --
> > Thanks - RevDave
> > Cool @ hosting4days . com
> > [db-lists 09]
>
> It depends on what you need to store, honestly. If all your dollar
> amounts are integers, int would work fine. If you need decimals,
> decimal(10, 2) would be fine for a lot of applications. However, a lot
> of financial applications need a little more precision. SQL Server has
> a money datatype that looks like it's about equivalent to decimal(19,
> 4) and a smallmoney type that looks like it's equivalent to
> decimal(10, 4). That handles things like gas prices that always have
> that extra 9/10 of a penny tacked onto them, or items that are 3 for a
> dollar. If you enter a price of 0.33 in a decimal(10, 2) field,
> multiplying that by 3 will result in 0.99, whereas three items priced
> at 0. will come to 0., which when formatted to two digits will
> round to 1.00.
>
> Andrew
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: ht

Re: [PHP] phpMyAdmin, localhost, mysql overhead

2009-06-12 Thread Eddie Drapkin
Some important differences:

InnoDB:
-row level locking
-transactional support
-foreign key support

MyISAM:
-table-level locking
-no transactions
-no foreign keys

If that doesn't sell you, definitely head to google :)

On Fri, Jun 12, 2009 at 2:12 PM, Jônatas Zechim wrote:

>  I really don’t know the differences betwen MyISAM and InnoDB yet but I’ll
> google for it right now.
>
>
>
> Thank u.
>
>
>
> *Zechim*
>
>
>
> *De:* Eddie Drapkin [mailto:oorza...@gmail.com]
> *Enviada em:* sexta-feira, 12 de junho de 2009 15:05
> *Para:* Nitsan Bin-Nun
> *Cc:* Jônatas Zechim; php-general@lists.php.net
>
> *Assunto:* Re: [PHP] phpMyAdmin, localhost, mysql overhead
>
>
>
> The better question is why are you using MyISAM tables?  Unless there's a
> legitimate reason to prefer MyISAM over InnoDB, you should be using InnoDB.
>
> On Fri, Jun 12, 2009 at 2:01 PM, Nitsan Bin-Nun 
> wrote:
>
> There is no way to avoid it since whenever you delete a row in a myisam
> table you create a space in the order of the rows, this space is expressed
> by a little bit of extra file size of the database.
> This extra file size is called in phpmyadmin as "overhead", you can kill
> this over head either by running some INSERT queries which will fill the
> space with the inserted rows or running an OPTIMISE query.
>
> In general, I don't think that there is anything that you should do or take
> care of, it is not rocket science and your tables will be good with or
> without the overhead ;)
>
> Nitsan
>
> On Fri, Jun 12, 2009 at 7:41 PM, Jônatas Zechim  >wrote:
>
>
> > I have other tables running but only this give me ‘overhead’.
> >
> >
> >
> > I’d know why this table does this and if is bad for my MySQL Server?
> >
> > Is there anyway to avoid it?
> >
> >
> >
> > Zechim
> >
> >
> >
> > De: nit...@binnun.co.il [mailto:nit...@binnun.co.il] Em nome de Nitsan
> > Bin-Nun
> > Enviada em: sexta-feira, 12 de junho de 2009 14:33
> > Para: Jônatas Zechim
> > Cc: php-general@lists.php.net
> > Assunto: Re: [PHP] phpMyAdmin, localhost, mysql overhead
> >
> >
> >
> > I haven't read all your mail, I'm sorry for it in advance, but I think
> that
> > you should know that "overheard" is just a blasting phrase for something
> > which was made up by phpmyadmin.
> >
> > Basically, when you run a lot of DELETE or UPDATE queries on a table an
> > "overhead" is created, generally speaking this "overhead" is a space
> > between
> > rows in the database file, which will cause mysql engine to insert rows
> > into
> > this space on future INSERT queries.
> >
> > You can imagine your table as a hard drive, every couple of months (some
> > may
> > say weeks) you have to run a de-fragment on it, you can do the same with
> > your database table, look up the query OPTIMIZE TABLE which will do the
> > de-frag for you :)
> >
> > If you have any further questions feel free to bring them up.
> >
> > Regards,
> > Nitsan
> >
> > On Fri, Jun 12, 2009 at 7:02 PM, Jônatas Zechim 
> > wrote:
> >
> > Hi there, i have this table running on my localhost:
> >
> > CREATE TABLE `caffecheckout_compra_itens` (
> >  `compra_key` varchar(23) NOT NULL,
> >  `item_id` int(5) NOT NULL,
> >  `item_valor` decimal(10,2) NOT NULL,
> >  `item_peso` decimal(5,3) NOT NULL,
> >  `item_qtd` int(3) NOT NULL,
> >  `item_data` int(10) NOT NULL,
> >  `item_obs` varchar(100) NOT NULL,
> >  PRIMARY KEY  (`item_id`),
> >  KEY `compra_key` (`compra_key`)
> > ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
> >
> >
> > It's on my Server, but when I add a row and after remove that I'd
> overhead
> > this table (58bytes/row), anyone know why is this happening?
> >
> > I run this SQL:
> >
> > INSERT INTO
> >   caffecheckout_compra_itens
> >   (compra_key,item_id,item_valor,item_peso,item_qtd,item_data)
> > VALUES
> >   ('12448259804a32897ce1116','2','19.90','0.250',1,'1244825980')
> > ON DUPLICATE KEY UPDATE
> >   item_qtd=item_qtd+1
> >
> > And after:
> >
> > DELETE FROM
> >   caffecheckout_compra_itens
> > WHERE
> >   compra_key='12448259804a32897ce1116'
> >
> >
> > Zechim
> >
> >
> > -Mensagem original-
> > De: Andrew Ballard [mailto:aball...@gmail.com]
> > Enviada em: sexta-feira, 12 de junho de 2009 09:38
> > Para: revDAVE
> > Cc: php-general@lists.php.net
> > Assunto: Re: [PHP] Field type for american money
> >
> > On Thu, Jun 11, 2009 at 4:08 PM, revDAVE wrote:
> > > Php - MySQL - newbie question
> > >
> > > - Field type for american money - int(11) seems to work fine
> > >
> > > - but also I tried decimal(10,2)
> > >
> > > Is one a better choice than another for american money usage?
> > >
> > >
> > > --
> > > Thanks - RevDave
> > > Cool @ hosting4days . com
> > > [db-lists 09]
> >
> > It depends on what you need to store, honestly. If all your dollar
> > amounts are integers, int would work fine. If you need decimals,
> > decimal(10, 2) would be fine for a lot of applications. However, a lot
> > of financial applications need a little more precision. SQL Server has
> > a money da

[PHP] opendir() Question

2009-06-12 Thread Parham Doustdar
Hi there,
I need to create a PHP script that will connect to an  FTP, get a listing of 
files/directories from it, and displays them in a table. Now, there is only one 
problem here.
I tried connecting with opendir(), like this:
opendir("ftp://...";);
but it seems it doesn't work with FTP. Now, is there another thing I could use 
for the same effect?
Thanks!
-- 
---
Contact info:
Skype: parham-d
MSN: fire_lizard16 at hotmail dot com
email: parham90 at GMail dot com

Re: [PHP] opendir() Question

2009-06-12 Thread Andrew Ballard
2009/6/12 Parham Doustdar :
> Hi there,
> I need to create a PHP script that will connect to an  FTP, get a listing of 
> files/directories from it, and displays them in a table. Now, there is only 
> one problem here.
> I tried connecting with opendir(), like this:
> opendir("ftp://...";);
> but it seems it doesn't work with FTP. Now, is there another thing I could 
> use for the same effect?
> Thanks!
> --
> ---
> Contact info:
> Skype: parham-d
> MSN: fire_lizard16 at hotmail dot com
> email: parham90 at GMail dot com

RTM http://www.php.net/ftp

Andrew

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



RE: [PHP] Re: Form handling

2009-06-12 Thread Dajve Green

> -Original Message-
> From: Manuel Lemos [mailto:mle...@acm.org]
> Sent: 11 June 2009 07:21
> To: Eddie Drapkin
> Cc: PHP General Mailing List
> Subject: [PHP] Re: Form handling
> 
> Hello,
> 
> on 06/10/2009 03:10 PM Eddie Drapkin said the following:
> > I've been charged with writing a class that handles forms, once they've
> been
> > POSTed to.  The idea of the class is to handle the most common use-cases
> of
> > POST forms, and any special functionality can be handled with a child
> class
> > at a later date, but for our uses, we're going to have mostly pretty
> typical
> > POST forms.  Follows is the list of cases I've determined that are the
> most
> > common, can anyone think of any that are omitted or that are never going
> to
> > be used?
> >
> > class form_handler {
> > public /* bool */ function setRequiredFields(array $fields); //takes
> a
> > simple array that corresponds to a $_POST key, verifying that there is
> data
> > on required fields but not for optional fields, returns true or false on
> > error
> > public /* bool */ function setRequiredFieldTypes(array $fieldTypes);
> > //array of field names => type a la ('username' => array(regex,
> > '/a-zA-Z0-9\-_/'))
> > //or 'phone_number' => (array('int', 'min_len' => 7,
> > 'max_len' => 10)) etc, the exact spec is obviously nowhere near done but
> > will probably just wrap a lot of filter_ functions, returns true or
> false on
> > error
> > public /* string */ function validateAndCaptureError(); //returns
> error
> > or empty string
> > public /* void */ function validateAndForwardTo($page); //forwards
> to
> > page on error, or not
> > }
> >
> > each of the globule setters will have a corresponding appendRequired...
> > method, so as not to require handling enormous data structures for
> > conditional form building.
> > ♦
> > As you can see, the class looks pretty barren, but I can't think of any
> more
> > functionality than would be required, although I am kickign the idea
> around
> > of having very specific validation type methods ie.
> > form_handler::requireInt($field, array $options) or
> > form_handler::requireRegex($field, $regex), etc.
> >
> > Thoughts?
> 
> You may want consider not reinventing the wheel.
> 
> I use this popular forms generation and validation class since about 10
> years now. It can deal with pretty much all you need now and probably
> later.
> 
> http://www.phpclasses.org/formsgeneration
> 
> Here are some live examples of the class and its plug-ins.
> 
> http://www.meta-language.net/forms-examples.html
> 
> --
> 
> Regards,
> Manuel Lemos

Whilst Manuel's Forms Generation class / Zend Form et al are certainly quick 
and easy to integrate, if this is an in-house project, I don't see a problem 
with rolling your own Forms class designed to simply automate some of the 
common functionality your developers use. In a lot of cases, out-of-the-box 
classes come with bloat while being all things to all men, which is not a bad 
thing, per se, but needs to be weighed up when selecting a methodology.

To answer your original question, though, our in-house framework has a base 
Form class, which is extended through child classes, as well as a base input 
class, which is extended with child classes such as TextInput, SelectInput etc. 
This allows each input to have its individual validate() methods, as well as 
creating a wrapper Form::validate() method which loops through the 
Input::validate() methods.

Example

$Form   = new Form;
$Form->fields['text']   = new TextInput;
$Form->fields['select'] = new SelectInput;
$Form->fields['select']->options= array('foo' => 'bar', 'wom' => 'bat');

With regard your setRequiredFields(), we use an Input::$mandatory property, 
which the Input::validate() method checks.
The setRequiredFieldTypes() is dealt with by the actual File class.
I would certainly separate out the required validation as mentioned with 
requireInt/Regex methods, which would allow combining of required conditions. 
We use a $validation bitwise property in the Input class combined with class 
constants, as well as minlength / maxlength properties for text / password 
fields.

Other things to consider

- Some method of storing user messages during validation which can be output 
later.

- Creating an output method for the fields. Repopulating the fields with 
submitted values, using CSS to highlight missing or invalid fields or creating 
"custom" fields (such as a date input with a calendar / made up of Y/M/D select 
inputs) can lead to a mess if you are hardcoding the output. 
For example:

$Form->fields['text']->add_css_class('missing_mandatory');
$Form->fields['text']->set_value('Foo');
$Form->fields['text']->output();

Something further to consider would be to have a $value property and use 
__set() overloading 
(http://us3.php.net/manual/en/language.oop5.overloading.php) to validate
Eg 
$Form->fields['select']->value = 'foo'; // Sets value to foo
$Form->f

Re: [PHP] Re: Dynamic Titles

2009-06-12 Thread David Robley
On Sat, 13 Jun 2009, you wrote:
> Well, im no longer getting any errors now, but its still not working.
> You can see it here: http://www.newtuts.com. When you go there, it
> should say "Photoshop tutorials, Flash tutorials . . .". This should be
> the default page. When you click on "Support", the title should become
> "Newtuts Help". But instead, it just says "echo $title". Any more
> ideas?
>
>
>
> Austin Caudill
>
> --- On Fri, 6/12/09, David Robley  wrote:
>
>
> From: David Robley 
> Subject: [PHP] Re: Dynamic Titles
> To: php-general@lists.php.net
> Date: Friday, June 12, 2009, 3:34 AM
>
> Austin Caudill wrote:
> > Hello, im trying to make the CMS system im using more SEO friendly by
> > giving each page it's own title. Right now, the system assigns all
> > pages the same general title. I would like to use PHP to discertain
> > which page is being viewed and in turn, which title should be used.
> >
> > I have put in the title tags the variable "$title". As for the PHP im
> > using, I scripted the following:
> >
> > $url = "http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']'";
> > switch ( $url )
> > {
> > default:
> > $title = "Photoshop tutorials, Flash tutorials, and more! Newtuts
> > Tutorial Search"; break;
> >
> > case "$config[HTTP_SERVER]help.php" :
> > $title = "Newtuts Help";
> > break;
> > }
> >
> > Right now, im getting this error:
> > Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
> > expecting T_STRING or T_VARIABLE or T_NUM_STRING in
> > /home/a7201901/public_html/includes/classes/tutorial.php on line 803
> >
> > Can someone please help me with this?
> >
> >
> >
> > Thanks!
>
> I'm guessing that line 803 is
>
> $url = "http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']'";
>
> which is full of mismatched quotes :-) Try any of
>
> $url = "http://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}";
> $url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
> $url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
>
> Cheers

Forwarding to the list for the benefit of others.

As you haven't shown the code that is supposed to produce the title, we're 
back to guessing again. Looking at the source of your Support page, I see 
the the Title tags are empty.

If you are seeing echo $title is it possible you forgot to use php tags 
around the php code?




Cheers
-- 
David Robley

"I haven't had any tooth decay yet," said Tom precariously.
Today is Prickle-Prickle, the 18th day of Confusion in the YOLD 3175. 

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



Re: [PHP] Re: Dynamic Titles

2009-06-12 Thread Austin Caudill
Yes, I corrected this problem. Now, the URL of each page is being displayed as 
the title. We are making progress! Now I just need to figure out why the URLs 
are shown as the title, and not whaty I want to be shown.



Austin Caudill

--- On Fri, 6/12/09, David Robley  wrote:


From: David Robley 
Subject: Re: [PHP] Re: Dynamic Titles
To: php-general@lists.php.net
Date: Friday, June 12, 2009, 9:29 PM


On Sat, 13 Jun 2009, you wrote:
> Well, im no longer getting any errors now, but its still not working.
> You can see it here: http://www.newtuts.com. When you go there, it
> should say "Photoshop tutorials, Flash tutorials . . .". This should be
> the default page. When you click on "Support", the title should become
> "Newtuts Help". But instead, it just says "echo $title". Any more
> ideas?
>
>
>
> Austin Caudill
>
> --- On Fri, 6/12/09, David Robley  wrote:
>
>
> From: David Robley 
> Subject: [PHP] Re: Dynamic Titles
> To: php-general@lists.php.net
> Date: Friday, June 12, 2009, 3:34 AM
>
> Austin Caudill wrote:
> > Hello, im trying to make the CMS system im using more SEO friendly by
> > giving each page it's own title. Right now, the system assigns all
> > pages the same general title. I would like to use PHP to discertain
> > which page is being viewed and in turn, which title should be used.
> >
> > I have put in the title tags the variable "$title". As for the PHP im
> > using, I scripted the following:
> >
> > $url = "http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']'";
> > switch ( $url )
> > {
> > default:
> > $title = "Photoshop tutorials, Flash tutorials, and more! Newtuts
> > Tutorial Search"; break;
> >
> > case "$config[HTTP_SERVER]help.php" :
> > $title = "Newtuts Help";
> > break;
> > }
> >
> > Right now, im getting this error:
> > Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
> > expecting T_STRING or T_VARIABLE or T_NUM_STRING in
> > /home/a7201901/public_html/includes/classes/tutorial.php on line 803
> >
> > Can someone please help me with this?
> >
> >
> >
> > Thanks!
>
> I'm guessing that line 803 is
>
> $url = "http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']'";
>
> which is full of mismatched quotes :-) Try any of
>
> $url = "http://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}";
> $url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
> $url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
>
> Cheers

Forwarding to the list for the benefit of others.

As you haven't shown the code that is supposed to produce the title, we're 
back to guessing again. Looking at the source of your Support page, I see 
the the Title tags are empty.

If you are seeing echo $title is it possible you forgot to use php tags 
around the php code?




Cheers
-- 
David Robley

"I haven't had any tooth decay yet," said Tom precariously.
Today is Prickle-Prickle, the 18th day of Confusion in the YOLD 3175. 

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




  

Re: [PHP] opendir() Question

2009-06-12 Thread Parham Doustdar
Hello there Andrew,
Thank you very much for your help. I didn't know such an extention existed. 
:)

-- 
---
Contact info:
Skype: parham-d
MSN: fire_lizard16 at hotmail dot com
email: parham90 at GMail dot com
"Andrew Ballard"  wrote in message 
news:b6023aa40906121312m47034863k9c502e07d66c4...@mail.gmail.com...
2009/6/12 Parham Doustdar :
> Hi there,
> I need to create a PHP script that will connect to an FTP, get a listing 
> of files/directories from it, and displays them in a table. Now, there is 
> only one problem here.
> I tried connecting with opendir(), like this:
> opendir("ftp://...";);
> but it seems it doesn't work with FTP. Now, is there another thing I could 
> use for the same effect?
> Thanks!
> --
> ---
> Contact info:
> Skype: parham-d
> MSN: fire_lizard16 at hotmail dot com
> email: parham90 at GMail dot com

RTM http://www.php.net/ftp

Andrew 



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



[PHP] Doubt on why some syntaxis is not used for PHP

2009-06-12 Thread Manuel Aude
I'm gonna guess that there might be some syntaxis problems or something,
since I would guess the following make sense to the PHP language.

Arrays: Since the + operator already gives the union of two arrays, why
isn't the - operator for differences and | for intersections? I would find
those to be rather natural and actually easy to implement.

Classes: I was also wondering why the static methods of a class use the ::
syntaxis. After all, I don't see what's the problem with also using -> for
static calls. Just by adding MyClass->staticMethod(), the whole problem of
namespaces and :: as separator would seem to be made a bit easier.

Just some questions =) I'm not here to say that things are wrong, just
wondering why they weren't thought to be the other way. Again, there might
be some syntaxis problem with the parser that I haven't thought so far.

Regards, Mamsaac