Re: [PHP] php path and relink

2010-05-11 Thread Piero Steinger
Am 11.05.2010 02:23, schrieb Augusto Flavio:
 Hi,


 I have a shell account with limited access. The php cli version installated
 is 4.4.6. But the server have also the php 5.2.6. I checked the php version
 and i got this:


 $ php -v
 PHP 4.4.9 (cli) (built: Sep 17 2008 11:04:03)
 .

 But i want that the php command be a link to the php5.

 How can i re-link this php command to the path /usr/local/php5/bin/php ?

 I tried include this path in the PATH variable env but didn't worked.


 Some idea?


 Thanks

 Augusto Morais.

   

If it's only for your shell:
Edit .bashrc and paste this:
alias php=/usr/local/php5/bin/php

Save and re-login.


-- Piero

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



Re: [PHP] multi dimensional array question

2010-04-30 Thread Piero Steinger
Am 01.05.2010 00:57, schrieb Nick Balestra:
 hello everybody here is my array(s)


 $us_census = array('NY' = array('New York' = 8008278),
  'CA' = array('Los Angeles' = 3694820,
'San Diego' = 
 1223400),
  'IL' = array('Chicago' = 2896016),
  'TX' = array('Houston' = 1953631,
'Dallas' = 
 1188580,
'San Antonio' 
 = 1144646),
  'PA' = array('Philadelphia' = 1517550),
  'AZ' = array('Phoenix' = 1321045),
  'MI' = array('Detroit' = 951270)); 



 print 
 tabletrthState/ththCity/ththPopulation/ththTotal/th/tr;

  
 // $state is the key and $states is the value 
 foreach ($us_census as $state = $cities) {

   // $state is the key and $habitant is the value
   foreach ($cities as $city = $habitants){


   
   print 
 trtd$state/tdtd$city/tdtd$habitants/tdtd/td/tr;
   
   
   }
   }


 Now i also want to be able to count the total population per state, i am 
 stucked...
   

array_sum() should do it :)


foreach ($us_census as $state = $cities) {
$population_per_state = array_sum($cities);
}




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



Re: [PHP] Sort two coupled arrays

2010-04-07 Thread Piero Steinger
Am 07.04.2010 22:09, schrieb tedd:
 Hi gang:

 Here's the problem -- I want to sort and combine two arrays into one
 sorted array. Here's a real-world example:

 Array 1
 (
 [1] = 75
 [2] = 31
 [3] = 31
 [4] = 31
 [5] = 40
 )

 Array 2
 (
 [1] = Personal Email
 [2] = Personal Phone
 [3] = Web site
 [4] = Text Message
 [5] = USPS mail
 )

 After the operation, I want this:

 Array
 (
 [75] = Personal Email
 [40] = USPS mail
 [31] = Personal Phone
 [31] = Web site
 [31] = Text Message
 )

 Note: This is a descending-sort of Array 1 while being coupled to
 index of Array 2. In other words, the order of Array 2 depends upon
 the order of Array 1 -- the two arrays are coupled.

 I've solved this problem, but my solution is pretty lame. There has to
 be a better/slicker way.

 Suggestions?

 Cheers,

 tedd


array_combine($key_array, $value_array)
 
:)

-- Piero

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



Re: [PHP] GetElementByClass?

2010-04-03 Thread Piero Steinger
On 03.04.2010 16:29, tedd wrote:
 Hi gang:

 Here's the problem.

 I have 184 HTML pages in a directory and each page contain a question.
 The question is noted in the HTML DOM like so:

 p class=question
   Who is Roger Rabbit?
 /p

 My question is -- how can I extract the string Who is Roger Rabbit?
 from each page using php? You see, I want to store the questions in a
 database without having to re-type, or cut/paste, each one.

 Now, I can extract each question by using javascript --

 document.getElementById(question).innerHTML;

 -- and stepping through each page, but I don't want to use javascript
 for this.

 I have not found/created a working example of this using PHP. I tried
 using PHP's getElementByID(), but that requires the target file to be
 valid xml and the string to be contained within an ID and not a class.
 These pages do not support either requirement.

 Additionally, I realize that I can load the files and parse out what
 is between the p tags, but I was hoping for a GetElementByClass
 way to do this.

 So, is there one?

 Thanks,

 tedd

Hi

You could replace the class with id and then go on with JavaScript.

A possible better way are regular expressions...


Greetz
Piero


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



Re: [PHP] GetElementByClass?

