php-general Digest 14 Nov 2010 20:49:18 -0000 Issue 7036

2010-11-14 Thread php-general-digest-help

php-general Digest 14 Nov 2010 20:49:18 - Issue 7036

Topics (messages 309478 through 309480):

Re: confusion about the file extension for php interpreter to interpret
309478 by: Sharl.Jimh.Tsin
309479 by: »ÝÐÂå·

Re: String manipulation
309480 by: Ron Piggott

Administrivia:

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

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

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


--
---BeginMessage---
you can use Apache configuration and mod_rewrite to get it, without no
changes on php.

Best regards,
Sharl.Jimh.Tsin (From China **Obviously Taiwan INCLUDED**)



2010/11/14 肖晗 xiaohan2...@gmail.com:
 Apache defaultly use php interpreter to execute files ended with '.php'
 extension.
 How can I change this rule?Can I  change the default extension to any
 arbitrary name? Such as .PHP or .Php and so on.
 And I am using Ubuntu/Linux, Apache2 and php5.

 Thanks very much!

---End Message---
---BeginMessage---
Hi:

  add AddType application/x-httpd-php .Php into httpd.conf or any
other config file in apache/conf/extra

thanks

惠新宸 Xinchen Hui
http://www.laruence.com/

On 11/14/2010 13:29, 肖晗 wrote:
 Apache defaultly use php interpreter to execute files ended with '.php'
 extension.
 How can I change this rule?Can I  change the default extension to any
 arbitrary name? Such as .PHP or .Php and so on.
 And I am using Ubuntu/Linux, Apache2 and php5.
 
 Thanks very much!
---End Message---
---BeginMessage---

