php-general Digest 31 May 2006 12:15:53 -0000 Issue 4158

Topics (messages 237112 through 237143):

Re: how include works?
        237112 by: Chris
        237129 by: Richard Lynch

Re: sending mail via php and unix box-clients thinks it's spam
        237113 by: Chris
        237126 by: Richard Lynch

Re: Addtime is for 4.1, what can i use for 3.23? (pretty much 0T)
        237114 by: Chris
        237115 by: Ryan A
        237118 by: Chris
        237125 by: Richard Lynch

PHP, Javascript, and Forms
        237116 by: Beauford
        237119 by: Minuk Choi
        237120 by: David Tulloh
        237121 by: tedd
        237122 by: Manuel Lemos

Long one here, but hopefully someone took their Adderall
        237117 by: Pavleck, Jeremy D.

mysql_num_rows
        237123 by: John Taylor-Johnston
        237124 by: Richard Lynch

Re: Using 'header' as redirect
        237127 by: Richard Lynch
        237134 by: Richard Lynch

Re: Executing functions or scripts in parallel
        237128 by: Richard Lynch

$_FILES doesn't work but $_POST works
        237130 by: kartikay malhotra
        237132 by: Richard Lynch
        237135 by: Chris
        237136 by: Rabin Vincent
        237139 by: kartikay malhotra

Re: More about converting text strings
        237131 by: Richard Lynch
        237133 by: Paul Scott

corrupt pdfs
        237137 by: Ross
        237138 by: Chris
        237140 by: André Medeiros

Parse string with variables
        237141 by: Merlin
        237142 by: Barry
        237143 by: Dimiter Ivanov

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Arno Kuhl wrote:
On 5/30/06, Arno Kuhl <[EMAIL PROTECTED]> wrote:

