php-general Digest 18 Jul 2006 18:10:57 -0000 Issue 4246

Topics (messages 239535 through 239552):

Re: Name in HTML input
        239535 by: Sameer N Ingole
        239536 by: Ligaya Turmelle
        239537 by: Sameer N Ingole
        239538 by: weetat
        239539 by: weetat
        239540 by: nicolas figaro
        239542 by: Jay Blanchard
        239543 by: Sameer N Ingole

Re: GD to database directly
        239541 by: Jay Blanchard

Sort Array
        239544 by: weetat
        239545 by: Jay Blanchard
        239546 by: tg-php.gryffyndevelopment.com
        239547 by: Andrew Brampton
        239548 by: Jochem Maas
        239549 by: Jay Blanchard
        239550 by: Miles Thompson

pg_query and COPY in transaction
        239551 by: Luis Magaña
        239552 by: Jochem Maas

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
weetat wrote:

<input name="FHK0924F0JG (2771890816)hostname[]" type="hidden" value="FHK0924F0JG (2771890816)">
Space in name. Remove it.

--
Sameer N. Ingole
http://weblogic.noroot.org/
---
Better to light one candle than to curse the darkness.

--- End Message ---
--- Begin Message ---
weetat wrote:
Hi all,

 I am using php 4.3.2 , mysql db and Red Hat Enterprise.

I have some issue regarding the name in <INPUT> Tag in html , as shown below:

a:
 <input name="FOX08340027hostname[]" type="hidden" value="FOX08340027">
b:
<input name="FHK0924F0JG (2771890816)hostname[]" type="hidden" value="FHK0924F0JG (2771890816)">


I can get value from <INPUT> tag in the sample a) above , however in the sample b) , there are no value when submit form ?

Anybody have any ideas to get value in the sample b?

Thanks.
maybe remove the blank space and use an underscore instead...

--

life is a game... so have fun.

--- End Message ---
--- Begin Message ---
Sameer N Ingole wrote:
weetat wrote:

<input name="FHK0924F0JG (2771890816)hostname[]" type="hidden" value="FHK0924F0JG (2771890816)">
Space in name. Remove it.

oh, also remove '(' and ')' then check.

--
Sameer N. Ingole
http://weblogic.noroot.org/
---
Better to light one candle than to curse the darkness.

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

 Thanks for your info.
 I am new in PHP , how to remove the the space and '(',')' ?

Thanks



Sameer N Ingole wrote:
Sameer N Ingole wrote:

weetat wrote:


<input name="FHK0924F0JG (2771890816)hostname[]" type="hidden" value="FHK0924F0JG (2771890816)">

Space in name. Remove it.

oh, also remove '(' and ')' then check.


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

 Thanks for your info.
 I am new in PHP , how to remove the the space and '(',')' ?

Thanks



Sameer N Ingole wrote:
Sameer N Ingole wrote:

weetat wrote:


<input name="FHK0924F0JG (2771890816)hostname[]" type="hidden" value="FHK0924F0JG (2771890816)">

Space in name. Remove it.

oh, also remove '(' and ')' then check.


--- End Message ---
--- Begin Message ---
weetat a écrit :
Hi ,

 Thanks for your info.
 I am new in PHP , how to remove the the space and '(',')' ?

hi,
$newstring = str_replace(" ","_",$string);
$newstring = str_replace(",","_",$newstring)

hope this'll help

N F
Thanks



Sameer N Ingole wrote:
Sameer N Ingole wrote:

weetat wrote:


<input name="FHK0924F0JG (2771890816)hostname[]" type="hidden" value="FHK0924F0JG (2771890816)">

Space in name. Remove it.

oh, also remove '(' and ')' then check.




--- End Message ---
--- Begin Message ---
[snip]
  Thanks for your info.
  I am new in PHP , how to remove the the space and '(',')' ?
[/snip]

Use the delete key.

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


<input name="FHK0924F0JG (2771890816)hostname[]" type="hidden" value="FHK0924F0JG (2771890816)">

Space in name. Remove it.

oh, also remove '(' and ')' then check.


This should be your second input tag.
<input name="FHK0924F0JG_2771890816hostname[]" type="hidden" value="FHK0924F0JG (2771890816)">

Read http://php.net/variables .. to know why it didn't work..