2010-04-03 Thread Piero Steinger
On 03.04.2010 17:17, Ashley Sheridan wrote:
 On Sat, 2010-04-03 at 17:03 +0200, dispy wrote:

   
 Am 03.04.2010 16:29, schrieb tedd:
 
 Hi gang:

 Here's the problem.

 I have 184 HTML pages in a directory and each page contain a question.
 The question is noted in the HTML DOM like so:

 p class=question
   Who is Roger Rabbit?
 /p

 My question is -- how can I extract the string Who is Roger Rabbit?
 from each page using php? You see, I want to store the questions in a
 database without having to re-type, or cut/paste, each one.

 Now, I can extract each question by using javascript --

 document.getElementById(question).innerHTML;

 -- and stepping through each page, but I don't want to use javascript
 for this.

 I have not found/created a working example of this using PHP. I tried
 using PHP's getElementByID(), but that requires the target file to be
 valid xml and the string to be contained within an ID and not a class.
 These pages do not support either requirement.

 Additionally, I realize that I can load the files and parse out what is
 between the p tags, but I was hoping for a GetElementByClass way to
 do this.

 So, is there one?

 Thanks,

 tedd
   
 Why don't you just use REGEX? I don't know any possibility to easily
 process contents which are not valid XML/XHTML just because there's no
 library to load such stuff (but put me in right there).

 I'm not an expert of REGEX, but I think the following would do it:
 /\p\s*class\=\question\\s*\(.*)\\/p\


 (my first contribute here, I beg your pardon if something went wrong)

 Regards,

 Valentin Dreismann

 

 The . won't match new line characters, so you'll have to add those in
 too.

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

It matches new lines with the modifier s.
http://ch2.php.net/manual/en/reference.pcre.pattern.modifiers.php

Greetz
Piero


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



Re: [PHP] Wordpress/PHP question

2010-03-22 Thread Piero Steinger

On 22.03.2010 17:47, John Tamm-Buckle wrote:

Hi all,

I'm storing generated data as a post in wordpress using the wp_insert_post
function, which works great.  Users click a submit button and the things
are saved, hurrah!

However, on clicking the submit button I want to automatically navigate to
the post.  This has been less successful.  I've tried using:

header('Location: /?p=' . $postId);

In this case, where $postId = wp_insert_post($generated_text), and
$generated_text is the object that saves the output to a post.

Now when I try to save I get the following error:

Cannot modify header information - headers already sent by (output started
at /Users/sv/source/wpm/public_html/wp-content/themes/mystique/header.php:6)
in */Users/sv/source/wpm/public_html/wp-content/plugins/wpm/wpm.php* on
line *64*

Line 64 contains the header('Location: /?p=' . $postId); line.

Thanks!

John


   


Hi

What's on line 6 from file 
/Users/sv/source/wpm/public_html/wp-content/themes/mystique/header.php?



--Piero

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



Re: [PHP] Wordpress/PHP question

2010-03-22 Thread Piero Steinger

On 22.03.2010 18:45, John Tamm-Buckle wrote:

Line 6 is:

html xmlns=http://www.w3.org/1999/xhtml; ?php 
//language_attributes('xhtml'); ?


Thanks,

John

On Mon, Mar 22, 2010 at 12:38 PM, Piero Steinger pi...@the-admins.ch 
mailto:pi...@the-admins.ch wrote:


On 22.03.2010 17:47, John Tamm-Buckle wrote:

Hi all,

I'm storing generated data as a post in wordpress using the
wp_insert_post
function, which works great.  Users click a submit button
and the things
are saved, hurrah!

However, on clicking the submit button I want to automatically
navigate to
the post.  This has been less successful.  I've tried using:

header('Location: /?p=' . $postId);

In this case, where $postId = wp_insert_post($generated_text), and
$generated_text is the object that saves the output to a post.

Now when I try to save I get the following error:

Cannot modify header information - headers already sent by
(output started
at

/Users/sv/source/wpm/public_html/wp-content/themes/mystique/header.php:6)
in
*/Users/sv/source/wpm/public_html/wp-content/plugins/wpm/wpm.php*
on
line *64*

Line 64 contains the header('Location: /?p=' . $postId); line.

Thanks!

John




Hi

What's on line 6 from file
/Users/sv/source/wpm/public_html/wp-content/themes/mystique/header.php?


--Piero




--
Out now:
Kvist 002 - Raglani - Web of Light - 12
Kvist 003 - EOD - untitled - 12
Kvist 004 - JD Emmanuel - Solid Dawn - CD
Kvist 005 - Guillaume Gargaud - Here - CD

Coming soon:
Kvist 006 - Tom Hamilton - Pieces for Kohn/Formal  Informal Music - CD

www.kvistrecords.com http://www.kvistrecords.com


You have to execute the plugin first, if possible. Alternatively you can 
put a JavaScript redirect in the file wpm.php instead of a HTTP redirect.