I understand the difference well enough, but I've never really understood
the reason for having both. Is it to help find errors in sloppy coding, or
is there a case where including a file more than once is desirable (and
won't cause an error)?

-----Original Message-----
From: chris smith [mailto:[EMAIL PROTECTED]
Sent: 30 May 2006 02:11
To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Subject: Re: [PHP] how include works?

There was more of a difference earlier on.

On http://www.php.net/manual/en/function.require.php:

Note:  Prior to PHP 4.0.2, the following applies: require()  will
always attempt to read the target file, even if the line it's on never
executes.

Now it behaves the same way except for the failure method (require is
fatal, include is not).

--

I wasn't talking about the difference between require and include but rather
the difference between require and require_once (or include and
include_once). Why doesn't require just work the same way as require_once,
because I can't see the need for require -ing the same file more than once.
Possibly for someone that doesn't understand the purpose of functions, as
Peter suggested, but programming languages don't generally go out of their
way to cater for people who don't understand basic programming concepts.

OOP.

file "b.php"
<?php
require('a.php');

class b extends a {
}

?>

file "c.php"
<?php
require('a.php');

class c extends a {
}

?>
...

Using both class "c" and "a" within the same request would cause an error because both are require'ing a.php.

This situation might come up when developing or using any sort of API - your base methods (load, save, update, delete etc) are in "a.php" and are overridden in the subclasses.

Using that API, class b might load up a user, class c might save comments to the database - you need to load the user to check permissions before you save to the database.

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
On Tue, May 30, 2006 2:02 am, Peter Lauri wrote:
> I understand the difference well enough, but I've never really
> understood
> the reason for having both. Is it to help find errors in sloppy
> coding, or
> is there a case where including a file more than once is desirable
> (and
> won't cause an error)?

Once upon a time, a long time ago...

require would ONLY read and parse the file one time, so whatever was
in there at the first 'require' would get parsed once, and, inside of
a loop, pasted multipel times.

include would read/parse the file on each iteration of a loop.

That got changed in PHP3 or so, because A) nobody understood it, and
B) nobody really used it much anyway.

When it did get chagned, it was decided that 'require' should be more
forceful than 'include' so one should error, and one should warn.

There are DEFINITELY times where include more than once is good.

Suppose you  have the body of a <TR><TD>...</TD></TR> in an include
file, and want to include it many times, with different values.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
blackwater dev wrote:
I have a site running on a linux box.  If I use my mail server via an email
client, the email works fine but if I send email through the mail function,
clients mark it as spam.  I see the line in php.ini for SMTP but that says
windows only.  How do I tell php to use my mail server?

Are you sure the email is coming through exactly the same? Things like missing a boundary in a multipart email can break it and be marked as spam.

Anyway - use something like http://phpmailer.sf.net and point it to your smtp server. If you want to write your own version of it, you'll need to do all sorts of stuff using fsockopen and worrying about response codes and so forth.

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
On Tue, May 30, 2006 12:45 pm, blackwater dev wrote:
> I have a site running on a linux box.  If I use my mail server via an
> email
> client, the email works fine but if I send email through the mail
> function,
> clients mark it as spam.  I see the line in php.ini for SMTP but that
> says
> windows only.  How do I tell php to use my mail server?

While it is possible that the IP has been logged as a spammer, it's
more likely that the email headers are tripping you up...

Compare the two sets of email headers and see what you get, and also
look at the information provided by the spam filters about WHY they
think it's spam.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
Ryan A wrote:
Hey,
To simplify this lets say my table looks like this:

  a time default NULL,
  b time default NULL

This is what i run:
INSERT INTO test2 VALUES (Curtime( ) ,
ADDTIME(Curtime( ) , "00:01:00"))
since the db is version 3.23  (I cant ask the client
to upgrade) instead of 4.1, the above SQL is not
possible and this:

SELECT curtime( ) + INTERVAL 60 minute
is giving me null, has anybody else faced this? if so
how did you solve this?

What does

select curtime();

give you?

Make sure that's valid before trying to add to it..

Could also try:

select now() + interval 1 hour;

should come back the same (I think anyway).

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Hey Chris,


...
> > SELECT curtime( ) + INTERVAL 60 minute 
> > 
> > is giving me null, has anybody else faced this? if
> so
> > how did you solve this?
...



> What does
> select curtime();
> give you?


It gives me the correct time, eg:
03:23:01 


> Make sure that's valid before trying to add to it..
Yep, checked that, it is.

 
> Could also try:
> 
> select now() + interval 1 hour;
> 
> should come back the same (I think anyway).

No, this works, its gives me back 
2006-05-31 04:23:56

but I only need the time part not the date part thats
why i am using curtime().

Thanks,
Ryan



------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--- End Message ---
--- Begin Message ---
Ryan A wrote:
Hey Chris,


...
SELECT curtime( ) + INTERVAL 60 minute
is giving me null, has anybody else faced this? if
so
how did you solve this?
...



What does
select curtime();
give you?


It gives me the correct time, eg:
03:23:01

Make sure that's valid before trying to add to it..
Yep, checked that, it is.

Could also try:

select now() + interval 1 hour;

should come back the same (I think anyway).

No, this works, its gives me back 2006-05-31 04:23:56

but I only need the time part not the date part thats
why i am using curtime().

Ah. Yes.

Might be quicker for you to ask on a mysql mailing list :)

I tried a couple of different things looking at the mysql page (http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html) but couldn't come up with a proper solution.

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
http://dev.mysql.com/

On Tue, May 30, 2006 6:53 pm, Ryan A wrote:
> Hey,
> To simplify this lets say my table looks like this:
>
>   a time default NULL,
>   b time default NULL
>
> This is what i run:
> INSERT INTO test2 VALUES (Curtime( ) ,
> ADDTIME(Curtime( ) , "00:01:00"))
>
> since the db is version 3.23  (I cant ask the client
> to upgrade) instead of 4.1, the above SQL is not
> possible and this:
>
> SELECT curtime( ) + INTERVAL 60 minute
>
> is giving me null, has anybody else faced this? if so
> how did you solve this?
>
> I can of course run a query from my script to get the
> curtime and then add minutes to it in my php script
> and then insert it accordingly but it seems too much
> of a PITA to do that... or I dont have a choice?
>
> Thanks!
> Ryan
>
> ------
> - The faulty interface lies between the chair and the keyboard.
> - Creativity is great, but plagiarism is faster!
> - Smile, everyone loves a moron. :-)
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

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

I have a form with about 20 fields in it and have two drop down menus in
which the second one changes depending on the previous one. This is done
with a javascript which reloads the page.