--
Sameer N. Ingole
http://weblogic.noroot.org/
---
Better to light one candle than to curse the darkness.

--- End Message ---
--- Begin Message ---
[snip]
Kevin, you have more than once pointed out using a RAW format for
operating the data system, what exactly do you mean? The database
becomes the OS? If so, how do you set that up? It is something that I am
not totally familiar with. 
[/snip]

I did some research and went back to Kevin's original statement;

[kevin]
databases can be stored on RAW partitions, thus eliminating FILE SYSTEM
overhead
[/kevin]

Here is what I found;

[quote]
raw partition vs filesystem store? 

> What are pros/cons as far as performance, reliability, and ease of 
> backup/restore? 
> 
> Anyone have any experience running Innodb on raw partition? 

raw partitions are beneficial only in some old OS/hardware
configurations 
where fsync is extremely slow. In most computers, you only get a < 5 % 
performance improvement from raw partitions. 

> Any thoughts as to best filesystem for Innodb? What about pros/cons of

> journaled filesystems when in use with Innodb (i.e. transactions)? 

All major Linux file systems seem to have almost the same performance. 
[/quote - Heikki Tuuri]

Use of MySQL on a RAW partition I limited to InnoDB type; (note the use
of 'may' in the quote)

[quote]
http://dev.mysql.com/doc/refman/5.0/en/innodb-raw-devices.html

"You can use raw disk partitions as data files in the shared tablespace.
By using a raw disk, you can perform non-buffered I/O on Windows and on
some Unix systems without filesystem overhead, which may improve
performance."
[/quote]

[quote]
A raw device can be bound to an existing block device (e.g. a disk) and
be used to perform "raw" IO with that existing block device. Such "raw"
IO bypasses the caching that is normally associated with block devices.
Hence a raw device offers a more "direct" route to the physical device
and allows an application more control over the timing of IO to that
physical device. This makes raw devices suitable for complex
applications like Database Management Systems that typically do their
own caching. 
[/quote - SCSI HOWTO]

Based on what I read utilizing a RAW would probably require most PHP'ers
to reconfigure their systems in major ways, including the database type,
disk partitions, etc. I don't know about you, but most would consider
Heikki Tuuri an expert on MySQL systems and Tuuri's thoughts indicate
that RAW partitions vs. file systems are a wash unless you have fsync
problems. It would appear that the only benefit comes from not having
the file system doing the caching.

[previous statement]
There are a lot of us using MySQL (and PostGreSQL) along with PHP and in
practice we have found that storing images in the database to be less
than ideal from both a performance and backup POV. The reasons range
from speed to overhead to ease of use. On our hardware. It not only has
to do with storing and retrieving BLOB data, but also things like
indexing, OS qwirks and the like.
[/previous statement]

I still stand by this, and amend by saying that using a RAW partition
for database storage is typically beyond the needs of most PHP'ers as it
gains nothing in performance and requires that much additional
maintenance be performed on the database as well as the OS for
maintenance of the RAW partition.

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


I have the array below : How to sort the array by "Model" and "Country?

Thanks

array(

  "TBA0123456" => array("Country"=>"Singapore","Model"=>"WS8234"),
  "TBA0123458" => array("Country"=>"Indonesia","Model"=>"WS2234"),
  "TBA0123459" => array("Country"=>"Vietnam","Model"=>"WS7234"),
  "TBA0123452" => array("Country"=>"England","Model"=>"WS1234"),
  "TBA0123451" => array("Country"=>"Germany","Model"=>"WS6234"),

)

--- End Message ---
--- Begin Message ---
[snip]
I have the array below : How to sort the array by "Model" and "Country?

Thanks

array(

   "TBA0123456" => array("Country"=>"Singapore","Model"=>"WS8234"),
   "TBA0123458" => array("Country"=>"Indonesia","Model"=>"WS2234"),
   "TBA0123459" => array("Country"=>"Vietnam","Model"=>"WS7234"),
   "TBA0123452" => array("Country"=>"England","Model"=>"WS1234"),
   "TBA0123451" => array("Country"=>"Germany","Model"=>"WS6234"),

)
[/snip]

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

--- End Message ---
--- Begin Message ---
Actually it's going to be a little more complicated than a 'ksort' here I think.

ksort on the main array is going to give you:

