php-general Digest 17 Jan 2005 10:50:07 -0000 Issue 3232
Topics (messages 206490 through 206531):
Socket_Connect returning unusual error
206490 by: Adam Hubscher
206503 by: Richard Lynch
206505 by: Adam Hubscher
cron job style php...
206491 by: Russell P Jones
206493 by: Randy Johnson
206494 by: Hans Zaunere
206495 by: Bret Hughes
206513 by: Ligaya Turmelle
Phonetic speller function
206492 by: Dotan Cohen
206496 by: Greg Donald
206501 by: Richard Lynch
Re: use php to determine user OS
206497 by: Greg Donald
Re: imagejpeg() output
206498 by: Greg Donald
206507 by: Richard Lynch
206516 by: Rasmus Lerdorf
cancel <[EMAIL PROTECTED]>
206499 by: webmaster.offbeat-zero.net
Encoding problems using phpMyAdmin
206500 by: Lars B. Jensen
206509 by: Lars B. Jensen
206510 by: Randy Johnson
206512 by: Lars B. Jensen
socket_connect errors
206502 by: Adam Hubscher
Re: Only variables can be passed by reference - Preg_match Fatal error
206504 by: Richard Lynch
Re: Comman line vs. phpinfo()
206506 by: Richard Lynch
Re: control REMOTE_ADDR header
206508 by: Richard Lynch
Re: Any idea when 4.3.11 will be released?
206511 by: Manuel Lemos
206515 by: Rasmus Lerdorf
Persistance objects + importing
206514 by: daniel.electroteque.org
Php5 with .Net webservices
206517 by: Michael Leung
Re: php5 threadsafe / apache2 mpm=worker
206518 by: Rasmus Lerdorf
Re: Best method for threading?
206519 by: Rasmus Lerdorf
$_POST
206520 by: Andrew Maxwell
206521 by: Adam Hubscher
206522 by: Ville Mattila
206523 by: Andrew Maxwell
206524 by: Rasmus Lerdorf
Obtaining the base dir of a file in a web server
206525 by: Juan Antonio Garrido
can you solve this problem with regex ?
206526 by: Zouari Fourat
206528 by: Marek Kilimajer
206529 by: Zouari Fourat
Javascript newsgroup
206527 by: Ross Hulford
$_REQUEST or $_POST?
206530 by: gustav.varupiraten.se
PHPED PHP IDE (wasRe: [PHP] php editor)
206531 by: Benjamin Edwards
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 ---
Warning: socket_connect() expects parameter 3 to be long, string given
in testing.php on line 21
Couldn't Create Socket: Success
It actually spits that across for every socket I'm trying to connect.
I'm doing an online status for multiple servers, which I have tested to
work when I simply do a socket_connect($sock,$url,$port); on the port
numbers of the various servers. The servers all reside on the same IP
address.
The script actually works manually, ie if i put the actual port in to
the socket_connect function call. However, as soon as I put the variable
in - it wont work.
The code looks like so:
foreach ($servers as $key => $value){
$currport = $servers[$key]['Port']; // was attempting this to see
if it would work - it did not either. Normally tried
$servers[$key]['Port'] directly.
if(!socket_connect($sock, $ip, $currport)){
print("Couldn't Create Socket: " .
socket_strerror(socket_last_error()). "\n"); // Debugging purposes
$output .= "Server Name: " . $Servers[$key]['Name']. " ~~
Offline <br />";
}
else{
$output .= "Server Name: " . $Servers[$key]['Name']. " ~~
Online <br />";
}
}
I cant quite find anything that is... actually wrong with the code. I
dont understand the error all that much either, as it says "Success" in
it. Needless to say - I'm thoroughly confused!
Anyone help me out?
Thanks!
--- End Message ---
--- Begin Message ---
Adam Hubscher wrote:
> Warning: socket_connect() expects parameter 3 to be long, string given
> in testing.php on line 21
> Couldn't Create Socket: Success
PHP usually auto-converts data -- However it's possible that this
EXPERIMENTAL function (?) doesn't have the magic code down in the guts of
PHP.
So, try type-casting your third parameter to an (int):
> $currport = $servers[$key]['Port']; // was attempting this to see
$currport = (int) $servers[$key]['Port'];
echo "currport is: '$currport'<br />\n";
If this fixes it, file a bug report at http://bugs.php.net -- search for
the same issue first. It should get fixed pretty quick-like (relatively
speaking) if that's all it is.
It's also possible that your 'Port' is empty or something... That's why I
included the 'echo' -- Always hand-check the data you are sending when
weird things happen.
One line of debugging output can save hours of time and fistfuls of hair.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
Adam Hubscher wrote:
Warning: socket_connect() expects parameter 3 to be long, string given
in testing.php on line 21
Couldn't Create Socket: Success
PHP usually auto-converts data -- However it's possible that this
EXPERIMENTAL function (?) doesn't have the magic code down in the guts of
PHP.
So, try type-casting your third parameter to an (int):
$currport = $servers[$key]['Port']; // was attempting this to see
$currport = (int) $servers[$key]['Port'];
echo "currport is: '$currport'<br />\n";
If this fixes it, file a bug report at http://bugs.php.net -- search for
the same issue first. It should get fixed pretty quick-like (relatively
speaking) if that's all it is.
It's also possible that your 'Port' is empty or something... That's why I
included the 'echo' -- Always hand-check the data you are sending when
weird things happen.
One line of debugging output can save hours of time and fistfuls of hair.
I actually fixed it by using a simple preg_replace to remove any
returns/spaces. It was actually imported from a text file and I forgot
to clean up any excess characters taht could still exist.
However,now I get the error: Couldn't Create Socket: Transport endpoint
is already connected after it successfully connects once already.
The new code is found in my other post (socket_connect errors), but for
reference:
if(($sock = socket_create(AF_INET,SOCK_STREAM,SOL_TCP)) < 0){
print("Couldn't Create Socket: " .
socket_strerror(socket_last_error()). "\n");
}
socket_set_option($sock, SOL_SOCKET,SO_RCVTIMEO, array('sec' => 1,
'usec' => 0));
$output = '';
for($i = 0; $i < count($file); $i++){
$servernum = $file[$i];
$i++;
$servername = $file[$i];
$serverport = $file2[$i];
$serverport = preg_replace('/\s/','',$serverport);
// Test if server online - if not, output offline. If yes, output
Online.
if(!socket_connect($sock, $ip, $mapport)){
print("Couldn't Create Socket: " .
socket_strerror(socket_last_error()). "\n"); // Debug
$output .= "Server Name: " . $servername. " ~~ Offline <br />";
continue;
}
else{
$output .= "Server Name: " . $servername. " ~~ Online <br />";
}
}
--- End Message ---
--- Begin Message ---
I have written a simple script that when a date in an array matches todays
date, it sends an email (notifies me when bills are due). Any ideas on how
to make this run once a day? Can you do a cron job on a PHP prog?
Russ Jones
--- End Message ---
--- Begin Message ---
Russel,
Yes you can run a cron job on php
You may have to add a line like this at the top, it has been awhile since I
have done it]
#! /usr/local/php/sapi/cli/php
this line would be different for your system
-Randy
----- Original Message -----
From: "Russell P Jones" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Sunday, January 16, 2005 6:00 PM
Subject: [PHP] cron job style php...
I have written a simple script that when a date in an array matches todays
date, it sends an email (notifies me when bills are due). Any ideas on how
to make this run once a day? Can you do a cron job on a PHP prog?
Russ Jones
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
> I have written a simple script that when a date in an array matches todays
> date, it sends an email (notifies me when bills are due). Any ideas on how
> to make this run once a day? Can you do a cron job on a PHP prog?
It can, and run basically like any other shell script.
The first line needs to be the dash-bang that point to your PHP binary.
#!/usr/local/php/bin/php
<?php
Note that the opening tag is required. No closing tag is required.
Note that you can/should compile PHP to contain the CLI binary (new releases
do). You can check what kind of PHP binary you have using -v:
Shell> /usr/local/php/bin/php -v
To keep track of scripts that I run under Apache, versus those that run on
the command line, I use the .psh extension on those that run on the command
line.
---
Hans Zaunere
President, Founder
New York PHP
http://www.nyphp.org
Gmail: The 1gb spam catcher
--- End Message ---
--- Begin Message ---
On Sun, 2005-01-16 at 17:00, Russell P Jones wrote:
> I have written a simple script that when a date in an array matches todays
> date, it sends an email (notifies me when bills are due). Any ideas on how
> to make this run once a day? Can you do a cron job on a PHP prog?
>
> Russ Jones
Never tried it but on linux (RHL or Fedora) I would add a file to
/etc/cron.daily with something like this in it
/usr/bin/php /usr/local/bin/myjob.php
where myjob.php is the php script. if it runs from the command link
now it should work. This will run as root of course and if you wnated
it to be run as someone else you could probably add the line:
0 2 * * * username /usr/bin/php /usr/local/bin/myjob.php
to /etc/crontab or the users crontab without the username field.
hth
Bret
--- End Message ---
--- Begin Message ---
Check out here - http://www.htmlcenter.com/tutorials/tutorials.cfm/155/php/
and here -
http://www.phpfreaks.com/tutorials/28/0.php
and if you want to read about my learning with cron try here -
http://www.khankennels.com/blog/index.php?p=103
Hope it all helps.
Respectfully,
Ligaya Turmelle
Russell P Jones wrote:
I have written a simple script that when a date in an array matches todays
date, it sends an email (notifies me when bills are due). Any ideas on how
to make this run once a day? Can you do a cron job on a PHP prog?
Russ Jones
--- End Message ---
--- Begin Message ---
Hi all,
I am creating an app that will take any word and return an array with all the
possible ways of spelling it. I wrote a function that replaces letter(s) with
other letter(s) with similar sounds. For instance, 'pink' returns:
Array
(
[0] => pink
[1] => pinc
[2] => pynk
[3] => pync
[4] => peenk
[5] => peenc
)
The code looks like this:
<?php
print"<pre>\n";
if (!$band) { $band="Pink Floyd"; }
$band=strtolower($band);
$misspells = array($band);
function mispel ($was,$willbe) {
global $misspells;
global $newarr;
$newarr = array();
foreach ($misspells as $mis) {
$newarr[] = str_replace($was, $willbe, $mis);
}
foreach ($newarr as $new) {
$misspells[] = $new;
}
$misspells = array_unique ($misspells);
}
mispel('c','k');
mispel('c','s');
mispel('k','c');
mispel('s','c');
mispel('l','ll');
mispel('t','tt');
mispel('i','y');
mispel('i','ee');
mispel('f','ph');
$misspells = array_unique ($misspells);
print_r($misspells);
print"</pre>";
?>
I don't know how obvious it is from my code, but I'm fairly new to php and
programming in general (I certainly don't make my living this way!). My big
obstacle now is replacing letters that appear twice in the word, such as
kayak. Focusing only on the 'k's I get this array: kayak, cayac. But I need
kayak, kayac, cayak, cayac.
I have just spent the last four hours of my life getting all exited about
exploding and imploding and str*** and replacing needles in haystacks with
the php manual (and the comments!!!). But it proves far beyond my ability to
command my little compter to give me four possible spellings of kayak.
So I now turn to the popular php community for advise. What functions could be
reccommended to complete the task? Is there a better way of doing this? Was I
better off trying to do it with explode/implode or is the replace method
better? Neither of them worked for me... Maybe a completely different
approach? And ideas would be great, links to tutorials, code snippets,
sggestions as to aproaches, cups of coffee...
Thanks guys.
Dotan Cohen
--- End Message ---
--- Begin Message ---
On Mon, 17 Jan 2005 01:07:12 +0200, Dotan Cohen
<[EMAIL PROTECTED]> wrote:
> I am creating an app that will take any word and return an array with all the
> possible ways of spelling it.
PHP has soundex, which may greatly assist in what you are doing:
php.net/soundex
Lots of good examples in the user comments.
--
Greg Donald
Zend Certified Engineer
http://destiney.com/
--- End Message ---
--- Begin Message ---
Dotan Cohen wrote:
> kayak. Focusing only on the 'k's I get this array: kayak, cayac. But I
> need
> kayak, kayac, cayak, cayac.
You may (or may not) be able to get something going with that extra
optional last argument to str_replace which tells how many characters to
replace.
str_replace('k', 'c', 'kayak', 1) ==> cayak
You probably should step back and use soundex, or one of the other "sound
like" modules in PHP as Greg suggested though, as a word with THREE k's in
it will maybe be too much hassle...
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Sat, 15 Jan 2005 18:30:02 -0800, Graham Anderson <[EMAIL PROTECTED]> wrote:
> is there a php function out there that can get the operating system of
> the user...Mac/PC/Linux
$_SERVER[ 'HTTP_USER_AGENT' ]
--
Greg Donald
Zend Certified Engineer
http://destiney.com/
--- End Message ---
--- Begin Message ---
On Sat, 15 Jan 2005 08:39:16 -0800, Steven Simmons <[EMAIL PROTECTED]> wrote:
> I'm trying to write an object oriented system for saving my uploaded
> files to a blog.
>
> I am using php to resize the original photos and save a thumbnail .
>
> When I get all done, I want to do something like this:
>
> $tempImageData = imagejpeg( $imageResource, '', 75 );
> $outputHandler -> save ( $tempImageData );
>
> Where the $outputHandler is an object that knows how/where to save the file.
> However, I've noticed that imagejpeg() only returns a number 1.
>
> This worked on my previous server, but I'm guessing my new server has a
> newer version of php.
>
> What am I doing wrong? How can i pass the raw jpeg data to a function?
To resize the image you have to create a new image handler to write
the new jpeg data to. You can create that image handler with
imagecreatetruecolor() for example.
imagejpeg() is for outputting the data to the browser.
--
Greg Donald
Zend Certified Engineer
http://destiney.com/
--- End Message ---
--- Begin Message ---
Steven Simmons wrote:
> When I get all done, I want to do something like this:
>
> $tempImageData = imagejpeg( $imageResource, '', 75 );
> $outputHandler -> save ( $tempImageData );
>
> Where the $outputHandler is an object that knows how/where to save the
> file.
> However, I've noticed that imagejpeg() only returns a number 1.
With a blank filename, I think imagejpeg() dumps your JPEG to the browser
and returns true/false for success/failure. http://php.net/imagejpeg
You'd need to use http://php.net/ob_start and friends to do what you're
trying to do.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Sat, 15 Jan 2005, Steven Simmons wrote:
> I'm trying to write an object oriented system for saving my uploaded
> files to a blog.
>
> I am using php to resize the original photos and save a thumbnail .
>
> When I get all done, I want to do something like this:
>
> $tempImageData = imagejpeg( $imageResource, '', 75 );
> $outputHandler -> save ( $tempImageData );
>
> Where the $outputHandler is an object that knows how/where to save the file.
> However, I've noticed that imagejpeg() only returns a number 1.
>
> This worked on my previous server, but I'm guessing my new server has a
> newer version of php.
>
> What am I doing wrong? How can i pass the raw jpeg data to a function?
What worked on your previous server? ImageJpeg has never returned the
image data. It has always either written it to the file you specify, or
if you don't specify one it will output it directly at that point. If you
want to capture it in a variable you will need to use output buffering.
See php.net/ob_start
-Rasmus
--- End Message ---
--- Begin Message ---
This message was cancelled from within Mozilla.
--- End Message ---
--- Begin Message ---
I seem to have problems getting phpMyAdmin showing shift_jis properly, after
upgrading to PHP5 on my FreeBSD box. mySQL is running version 4.1.8.
My application works excellent, the problem only exist in phpmyadmin.
Anyone ran into this problem before ? I've tried to google for it, but didnt
really find anything on it ?
I did as a test update the phpmyadmin sourcecode to force shift_jis charset
rather than UTF8 which it seems to prefer, to no apparent difference.
--
Lars B. Jensen, Internet Architect
CareerCross Japan
Japan's premier online career resource for english speaking professionals
http://www.careercross.com
--- End Message ---
--- Begin Message ---
Just a quick note, this seems to be a bug in phpMyAdmin since 2.5.7-pl1 - I
submitted a bug report on the sourceforge website and awaits them to handle
it.
/ Lars
--- End Message ---
--- Begin Message ---
I am just curious why you do not upgrade to the latest stable 2.6.0-pl3?
Randy
----- Original Message -----
From: "Lars B. Jensen" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Sunday, January 16, 2005 11:40 PM
Subject: Re: [PHP] Encoding problems using phpMyAdmin
Just a quick note, this seems to be a bug in phpMyAdmin since 2.5.7-pl1 -
I submitted a bug report on the sourceforge website and awaits them to
handle it.
/ Lars
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
I am just curious why you do not upgrade to the latest stable 2.6.0-pl3?
Because, any version in any patch level since 2.5.7-pl1 doesnt display
shift-jis (japanese) properly - or anyway on my system. They seem to have
broken the support for it, since that specific version.
/ Lars
--- End Message ---
--- Begin Message ---
Ok, I had made a post earlier but bout 5min later I figured out the
problem (I had spaces and returns that were in the array beside the ports).
The code looks like this:
if(($sock = socket_create(AF_INET,SOCK_STREAM,SOL_TCP)) < 0){
print("Couldn't Create Socket: " .
socket_strerror(socket_last_error()). "\n");
}
socket_set_option($sock, SOL_SOCKET,SO_RCVTIMEO, array('sec' => 1,
'usec' => 0));
$output = '';
for($i = 0; $i < count($file); $i++){
$servernum = $file[$i];
$i++;
$servername = $file[$i];
$serverport = $file2[$i];
$serverport = preg_replace('/\s/','',$serverport);
// Test if server online - if not, output offline. If yes, output Online.
if(!socket_connect($sock, $ip, $mapport)){
print("Couldn't Create Socket: " .
socket_strerror(socket_last_error()). "\n"); // Debug
$output .= "Server Name: " . $servername. " ~~ Offline <br />";
continue;
}
else{
$output .= "Server Name: " . $servername. " ~~ Online <br />";
}
}
My problem now is that as it runs through the loop - it has a connection
error. Warning: socket_connect() [function.socket-connect]: unable to
connect [106]: Transport endpoint is already connected in status.php on
line 17
Even looking at examples, I cannot figure out why this error is being
produced. I cannot close the socket at the end of the loop, as it would
make any further attempts for online status impossible.
The socket_close($sock) is directly after the loop.
Thanks for any help!
--- End Message ---
--- Begin Message ---
Adrian wrote:
> check your preg_match() call...
>
> things like "$pattern" and "$msg" are the spawn of satan btw.
> there is ABSOLUTELY NO REASON to put variables in quotation marks
> except that php has to parse the string which is slower than php just
> seeing the variable.
You'd be hard-pressed to measure a difference, I suspect.
It *IS* a bad thing stylsticly.
> and when a functions expects a reference, "$variable" will cause a
> fatal error like it happens in your script.
Ouch.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
Joseph E. Maxwell wrote:
> Just upgraded to php 4.3.10
> phpinfo() apparently stuck on
>
>
> PHP Version 4.3.5
>
>
> System FreeBSD xxxxxxx.com 4.9-STABLE FreeBSD 4.9-STABLE #0: Wed Nov
> i386
> Build Date Apr 11 2004 20:01:52
>
>
>
> Command line ==>
> php -v
> PHP 4.3.10 (cli) (built: Jan 15 2005 12:54:11)
> Copyright (c) 1997-2004 The PHP Group
> Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
>
>
> Is this a php or an Apache problem. I did do an Apache restart !
To make 100% sure your Apache restart actually happened, check the
run-times for your 'httpd' processes or use mod_status (?)
http://127.0.0.1/server-status (http://127.0.0.1/server_status?) which
will print Apache uptime (and other fun stuff)
If you didn't install mod_status, ps auxwww | grep httpd might show it, or
top.
Some Apache restart scripts don't report errors well, so when you THINK
you re-started, you didn't.
Also check the module path in httpd.conf as suggestd, and re-do PHP's
"make install" paying particular attention to where it puts things...
You may be putting the php*.so in the wrong directory.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
Alawi Albaity wrote:
> how can I can send http request with my chosen REMOTE_ADDR is there a
> class
> to do that or method in php ?
I'm not 100% certain, but I think REMOTE_ADDR comes from data embedded in
the TCP/IP info...
So, basically, you'd have to seriously hack things to forge your return IP
address... And then the data would go to somebody else. *WHY* do you
think you need this?...
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
Hello,
on 01/16/2005 10:17 AM Gal said the following:
I'm Working in organization which also using php on the Windows platform.
Because of the security holes in the older version and a COM bug at PHP
4.3.10 (http://bugs.php.net/bug.php?id=31159) we are using a problematic
version.
Does anyone here knows - what is the status of the release of 4.3.11 ?
There hasn't been even a release candidate, so do not expect a release soon.
Meanwhile, if you can build PHP from the source, you may want to try PHP
4.3.9 with the Hardened PHP patches that fix the security bugs .
http://www.hardened-php.net/
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--- End Message ---
--- Begin Message ---
On Sun, 16 Jan 2005, Gal wrote:
> I'm Working in organization which also using php on the Windows platform.
> Because of the security holes in the older version and a COM bug at PHP
> 4.3.10 (http://bugs.php.net/bug.php?id=31159) we are using a problematic
> version.
I'd just roll back to 4.3.9 and do proper input filtering. As long as you
don't pass raw user data to unserialize or do something like include
"$user_data/foo" while allowing $user_data to be huge, you are fine.
-Rasmus
--- End Message ---
--- Begin Message ---
Hi list, I am needing some advise on the best way of importing classes and
persistance, I am goingto supply some code, and would like to know if sessions
or share memory is
the best way for it.It currently serializes and unserializes the class from a
session , i
parse the directory and classusing pear naming standards, i can also send args
to it. Let me know if
there is a better way ofdoing this, as from the talk serializing is also slow.
I wonder if this
bit of code could ever becomea php extension ?? That would rock.
import 'PACKAGE_Classname'; or even import PACKAGE_Classname heh :)
becomes require_once('PACKAGE/Classname.php');
new PACKAGE_Classname(); //persist here dont reinclude per page.
function import($class_name,$serialize = null,$parse_dir = true,$args = null)
{
$parse_dir ? $filename =
preg_replace("/_/","/",$class_name) : $filename =
$class_name;
if ($serialize) {
require_once($filename.".php");
if (!isset($_SESSION[''.$class_name.''])) {
if (!$args) {
$class = new $class_name;
} else {
$num_args = func_num_args();
$params = func_get_args();
$class=
$this->_format_args($class_name,$num_args,$params);
}
$_SESSION[''.$class_name.''] =
serialize($class);
}
return
unserialize($_SESSION[''.$class_name.'']);
} else {
require_once($filename.".php");
if (!$args) {
return new $class_name;
} else {
$num_args = func_num_args();
$params = func_get_args();
return
$this->_format_args($class_name,$num_args,$params);
}
}
}
function _format_args($class_name,$num_args,$params)
{
$code = "return new {$class_name}(";
if ($num_args >= 4) {
$args = array();
for($i=3;$i<$num_args;$i++) {
$args[] = '$params[' . $i . ']';
}
$code .= implode(',',$args);
}
$code .= ');';
return eval($code);
}
--- End Message ---
--- Begin Message ---
Hi all,
Does any one try to .net webservices by PHP5?
yours,
Michael
--- End Message ---
--- Begin Message ---
On Fri, 14 Jan 2005, Jason Morehouse wrote:
> Just wondering if anyone is using the apache worker module with php?
>
> I've complied php5 with zend threadsafe support, and apache2 with the
> MPM worker module on a Linux box. Everything seems sweet.
> mysqli_thread_safe() reports true... anyone know if this configuration
> may include modules that aren't threadsafe?
>
> with-apxs2=/usr/local/apache2/bin/apxs with-gd enable-gd-native-ttf
> with-pspell with-zlib with-freetype-dir with-curlwrappers
> with-mime-magic with-curl enable-shmop with-jpeg-dir
> with-mcrypt=/usr/lib with-mysqli enable-magic-quotes
> with-enable-sockets enable-roxen-zts
Nobody can answer that question for you. You are in uncharted waters.
-Rasmus
--- End Message ---
--- Begin Message ---
On Wed, 12 Jan 2005, Galen wrote:
> I'm working on a web spider application where the server has
> considerable latency in serving the information I require, but
> simultaneous requests do not have a significant performance hit. I have
> a nice little class that handles all the sessions, cookies, etc
> perfectly. What's the best way to basically hand off a bunch of threads
> to access this information without hanging up the execution of my
> script? I plan to handle inter-thread coordination via MySQL and code
> in the main script. I've done threads before like this and have had
> great luck, but all my solutions have been hack-ish at best. What are
> the cleanest solution for this? What do you all do to handle situations
> like this?
>
> I will be running PHP 4.3.1.0 under Linux and Mac OS X, depending on
> location.
>
> Thoughts anybody?
You don't need threads for this. See http://php.net/curl_multi_exec
PHP5 only, but there is nothing PHP5-specific about the multi stuff in the
PHP5 curl extension, so you can just move it to PHP4.
-Rasmus
--- End Message ---
--- Begin Message ---
When you submit something, and you want to make sure that the user
inputs all of the info, is there an easier way to do it than this:
if ((!$_POST[name]) || !$_POST[pass]) || (!$_POST[blah]))
{
etc.....
}
is there an easy way to check if all of the varibles have data in them?
~Andrew
--- End Message ---
--- Begin Message ---
Andrew Maxwell wrote:
When you submit something, and you want to make sure that the user
inputs all of the info, is there an easier way to do it than this:
if ((!$_POST[name]) || !$_POST[pass]) || (!$_POST[blah]))
{
etc.....
}
is there an easy way to check if all of the varibles have data in them?
~Andrew
Well, you could use a simple foreach:
foreach ($_POST as $key => $value){
if($value === '') { print("You must fill in all the values");}
else{continue;}
}
I'm not sure if empty($value); would work, but its worth a try.
You could however use it, within the foreach by doing:
empty($_POST[$key]);
(if $key = name, it would test $_POST[$name] whether it is empty or not).
http://us2.php.net/manual/en/function.empty.php
I would assume that empty() would work in this case eitherway, and is
most likely your best bet.
However, within this function it may also be smart to include a few form
validation rules for the security of your form as well.
--- End Message ---
--- Begin Message ---
Andrew Maxwell wrote:
When you submit something, and you want to make sure that the user
inputs all of the info, is there an easier way to do it than this:
One method I've done that is to create an array with the required field
names, then loop it through and check whether they all have a value.
$required = array('name','pass','blah');
foreach ($required as $req) {
if (!$_POST[$req]) {
die("$reg is missing");
}
}
- Ville
--- End Message ---
--- Begin Message ---
Thats exactly what i need. Thanks a ton.
~Andrew
On Mon, 17 Jan 2005 10:58:07 +0200, Ville Mattila <[EMAIL PROTECTED]> wrote:
> Andrew Maxwell wrote:
> > When you submit something, and you want to make sure that the user
> > inputs all of the info, is there an easier way to do it than this:
>
> One method I've done that is to create an array with the required field
> names, then loop it through and check whether they all have a value.
>
> $required = array('name','pass','blah');
> foreach ($required as $req) {
> if (!$_POST[$req]) {
> die("$reg is missing");
> }
> }
>
> - Ville
>
>
>
--- End Message ---
--- Begin Message ---
Andrew Maxwell wrote:
When you submit something, and you want to make sure that the user
inputs all of the info, is there an easier way to do it than this:
if ((!$_POST[name]) || !$_POST[pass]) || (!$_POST[blah]))
{
etc.....
}
is there an easy way to check if all of the varibles have data in them?
Not sure if you will find this easier, but you can clean up your POST
array (or any other array for that matter) and get rid of any entries
matching some criteria you specify by using array_filter. In your case
you probably want to get rid of any empty strings and anything just
containing whitespace.
function clean($arg) { return strlen(trim($arg)); }
$fp = array_filter($_POST, 'clean');
Now you have your filtered post variables in the $fp array. You can
quickly check if a certain array elements are set like this:
if(isset($fp['name'],$fp['pass'],$fp['blah']))
-Rasmus
--- End Message ---
--- Begin Message ---
Hi everybody:
I use this sentence ($htmlFile = $_SERVER['DOCUMENT_ROOT'] ) for obtaining the
complete route of a file in my web server, but �inserts a white space to
final char and i need remove it. I use the trim function but it continue
there. How can i remove it? Can it be anohter char?
--
-------------------------------------------
Juan Antonio Garrido Mata
Emergya S.C.A
Tel. +34 954 98 10 53 FAX +34 954 98 11 79
Avda. Luis Montoto, 105.
E41007 - Sevilla(Espa�a)
[EMAIL PROTECTED]
http://www.emergya.info
-------------------------------------------
--- End Message ---
--- Begin Message ---
Hello !
My user can input values like this :
15.2
10-5
10 0
0x5
005
00
to be clear, i must extract two values from each line, each value is
between 1 and 20 and seaparated with a non numeric caracter, so with
lines 1,2,3 and 4 i will get :
Array([0]=>15, [1]=>2);
Array([0]=>10, [1]=>5);
Array([0]=>10, [1]=>0);
Array([0]=>0, [1]=>5);
and for other lines i will label them as erronus entries...
how can i do it intelligently :)
--- End Message ---
--- Begin Message ---
Zouari Fourat wrote:
Hello !
My user can input values like this :
15.2
10-5
10 0
0x5
005
00
to be clear, i must extract two values from each line, each value is
between 1 and 20 and seaparated with a non numeric caracter, so with
lines 1,2,3 and 4 i will get :
Array([0]=>15, [1]=>2);
Array([0]=>10, [1]=>5);
Array([0]=>10, [1]=>0);
Array([0]=>0, [1]=>5);
and for other lines i will label them as erronus entries...
how can i do it intelligently :)
yes.
if(!preg_match('/^([0-9]+)[^0-9]+([0-9]+)$/', $input, $m)) {
$m = 'error';
}
print_r($m);
--- End Message ---
--- Begin Message ---
i found that this was better :
list($ar[0], $ar[1]) = preg_split('/[^0-9]/', $string);
On Mon, 17 Jan 2005 11:27:38 +0100, Marek Kilimajer <[EMAIL PROTECTED]> wrote:
> Zouari Fourat wrote:
> > Hello !
> > My user can input values like this :
> >
> > 15.2
> > 10-5
> > 10 0
> > 0x5
> > 005
> > 00
> >
> > to be clear, i must extract two values from each line, each value is
> > between 1 and 20 and seaparated with a non numeric caracter, so with
> > lines 1,2,3 and 4 i will get :
> >
> > Array([0]=>15, [1]=>2);
> > Array([0]=>10, [1]=>5);
> > Array([0]=>10, [1]=>0);
> > Array([0]=>0, [1]=>5);
> >
> > and for other lines i will label them as erronus entries...
> >
> > how can i do it intelligently :)
> >
>
> yes.
>
> if(!preg_match('/^([0-9]+)[^0-9]+([0-9]+)$/', $input, $m)) {
> $m = 'error';
> }
>
> print_r($m);
>
--- End Message ---
--- Begin Message ---
Hi,
I need to find a good Javascript newsgroup.
Thanks,
Ross
--- End Message ---
--- Begin Message ---
Hi there!
I've learned to use $_REQUEST but it seems to me that it uses any $_GEt,
or $_POST. Is it better to $_POST when I'm just using $_POST? It seems
like that if I want "good code", but I mean is it faster with $_POST?
/G
@varupiraten.se
--- End Message ---
--- Begin Message ---
Whats the story with this. It seems too good to be true. A fully featured
IDE/Debugger released under some sort of free software licence. The site you
link to seems indicate that is is free software, it has a sourceforge.net logo
at the botton. However nuspere are selling it for �299. what is the story?
Ben
>>> eoghan <[EMAIL PROTECTED]> 01/14/05 11:03am >>>
> Since I do Java, Python etc. on OSX/windows/Linux, I'm using Eclipse
> with the PHPEclipse (PHPEclipse.de), I'm just starting PHP, but I'm
> pretty happy with it so far. One thing I am wondering about is the
> situation which Debugging in PHP4 / PHP5. Is there a Debugger for PHP?
http://dd.cron.ru/dbg/downloads.php
eoghan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
______________________________________________________________________
This email and any files transmitted with it are confidential. It is for the
intended recipient only. If you have received the email in error please notify
the author by replying to this email. If you are not the intended recipient,
you must not disclose, distribute, copy, print, or rely on this email. Any
views expressed by an individual within this email which do not constitute or
record professional advice relating to the RNLI, do not necessarily reflect the
views of the organisation.
Registered Charity Number 209603
--- End Message ---