How would I write an IF statement that looks for the first space space (“ “) 
left of the 76th character in a string or br, which ever comes first --- OR 
the end of the string (IE the string is less than 76 characters long? I 
specifically want is it’s character position in the string.  Ron

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info---End Message---


[PHP] Re: String manipulation

2010-11-14 Thread Ron Piggott

How would I write an IF statement that looks for the first space space (“ “) 
left of the 76th character in a string or br, which ever comes first --- OR 
the end of the string (IE the string is less than 76 characters long? I 
specifically want is it’s character position in the string.  Ron

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info

Re: [PHP] Re: String manipulation

2010-11-14 Thread a...@ashleysheridan.co.uk
What about something like this:

$pos = (strpos(' ', $string, 76))?strpos(' ',$string, 76):strlen($string);

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

- Reply message -
From: Ron Piggott ron.pigg...@actsministries.org
Date: Sun, Nov 14, 2010 20:48
Subject: [PHP] Re: String manipulation
To: php-general@lists.php.net


How would I write an IF statement that looks for the first space space (“ “) 
left of the 76th character in a string or br, which ever comes first --- OR 
the end of the string (IE the string is less than 76 characters long? I 
specifically want is it’s character position in the string.  Ron

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info

Re: [PHP] Re: String manipulation

2010-11-14 Thread D. Dante Lorenso

On 11/14/10 2:48 PM, Ron Piggott wrote:

How would I write an IF statement that looks for the first space space (“ “) left of 
the 76th character in a string orbr, which ever comes first --- OR the end of 
the string (IE the string is less than 76 characters long? I specifically want is 
it’s character position in the string.  Ron


... but you sound like you are looking for the 'wordwrap' function.

-- Dante

--
D. Dante Lorenso
da...@lorenso.com
972-333-4139

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



Re: [PHP] Re: String manipulation

2010-11-14 Thread Ron Piggott
I am receiving this error:

Warning: strpos() [function.strpos]: Offset not contained in string

I have never seen it before, what do I do?  I made one change to it though, you 
didn’t have br in it before so I changed the syntax to:

$pos = (strpos(' ', $activity_description_result, 
76))?strpos('br',$activity_description_result, 
76):strlen($activity_description_result);

Ron



The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info

From: a...@ashleysheridan.co.uk 
Sent: Sunday, November 14, 2010 4:58 PM
To: Ron Piggott ; php-general@lists.php.net 
Subject: Re: [PHP] Re: String manipulation

What about something like this:

$pos = (strpos(' ', $string, 76))?strpos(' ',$string, 76):strlen($string);

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

- Reply message -
From: Ron Piggott ron.pigg...@actsministries.org
Date: Sun, Nov 14, 2010 20:48
Subject: [PHP] Re: String manipulation
To: php-general@lists.php.net


How would I write an IF statement that looks for the first space space (“ “) 
left of the 76th character in a string or br, which ever comes first --- OR 
the end of the string (IE the string is less than 76 characters long? I 
specifically want is it’s character position in the string.  Ron

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info



[PHP] PHP loop to issue sql insert

2010-11-14 Thread Rick Dwyer

Hello List.

I have a sql command that counts, groups and sorts data from a table.   
I need to insert the results of that sql command into different table.


My sql SELECT looks like  this:

select count(*) as count, searchkeywords from searchtable group by  
searchkeywords order by count desc;


and returns records like this:

578 green
254 blue
253 red
253 yellow
118 orange
 etc.

My PHP looks like this so far:

$sql = select count(*) as count, searchkeywords from searchtable  
group by searchkeywords order by count desc;
$result = @mysql_query($sql,$connection) or die(Couldn't execute  
checkcat query);

$num = mysql_num_rows($result);
echo $num;


The echo is of course returning the total number of records not  
data as listed above.


I know a WHILE statement is to be used here, but can't get it to work.

How do I loop through the above found data, inserting each value as  
like this:


insert into mytable (count, color) values (578, green);
insert into mytable (count, color) values (254, blue);
...etc



Thanks,


 --Rick


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



Re: [PHP] PHP loop to issue sql insert

2010-11-14 Thread Simon J Welsh
On 15/11/2010, at 12:47 PM, Rick Dwyer wrote:

 Hello List.
 
 I have a sql command that counts, groups and sorts data from a table.  I need 
 to insert the results of that sql command into different table.
 
 My sql SELECT looks like  this:
 
 select count(*) as count, searchkeywords from searchtable group by 
 searchkeywords order by count desc;
 
 and returns records like this:
 
 578   green
 254   blue
 253   red
 253   yellow
 118   orange
  etc.
 
 My PHP looks like this so far:
 
 $sql = select count(*) as count, searchkeywords from searchtable group by 
 searchkeywords order by count desc;
 $result = @mysql_query($sql,$connection) or die(Couldn't execute checkcat 
 query);
 $num = mysql_num_rows($result);
 echo $num;
 
 
 The echo is of course returning the total number of records not data as 
 listed above.
 
 I know a WHILE statement is to be used here, but can't get it to work.
 
 How do I loop through the above found data, inserting each value as like this:
 
 insert into mytable (count, color) values (578, green);
 insert into mytable (count, color) values (254, blue);
 ...etc
 
 
 
 Thanks,
 
 
 --Rick

Personally I'll get MySQL to do it for me using: insert into mytable (count, 
color) select count(*) as count, searchkeywords from searchtable group by 
searchkeywords order by count desc (see 
http://dev.mysql.com/doc/refman/5.1/en/insert-select.html for more information 
on INSERT ... SELECT)

Otherwise, you'll want to use mysql_fetch_assoc($result). Examples and 
information can be found at http://php.net/mysql_fetch_assoc
---
Simon Welsh
Admin of http://simon.geek.nz/

Who said Microsoft never created a bug-free program? The blue screen never, 
ever crashes!

http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e

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



Re: [PHP] PHP loop to issue sql insert

2010-11-14 Thread Rick Dwyer


On Nov 14, 2010, at 8:15 PM, Simon J Welsh wrote:


On 15/11/2010, at 12:47 PM, Rick Dwyer wrote:


Hello List.

I have a sql command that counts, groups and sorts data from a  
table.  I need to insert the results of that sql command into  
different table.


My sql SELECT looks like  this:

select count(*) as count, searchkeywords from searchtable group by  
searchkeywords order by count desc;


and returns records like this:

578 green
254 blue
253 red
253 yellow
118 orange
 etc.

My PHP looks like this so far:

$sql = select count(*) as count, searchkeywords from searchtable  
group by searchkeywords order by count desc;
$result = @mysql_query($sql,$connection) or die(Couldn't execute  
checkcat query);

$num = mysql_num_rows($result);
echo $num;


The echo is of course returning the total number of records not  
data as listed above.


I know a WHILE statement is to be used here, but can't get it to  
work.


How do I loop through the above found data, inserting each value as  
like this:


insert into mytable (count, color) values (578, green);
insert into mytable (count, color) values (254, blue);
...etc



Thanks,


--Rick


Personally I'll get MySQL to do it for me using: insert into mytable  
(count, color) select count(*) as count, searchkeywords from  
searchtable group by searchkeywords order by count desc (see http://dev.mysql.com/doc/refman/5.1/en/insert-select.html 
 for more information on INSERT ... SELECT)


Wow... I have never heard of the combination of INSERT... SELECT  
before worked perfectly.  Thanks.


--Rick


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



[PHP] Returning values from a function

2010-11-14 Thread Ron Piggott

I am writing a string parsing function.


I need to return 3 values from a function:

return $string_to_display;
return $string_to_parse;
return $continue_parsing;

I am not sure how to retrieve these variables.

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info

[PHP] Retrieving function values

2010-11-14 Thread Ron Piggott
I am writing a custom function and I need to be able to retrieve 3 values from 
it.

string_parse_tool ( $string_to_parse )

The 3 variables I need to retrieve from the function are:

$string_to_parse
$string_to_display
$continue_parsing

I only know how to retrieve 1 variable from a function, not 3.  Could someone 
help me please?

Thank you.

Ron

Re: [PHP] Returning values from a function

2010-11-14 Thread 惠新宸

Hi:
  return array(
 'string_to_display' = $string_to_display,
 .
  );

Best regards

惠新宸 Xinchen Hui
http://www.laruence.com/

On 2010/11/15 11:10, Ron Piggott wrote:


I am writing a string parsing function.


I need to return 3 values from a function:

return $string_to_display;
return $string_to_parse;
return $continue_parsing;

I am not sure how to retrieve these variables.

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info


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



Re: [PHP] Retrieving function values

2010-11-14 Thread Bastien Koert
On Sun, Nov 14, 2010 at 10:12 PM, Ron Piggott
ron.pigg...@actsministries.org wrote:
 I am writing a custom function and I need to be able to retrieve 3 values 
 from it.

 string_parse_tool ( $string_to_parse )

 The 3 variables I need to retrieve from the function are:

 $string_to_parse
 $string_to_display
 $continue_parsing

 I only know how to retrieve 1 variable from a function, not 3.  Could someone 
 help me please?

 Thank you.

 Ron

2 options

Pass them back as an array
$data['parse'] = some value;
$data['display'] = some value;
$data['continue'] = some value;

return $data;

or send it back as a delimited string

$data = $parse .'|'. $display .'|'. $continue;

return $data;





-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] Retrieving function values

2010-11-14 Thread Tamara Temple


On Nov 14, 2010, at 9:12 PM, Ron Piggott wrote:

I am writing a custom function and I need to be able to retrieve 3  
values from it.




To return multiple values, you have to return an array:

return array($var1, $var2, $var3);

Then at the calling site, you retrieve them with a list construct:

list ($var1, $var2, $var3) = function_returning_array($param);



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



Re: [PHP] Re: String manipulation

2010-11-14 Thread Tamara Temple


On Nov 14, 2010, at 4:48 PM, Ron Piggott wrote:


Warning: strpos() [function.strpos]: Offset not contained in string



Shouldn't you check the length of the string before giving it the  
offset?



From: a...@ashleysheridan.co.uk


$pos = (strpos(' ', $string, 76))?strpos(' ',$string,  
76):strlen($string);


Doesn't strpos(' ',$string,76) look for the first space to the *right*  
of position 76?


I really don't know how to do this except by exploding the string and  
shooting the array of characters, keeping mind of the last space found  
before you get to slot 75.



- Reply message -
From: Ron Piggott ron.pigg...@actsministries.org


How would I write an IF statement that looks for the first space  
space (“ “) left of the 76th character

^ left


in a string or br, which ever comes


first --- OR the end of the string (IE the string is less than 76  
characters long? I specifically want is it’s character position in  
the string.




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