array (
   "TBA0123451" => array("Country"=>"Germany","Model"=>"WS6234"),
   "TBA0123452" => array("Country"=>"England","Model"=>"WS1234"),
   "TBA0123456" => array("Country"=>"Singapore","Model"=>"WS8234"),
   "TBA0123458" => array("Country"=>"Indonesia","Model"=>"WS2234"),
   "TBA0123459" => array("Country"=>"Vietnam","Model"=>"WS7234")
)

and ksort on the next leve down is going to sort the keys "Country" and "Model" 
so all the "Country" elements come before all the "Model" elements, which they 
already do.

I'm guessing what's being asked here is to be able to sort the "TBA" level (?) 
by the value of the "Model"s then by the value of the "Country"s.  So you'd end 
up with:

array (
   "TBA0123452" => array("Country"=>"England","Model"=>"WS1234"),
   "TBA0123456" => array("Country"=>"Singapore","Model"=>"WS1234"),
   "TBA0123458" => array("Country"=>"Indonesia","Model"=>"WS2234"),
   "TBA0123451" => array("Country"=>"Germany","Model"=>"WS6234"),
   "TBA0123459" => array("Country"=>"Vietnam","Model"=>"WS7234")
)

(Changed Singapore's Model to match England's to illustrate Model then Country 
sorting)

If this is what the goal is, then it looks like the uasort() function might 
help.  Although I havn't messed with any of the usort() functions and on the 
surface they kind of bewilder me, but I believe that's what might help here.  
It does a user defined sort while maintaining index associations.

http://us3.php.net/manual/en/function.uasort.php

Hope that helps.

-TG





= = = Original message = = =

[snip]
I have the array below : How to sort the array by "Model" and "Country?

Thanks

array(

   "TBA0123456" => array("Country"=>"Singapore","Model"=>"WS8234"),
   "TBA0123458" => array("Country"=>"Indonesia","Model"=>"WS2234"),
   "TBA0123459" => array("Country"=>"Vietnam","Model"=>"WS7234"),
   "TBA0123452" => array("Country"=>"England","Model"=>"WS1234"),
   "TBA0123451" => array("Country"=>"Germany","Model"=>"WS6234"),

)
[/snip]

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


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

--- End Message ---
--- Begin Message ---
ksort won't do what he wants... Look at usort, and something like this:

function cmp($a, $b) {
  return strcmp($a['Country'], $b['Country']);
}

usort($array, "cmp");


Andrew

----- Original Message ----- From: "Jay Blanchard" <[EMAIL PROTECTED]>
To: "weetat" <[EMAIL PROTECTED]>; <[email protected]>
Sent: Tuesday, July 18, 2006 3:17 PM
Subject: RE: [PHP] Sort Array


[snip]
I have the array below : How to sort the array by "Model" and "Country?

Thanks

array(

  "TBA0123456" => array("Country"=>"Singapore","Model"=>"WS8234"),
  "TBA0123458" => array("Country"=>"Indonesia","Model"=>"WS2234"),
  "TBA0123459" => array("Country"=>"Vietnam","Model"=>"WS7234"),
  "TBA0123452" => array("Country"=>"England","Model"=>"WS1234"),
  "TBA0123451" => array("Country"=>"Germany","Model"=>"WS6234"),

)
[/snip]

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

--- End Message ---
--- Begin Message ---
Jay Blanchard wrote:
> [snip]
> I have the array below : How to sort the array by "Model" and "Country?
> 
> Thanks
> 
> array(
> 
>    "TBA0123456" => array("Country"=>"Singapore","Model"=>"WS8234"),
>    "TBA0123458" => array("Country"=>"Indonesia","Model"=>"WS2234"),
>    "TBA0123459" => array("Country"=>"Vietnam","Model"=>"WS7234"),
>    "TBA0123452" => array("Country"=>"England","Model"=>"WS1234"),
>    "TBA0123451" => array("Country"=>"Germany","Model"=>"WS6234"),
> 
> )
> [/snip]
> 
> http://www.php.net/manual/en/function.ksort.php

you mean?:

http://php.net/manual/en/function.uasort.php



> 