The problem with this is that everything the user has put in so far gets
erased when the page reloads. I am using PHP sessions, but at this point
these fields are not saved yet.

Is there a way to do this using sessions, or some other PHP function. All
the javascript I've looked at reloads the page.

This also screws up my validation routines.

Thanks

B

--- End Message ---
--- Begin Message --- I think a better way for you to go(it may be a little bit more difficult, but it won't have any annoying "flickering" from the reloading of page) is to use AJAX.

But if you insist on going on a PHP form + Javascript validation -> submit form ->PHP form + Javascript validation, that can be done as well.

It might help to put up a sniplet of your PHP code. When you say the page is reloading, I assume that you mean you have a form tag that sends the POST data back to itself?


Beauford wrote:

Hi,

I have a form with about 20 fields in it and have two drop down menus in
which the second one changes depending on the previous one. This is done
with a javascript which reloads the page.

The problem with this is that everything the user has put in so far gets
erased when the page reloads. I am using PHP sessions, but at this point
these fields are not saved yet.

Is there a way to do this using sessions, or some other PHP function. All
the javascript I've looked at reloads the page.

This also screws up my validation routines.

Thanks

B


--- End Message ---
--- Begin Message ---
Beauford wrote:
> Hi,
> 
> I have a form with about 20 fields in it and have two drop down menus in
> which the second one changes depending on the previous one. This is done
> with a javascript which reloads the page.
> 
> The problem with this is that everything the user has put in so far gets
> erased when the page reloads. I am using PHP sessions, but at this point
> these fields are not saved yet.
> 
> Is there a way to do this using sessions, or some other PHP function. All
> the javascript I've looked at reloads the page.
> 

Javascript can do this easily, you set up your variable content section
in a div.  Then use div.innerHTML = newcontent.  Only the content of the
div will change.

Searching for innerHTML should give you a few tutorials and full examples.


David

--- End Message ---
--- Begin Message ---
At 10:03 PM -0400 5/30/06, Beauford wrote:
>Hi,
>
>I have a form with about 20 fields in it and have two drop down menus in
>which the second one changes depending on the previous one. This is done
>with a javascript which reloads the page.
>
>The problem with this is that everything the user has put in so far gets
>erased when the page reloads. I am using PHP sessions, but at this point
>these fields are not saved yet.
>
>Is there a way to do this using sessions, or some other PHP function. All
>the javascript I've looked at reloads the page.
>
>This also screws up my validation routines.
>
>Thanks
>
>B

B:

Use ajax to populate the php session variables.

tedd
-- 
------------------------------------------------------------------------------------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
Hello,

on 05/30/2006 11:03 PM Beauford said the following:
> I have a form with about 20 fields in it and have two drop down menus in
> which the second one changes depending on the previous one. This is done
> with a javascript which reloads the page.
> 
> The problem with this is that everything the user has put in so far gets
> erased when the page reloads. I am using PHP sessions, but at this point
> these fields are not saved yet.
> 
> Is there a way to do this using sessions, or some other PHP function. All
> the javascript I've looked at reloads the page.
> 
> This also screws up my validation routines.

You may want to try this forms generation and validation class. It
provides means to do exactly what you want.

It comes with several plug-ins that simplify the implementation of
controls like you want.

There is one plug-in that can link 2 or more select inputs, on which one
switches its group of options when another changes the currently
selected value.

The new group of options can be loaded from a static array or
dynamically connecting to the server via AJAX and executing some task
that gets the new set options depending on the new linked select value.

It comes also with several variants of the plugin that query databases
to retrieve the new sets of options.

Here is a screenshot of a form using the static array version:

http://www.phpclasses.org/browse/view/html/file/9879/name/test_linked_select_page.html


There is also a more generic plug-in form submitting the form using
AJAX. This means that you can submit the form without reloading the
page. In response you can tell the class to make the current browser
page be updated arbitrarily.

There is now even a plug-in to integrate with Google Maps, but that is
anothe story:

The class and all plug-ins are available here. See the dependent classes
too for more third party plug-ins:

http://www.phpclasses.org/formsgeneration


-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

--- End Message ---
--- Begin Message ---
I also have a strong suspicion this webmail will be sending this HTML 
formatted, so I apologize in advance. Anyway, here it goes!
 
Greetings All!
I'm trying to build a webpage that will pull out server information using 
snmpget and snmpwalkoid, among other things.
Most of the things I poll are fairly static, so in that regards I simply 
snmpwalkoid('server', 'community', 'oid') and then create another array that 
has my info to spit out like "System Name:" etc etc.
I then use array_combine($my_array, $theOIDArray) and run through them spitting 
out the keys & values.
But, with other things, like processors and hard drives, the snmpwalkoid may 
return multiple items - and in that case my array_combine won't work since it 
will just break.
I'm a total PHP newbie here, and I'm not sure the best way to approach this. 
I'd like to use the snmpwalkoid array VALUES with my own KEYS, then spit it out 
to the web. Here's what the array from snmpwalkoid() will look like, the exact 
OID is the key, the return is the value.
CPQIDA-MIB::cpqDaPhyDrvCntlrIndex.0.128: 0
CPQIDA-MIB::cpqDaPhyDrvCntlrIndex.0.129: 0
CPQIDA-MIB::cpqDaPhyDrvIndex.0.128: 128
CPQIDA-MIB::cpqDaPhyDrvIndex.0.129: 129
CPQIDA-MIB::cpqDaPhyDrvModel.0.128: "COMPAQ BD07286224 "
CPQIDA-MIB::cpqDaPhyDrvModel.0.129: "COMPAQ BD07286224 "
CPQIDA-MIB::cpqDaPhyDrvFWRev.0.128: "HPB6"
CPQIDA-MIB::cpqDaPhyDrvFWRev.0.129: "HPB6"
CPQIDA-MIB::cpqDaPhyDrvBay.0.128: 0
CPQIDA-MIB::cpqDaPhyDrvBay.0.129: 1
CPQIDA-MIB::cpqDaPhyDrvStatus.0.128: ok
CPQIDA-MIB::cpqDaPhyDrvStatus.0.129: ok
CPQIDA-MIB::cpqDaPhyDrvFactReallocs.0.128: -1
CPQIDA-MIB::cpqDaPhyDrvFactReallocs.0.129: -1
Now how can I combine that with:
$arrCpqDaPhyDrvIndex = array( 1 => 'Controller Index:', 'Drive Index:', 'Drive 
Model:', 'Firmware Revision:', 'Drive Bay Location:', 'Drive Status:', 'Spare 
Sectors:');
So I can get output that will look like this:
Drive A Controller Index: 0
Drive A Drive Index: 128
Drive A Drive Model: "COMPAQ BD07286224"
Drive A Firmware Revision: "HPB6"
Drive A Drive Bay Location: 0
Drive A Drive Status: ok
Drive A Spare Sectors: -1
Drive B Controller Index: 0
Drive B Drive Indes: 129
etc, etc, etc.
I'm assuming I might have to do something with the drive index number.. .But 
like I said, I'm very new to this all can't figure out how to combine the 2 
pieces of info I need. Once I figure this out, I'll be able to play with the 
data more and smooth it to the way I'd like to. Any help would be wonderful - 
thanks!
 
Jeremy

--- End Message ---
--- Begin Message ---
How can I get an integer value for mysql_affected_rows()? I get text:

" n Database Transfer(s)".

I would like to create my own error flag and exit; if the number of affected rows is <= 0.

The example for mysql-num-rows in the manual does not work. I have MySQL - 4.1.12.

$num_rows = mysql_num_rows($result);
echo "$num_rows Rows\n";

http://ca3.php.net/manual/en/function.mysql-num-rows.php

I get:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/html2/db/tools/test.php on line 29
Rows Database Transfer

Here is my code.

--------------------------------------------------------------------------------

$sql ="insert into `jtjohnston`.`ccl`
(RNum,YR,AU,ST,SD,SC,BT,BD,BC,AT,AD,AC,SR,PL,PR,JR,VNum,INum,DT,PG,LG,SF,OL,KW,AUS,TUS,GEO,AN,RB,SA,CO,RR)

select RNum,YR,AU,ST,SD,SC,BT,BD,BC,AT,AD,AC,SR,PL,PR,JR,VNum,INum,DT,PG,LG,SF,OL,KW,AUS,TUS,GEO,AN,RB,SA,
CONCAT(`CO`,' <Transfered: ".date("F jS, Y, g:i a").">;'),RR
FROM ".$_POST["dbtable"]."
WHERE id=".$_POST["transferthis"].";";

echo "<pre>".htmlspecialchars($sql)."</pre><hr size=\"1\">\n";

$myconnection = mysql_connect($server,$user,$pass);
mysql_select_db($db,$myconnection);

$result = mysql_query($sql) or die(print mysql_error());

echo mysql_affected_rows();
#$num_rows = mysql_num_rows($result);
#echo "$num_rows Rows\n";

--- End Message ---
--- Begin Message ---
INSERT queries and num_rows just don't go together.

And whatever you've done with mysql_affected_rows() is just some kind
of silly mistake on your part, almost for sure...



On Tue, May 30, 2006 11:28 pm, John Taylor-Johnston wrote:
> How can I get an integer value for mysql_affected_rows()? I get text:
>
>  " n Database Transfer(s)".
>
> I would like to create my own error flag and exit; if the number of
> affected rows is <= 0.
>
> The example for mysql-num-rows in the manual does not work. I have
> MySQL
> - 4.1.12.
>
> $num_rows = mysql_num_rows($result);
> echo "$num_rows Rows\n";
>
> http://ca3.php.net/manual/en/function.mysql-num-rows.php
>
> I get:
> Warning: mysql_num_rows(): supplied argument is not a valid MySQL
> result
> resource in /var/www/html2/db/tools/test.php on line 29
> Rows Database Transfer
>
> Here is my code.
>
> --------------------------------------------------------------------------------
>
> $sql ="insert into `jtjohnston`.`ccl`
> (RNum,YR,AU,ST,SD,SC,BT,BD,BC,AT,AD,AC,SR,PL,PR,JR,VNum,INum,DT,PG,LG,SF,OL,KW,AUS,TUS,GEO,AN,RB,SA,CO,RR)
>
> select
> RNum,YR,AU,ST,SD,SC,BT,BD,BC,AT,AD,AC,SR,PL,PR,JR,VNum,INum,DT,PG,LG,SF,OL,KW,AUS,TUS,GEO,AN,RB,SA,
> CONCAT(`CO`,' <Transfered: ".date("F jS, Y, g:i a").">;'),RR
> FROM ".$_POST["dbtable"]."
> WHERE id=".$_POST["transferthis"].";";
>
> echo "<pre>".htmlspecialchars($sql)."</pre><hr size=\"1\">\n";
>
> $myconnection = mysql_connect($server,$user,$pass);
> mysql_select_db($db,$myconnection);
>
> $result = mysql_query($sql) or die(print mysql_error());
>
> echo mysql_affected_rows();
> #$num_rows = mysql_num_rows($result);
> #echo "$num_rows Rows\n";
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
Your theory is wrong.

The correct answer is that somebody turned output_buffering "ON" in
php.ini (or .htaccess) so the output is not really sent until the
script finishes (up to 4096 chars).

On Tue, May 30, 2006 11:08 am, Philip Thompson wrote:
> Hi all.
>
> I have a site where I include pages within pages. Well, for some of
> the pages I want the user to be logged in, while others I don't care.
> I'm doing something that I thought was not allowed by the header()
> function.
>
> <!-- index.php -->
> <html>
> <head>...</head>
> <body>
> <?
> if ($subPage = $_GET['page'])
>    include ("$subPage");
> ?>
> </body>
> </html>
>
>
> <!-- some subpage that requires a login: subpage.php -->
> <?
> if (!$_SESSION["loggedIn"]) {
>    header ("location: login.php");
>    exit;
> } else {
>    ...
> }
> ?>
>
> As you can see, by the time that index.php includes the subpage, it
> has already outputted HTML. According to using the header() function,
> you are not allowed to output any HTML *before* using header().
> However, I am doing this and it is redirecting fine.
>
> I have hypothesized why it is still redirecting appropriately...
> *subpage.php* has not outputted HTML before it does the check, only
> index.php, so it does not fail. Is this correct? Any help is
> appreciated. It appears to work fine, but I don't want to be
> surprised in the future by my application breaking suddenly!! =D
>
> Thanks,
> ~Philip
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Tue, May 30, 2006 1:21 pm, Philip Thompson wrote:
> On May 30, 2006, at 12:52 PM, Stut wrote:
>
>> Philip Thompson wrote:
>>> Ok, I have modified my code a little bit. Stut, yes, output
>>> buffering was on by default (4096). I *think* this will work. It
>>> appears to be the same as before - still redirecting appropriately:
>>>
>>> <!-- index.php -->
>>> <? ob_start(); ?>
>>> <html>
>>> <head>...</head>
>>> <body>
>>> <?
>>> include ($subPage);
>>> ob_end_flush();
>>> ?>
>>> </body>
>>>
>>> The subpage does not change any, only index.php. I am basically
>>> "holding off" on displaying the stuff between ob_start() and
>>> ob_end_flush(), unless it's header information. That way, if the
>>> subpage needs to redirect, it can without errors. Correct?
>>
>> Indeed. Output buffering does exactly what it says on the tin - it
>> buffers the output until the page execution finishes or it's
>> explicitly flushed. Your ob_end_flush call is technically not
>> needed unless you have a reason to end the buffering at that point.
>>
>> -Stut
>
> I was under the impression that if ob_end_flush() was not called,
> then there would be a memory leak. Is this not the case?
>
>  From http://us3.php.net/ob_start :
>
> "Output buffers are stackable, that is, you may call ob_start() while
> another ob_start() is active. Just make sure that you call
> ob_end_flush() the appropriate number of times. If multiple output
> callback functions are active, output is being filtered sequentially
> through each of them in nesting order."

I think the "memory leak" you are considering might just be that if
you don't realize you are stacking things up, you could run out of RAM
fast while it buffers everything.

> Also 4096k... I wonder if that's enough buffering to include all the
> stuff that I want to show? As of right now, it is. Is there another
> standard level of buffering to specify?

I'm not sure the 4096 applies to ob_start() or JUST to the buffer for
php.ini ...

Hopefully it's documented somewhere...

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Tue, May 30, 2006 9:55 am, Phil Martin wrote:
>       I've made a very basic and small function to suit my needs in
> monitoring some hosts services. I've noticed that the script is a
> little bit
> slow because of the number of hosts and services to monitor. Is there
> a way
> to execute my function servstatus();  in parallel with every hosts to
> increase the speed ?

No, but if it's using http://php.net/fsockopen, that can be done
asynchronously...

You'll have to gut and change your servstatus() function to take a
BUNCH of servers to check, and open them all async, and then test them
all...

-- 
Like Music?
http://l-i-e.com/artists.htm

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

I'm using Mbuni MMS gateway, which provides me the facility to upload .mms
files.

Now with my little exposure to PHP, to upload files (say from the browser),
I use $_POST, namely:

if($_FILES['userfile']['size'] > 0)
{
 $fileName = $_FILES['userfile']['name'];
 $tmpName  = $_FILES['userfile']['tmp_name'];
...
...
}

However, with Mbuni MMS Gateway (which provides HTTP POST),  the above
condition in if loop isn't satisfied. I think $_FILES isn't working. However
the following code works:

<?php

$in='/usr/share/wallpapers/alien-night.jpg';
$out='/tmp/alien.jpg';

if(isset($_POST['userfile'])/* || $_FILES['userfile']['size'] > 0*/ )
{

$f=fopen($out,'a');
echo "HELOOOOOOOOOOOOOOOOOOOO";
copy($in, $out);
}

?>

This implies, $_POST works, and a file has been uploaded. I  however, do not
know how to access it

How to access the uploaded file, determine its size and save its contents in
a database?


Thanks in advance
KM

--- End Message ---
--- Begin Message ---
Did you put the enctype="multipart/form-data" into the FORM tag?

What you describe matches not doing that.

On Wed, May 31, 2006 12:25 am, kartikay malhotra wrote:
> Hi All,
>
> I'm using Mbuni MMS gateway, which provides me the facility to upload
> .mms
> files.
>
> Now with my little exposure to PHP, to upload files (say from the
> browser),
> I use $_POST, namely:
>
> if($_FILES['userfile']['size'] > 0)
> {
>   $fileName = $_FILES['userfile']['name'];
>   $tmpName  = $_FILES['userfile']['tmp_name'];
> ...
> ...
> }
>
> However, with Mbuni MMS Gateway (which provides HTTP POST),  the above
> condition in if loop isn't satisfied. I think $_FILES isn't working.
> However
> the following code works:
>
> <?php
>
> $in='/usr/share/wallpapers/alien-night.jpg';
> $out='/tmp/alien.jpg';
>
> if(isset($_POST['userfile'])/* || $_FILES['userfile']['size'] > 0*/ )
> {
>
> $f=fopen($out,'a');
> echo "HELOOOOOOOOOOOOOOOOOOOO";
> copy($in, $out);
> }
>
> ?>
>
> This implies, $_POST works, and a file has been uploaded. I  however,
> do not
> know how to access it
>
> How to access the uploaded file, determine its size and save its
> contents in
> a database?
>
>
> Thanks in advance
> KM
>


-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
kartikay malhotra wrote:
Hi All,

I'm using Mbuni MMS gateway, which provides me the facility to upload .mms
files.

Now with my little exposure to PHP, to upload files (say from the browser),
I use $_POST, namely:

if($_FILES['userfile']['size'] > 0)
{
 $fileName = $_FILES['userfile']['name'];
 $tmpName  = $_FILES['userfile']['tmp_name'];
...
...
}

That's not $_POST. That's $_FILES.

Show us the real code you're using.

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
On 5/31/06, kartikay malhotra <[EMAIL PROTECTED]> wrote:
However, with Mbuni MMS Gateway (which provides HTTP POST),  the above
condition in if loop isn't satisfied. I think $_FILES isn't working. However
the following code works:

<?php

$in='/usr/share/wallpapers/alien-night.jpg';
$out='/tmp/alien.jpg';

if(isset($_POST['userfile'])/* || $_FILES['userfile']['size'] > 0*/ )
{

$f=fopen($out,'a');
echo "HELOOOOOOOOOOOOOOOOOOOO";
copy($in, $out);
}

?>

This implies, $_POST works, and a file has been uploaded. I  however, do not
know how to access it

Have you tried simply saving $_POST['userfile'] to a file?

Rabin

--- End Message ---
--- Begin Message ---
Thanks for your replies.

1. Did you put the enctype="multipart/form-data" into the FORM tag?
Ans: I do not have a form! I'm using a gateway utility to upload files

From documentation of Mbuni MMS gateway:

post-url
Response content is obtained as result of sending a HTTP POST request to the
provided URL. The POST message is *always* encoding (such as that used by a
web browser when an HTML form has the submitted using the
multipart/form-dataenctype=multipart/form-data parameter set). If
http-post-parameters field is given (see below), then the relevant
parameters are sent as part of the request. *X-Mbuni* headers are sent as
well.


http-post-parameters
Used in conjunction with post-url. Parameters are provided in the same way
as would be provided in an HTTP GET request (e.g. *
message=true&myname=test&image=%i*).

2.  Have you tried simply saving $_POST['userfile'] to a file?

    $save = $_POST['userfile'];
    $f=fopen($out,'a');
    copy($save, $out);


Nothing is copied. Opened file is empty.

Pls suggest
KM

On 5/31/06, Rabin Vincent <[EMAIL PROTECTED]> wrote:

On 5/31/06, kartikay malhotra <[EMAIL PROTECTED]> wrote:
> However, with Mbuni MMS Gateway (which provides HTTP POST),  the above
> condition in if loop isn't satisfied. I think $_FILES isn't working.
However
> the following code works:
>
> <?php
>
> $in='/usr/share/wallpapers/alien-night.jpg';
> $out='/tmp/alien.jpg';
>
> if(isset($_POST['userfile'])/* || $_FILES['userfile']['size'] > 0*/ )
> {
>
> $f=fopen($out,'a');
> echo "HELOOOOOOOOOOOOOOOOOOOO";
> copy($in, $out);
> }
>
> ?>
>
> This implies, $_POST works, and a file has been uploaded. I  however, do
not
> know how to access it

Have you tried simply saving $_POST['userfile'] to a file?

Rabin


--- End Message ---
--- Begin Message ---
On Tue, May 30, 2006 4:11 am, Jonas Rosling wrote:
> While I'm using UTF-8 as char set in my documents JavaScript messages
> works
> correct with none international characters. But not the PHP code with
> session_start(). I get the following error message:
>
> Warning: session_start(): Cannot send session cookie - headers already
> sent
> by (output started at /var/www/html/index3.php:1) in
> /var/www/html/index3.php on line 2

Show us the first 2 lines of index3.php

Cuz line 1 has something in it to print out data/content.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Wed, 2006-05-31 at 00:27 -0500, Richard Lynch wrote:

> Show us the first 2 lines of index3.php
> 
> Cuz line 1 has something in it to print out data/content.

Probably whitespace outside of <?php ?>

--Paul

--- End Message ---
--- Begin Message ---
I have pdfs saved as BLOBs I create the links dynamically but only some of 
the PDFs display an error message 'error opening this files...this file 
cannot be repaired..."


Is there a file size limit in kb for Blobs and what is it?
What size of file can a LONG BLOB accomodate?
If it is not this any ideas? It seems to fix it though!

Thanks,


Ross

--- End Message ---
--- Begin Message ---
Ross wrote:
I have pdfs saved as BLOBs I create the links dynamically but only some of the PDFs display an error message 'error opening this files...this file cannot be repaired..."


Is there a file size limit in kb for Blobs and what is it?
What size of file can a LONG BLOB accomodate?

Who knows? What database are you using? Each database is different. Have you checked the databases documentation?

If it is not this any ideas? It seems to fix it though!

So does it fix it or not?

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
A quick google search tells you that LONGBLOB can contain  string with
a maximum length of 4294967295 characters, which translates into
4gb+/-

Maybe a MEDIUMBLOB (16777215 characters) would already do the trick,
no? It supports as much as 16mb +/-



On 5/31/06, Chris <[EMAIL PROTECTED]> wrote:
Ross wrote:
> I have pdfs saved as BLOBs I create the links dynamically but only some of
> the PDFs display an error message 'error opening this files...this file
> cannot be repaired..."
>
>
> Is there a file size limit in kb for Blobs and what is it?
> What size of file can a LONG BLOB accomodate?

Who knows? What database are you using? Each database is different. Have
you checked the databases documentation?

> If it is not this any ideas? It seems to fix it though!

So does it fix it or not?

--
Postgresql & php tutorials
http://www.designmagick.com/

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



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

I am trying to parse a plain text which contains variables. The string looks like this:

P=1
U=test
T=ok
P=2
U=test2
T=anything

How could I create arrays out of this. To be able to access the values like this:
echo $P[1];

parse_str does not work here and I could not find another function which does this.

Thank you for any hint,

Merlin

--- End Message ---
--- Begin Message ---
Merlin schrieb:
Hi there,

I am trying to parse a plain text which contains variables. The string looks like this:

P=1
U=test
T=ok
P=2
U=test2
T=anything

How could I create arrays out of this. To be able to access the values like this:
echo $P[1];

parse_str does not work here and I could not find another function which does this.

Thank you for any hint,

Merlin

quite less infos you give.

echo $P[2] would output test or what?
$U["test"] or $U[1] = test ??

a hint. Uhm, use regexpressions to split the string and form variables out of it.

my guess.

Barry

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--- End Message ---
--- Begin Message ---
On 5/31/06, Barry <[EMAIL PROTECTED]> wrote:
Merlin schrieb:
> Hi there,
>
> I am trying to parse a plain text which contains variables. The string
> looks like this:
>
> P=1
> U=test
> T=ok
> P=2
> U=test2
> T=anything
>
> How could I create arrays out of this. To be able to access the values
> like this:
> echo $P[1];
>
> parse_str does not work here and I could not find another function which
> does this.
>
> Thank you for any hint,
>
> Merlin

quite less infos you give.

echo $P[2] would output test or what?
$U["test"] or $U[1] = test ??

a hint. Uhm, use regexpressions to split the string and form variables
out of it.

my guess.

Barry

OR, you could try :
1st split the text by newline into array.
Then split every element of the resulting array by '=' and
then you have all you need to create the variables, i guess :)

simple example :
$text_arr = explode("\n",$text);
foreach($text AS $val){
$temp_arr=explode("=",$val);
$$temp_arr[0][] = $temp_arr[1]; // not sure if this line is correct...
}

--- End Message ---

Reply via email to