--- End Message ---
--- Begin Message ---
[snip]
Jay Blanchard wrote:
> [snip]
> I have the array below : How to sort the array by "Model" and
"Country?
> 
> Thanks
> 
> array(
> 
>    "TBA0123456" => array("Country"=>"Singapore","Model"=>"WS8234"),
>    "TBA0123458" => array("Country"=>"Indonesia","Model"=>"WS2234"),
>    "TBA0123459" => array("Country"=>"Vietnam","Model"=>"WS7234"),
>    "TBA0123452" => array("Country"=>"England","Model"=>"WS1234"),
>    "TBA0123451" => array("Country"=>"Germany","Model"=>"WS6234"),
> 
> )
> [/snip]
> 
> http://www.php.net/manual/en/function.ksort.php

you mean?:

http://php.net/manual/en/function.uasort.php
[/snip]

That too. And RTFM.

--- End Message ---
--- Begin Message ---
At 10:51 AM 7/18/2006, weetat wrote:

Hi


I have the array below : How to sort the array by "Model" and "Country?

Thanks

array(

  "TBA0123456" => array("Country"=>"Singapore","Model"=>"WS8234"),
  "TBA0123458" => array("Country"=>"Indonesia","Model"=>"WS2234"),
  "TBA0123459" => array("Country"=>"Vietnam","Model"=>"WS7234"),
  "TBA0123452" => array("Country"=>"England","Model"=>"WS1234"),
  "TBA0123451" => array("Country"=>"Germany","Model"=>"WS6234"),

)

You do not way how the array is created.

If from a database, add " SORT by Model, Country " to your query and let the database do the work. Otherwise, read up on ar_multisort(), but I do not think you are going to find a built-in way of sorting one array on two indexes or key values.

Regards - Miles Thompson

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.394 / Virus Database: 268.10.1/390 - Release Date: 7/17/2006

--- End Message ---
--- Begin Message ---
I have the following code:

pg_query($conn,"BEGIN TRANSACTION;
          DELETE FROM codigo_postal;
          COPY
codigo_postal(codigo_postal,asentamiento,tipo_asentamiento,municipio,estado)
FROM '$tmpfname2' DELIMITER '|';
          COMMIT");

It is suppoused as I understand it, that if an error occurs on the copy
statement, then the codigo_postal table should still have all of the
previous records. Actually I've tested it within psql and it works as
expected.

However, the shown code does not. If an error occurs on the copy
transaction, the data on the table gets deleted.

I'm certainly lost on this one, is it a bug ?, am I doing something
wrong ? (most likely I guess)

Any help will be apprecciated.

PHP: 5.1.2
PostgreSQL: 8.1.4
Apache: 2.0.55
Debian Linux with Kernel 2.6.16


-- 
Luis Magaña
Gnovus Networks & Software
www.gnovus.com

--- End Message ---
--- Begin Message ---
Luis Magaña wrote:
> I have the following code:
> 
> pg_query($conn,"BEGIN TRANSACTION;
>           DELETE FROM codigo_postal;
>           COPY
> codigo_postal(codigo_postal,asentamiento,tipo_asentamiento,municipio,estado)
> FROM '$tmpfname2' DELIMITER '|';
>           COMMIT");
> 
> It is suppoused as I understand it, that if an error occurs on the copy
> statement, then the codigo_postal table should still have all of the
> previous records. Actually I've tested it within psql and it works as
> expected.
> 
> However, the shown code does not. If an error occurs on the copy
> transaction, the data on the table gets deleted.

wrapping an SQL question in a php function doesn't make it a php question. ;-)

$apps = array("apache", "mysql", "windows"); $i = 0;
while ($i++ < 100) printf("how do I install %s?\n", $apps[ rand(0,2) ]);

// I ran that code for a laugh a number of times - seems to a bias towards
// asking how to install windows... go figure on a php list.

> 
> I'm certainly lost on this one, is it a bug ?, am I doing something
> wrong ? (most likely I guess)

you are wrong. there is no ROLLBACK specified. I suggest you
do the queries one by one (i.e. one call to pg_query() for each statement)
and if the 'COPY' fails call a 'ROLLBACK'

disclaimer: I know nothing about PG as such - I mostly use Firebird;

> 
> Any help will be apprecciated.
> 
> PHP: 5.1.2
> PostgreSQL: 8.1.4
> Apache: 2.0.55
> Debian Linux with Kernel 2.6.16
> 
> 

--- End Message ---

Reply via email to