php-general Digest 18 Oct 2005 14:38:34 -0000 Issue 3744
Topics (messages 224262 through 224276):
Re: some problems with php form
224262 by: Bruce Gilbert
224263 by: Minuk Choi
224264 by: Chris
224274 by: Bruce Gilbert
224276 by: Minuk Choi
Re: Uploaded CSV -> database
224265 by: Mark Rees
224273 by: Brian Dunning
PHP DOM XHTML - let me set my own javascript from code
224266 by: Petr Smith
Re: can't get IIS to run php if the script is not directly under wwwroot
224267 by: tony yau
How can I count the usage of mail function in scripts?
224268 by: Cristea Adrian
224270 by: Jochem Maas
php, expect and screen
224269 by: Olivier Cant
Re: Invoking a DLL with PHP
224271 by: Jay Blanchard
224272 by: Jay Blanchard
Re: fckeditor and PDF and pesky users
224275 by: Jochem Maas
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
---------- Forwarded message ----------
From: "Richard Lynch" <[EMAIL PROTECTED]>
To: "Mark Rees" <[EMAIL PROTECTED]>
Date: Mon, 17 Oct 2005 15:12:50 -0500 (CDT)
Subject: Re: [PHP] Re: a couple of problems with PHP form
On Mon, October 17, 2005 5:32 am, Mark Rees wrote:
> -----------------------------------------------------
> sorry, my editor has not indented again
> -----------------------------------------------------
> also, I want the field to appear hilighted when there is no
> information so I am doing this:
>
> <input class="<? if($error_msg){ echo "error"; } ELSE { echo
> "normal"; } id="firstname" name="firstname" type="text"
> value="{$_POST['firstname']}"? />"
I think the quote mark balancing is messed up here...
><input class="
>this starts a quote for the class=
>There appears to be no ending quote for that...
I>t may simply have been lost in email editing, however...
adding the input.error didn't solve the problem dang it.! If there is
a ending quote missing, I don't see it right off hand.
I know have:
<input class="<? if($error_msg){ echo "input.error"; } ELSE { echo
"input.normal"; } id="firstname" name="firstname" type="text"
value="{$_POST['firstname']}"? />"
in the css:
input.error {
border: 2px inset red;
margin:0;
font-family: arial, helvetica, sans-serif;
color: #036;
width: 15em;
padding-left: .25em;
font-weight: bold;
background: #eee;
}
--- End Message ---
--- Begin Message ---
Wait a minute... you meant
<input class="
<?PHP
if ($error_msg)
{
echo "input.error";
}
else
{
echo "input.normal";
}
?>" id="firstname" name="firstname" type="text" value="<?PHP echo
$_POST['firstname'];?>">
...or am I looking at the wrong thing?
Bruce Gilbert wrote:
---------- Forwarded message ----------
From: "Richard Lynch" <[EMAIL PROTECTED]>
To: "Mark Rees" <[EMAIL PROTECTED]>
Date: Mon, 17 Oct 2005 15:12:50 -0500 (CDT)
Subject: Re: [PHP] Re: a couple of problems with PHP form
On Mon, October 17, 2005 5:32 am, Mark Rees wrote:
-----------------------------------------------------
sorry, my editor has not indented again
-----------------------------------------------------
also, I want the field to appear hilighted when there is no
information so I am doing this:
<input class="<? if($error_msg){ echo "error"; } ELSE { echo
"normal"; } id="firstname" name="firstname" type="text"
value="{$_POST['firstname']}"? />"
I think the quote mark balancing is messed up here...
<input class="
this starts a quote for the class=
There appears to be no ending quote for that...
I>t may simply have been lost in email editing, however...
adding the input.error didn't solve the problem dang it.! If there is
a ending quote missing, I don't see it right off hand.
I know have:
<input class="<? if($error_msg){ echo "input.error"; } ELSE { echo
"input.normal"; } id="firstname" name="firstname" type="text"
value="{$_POST['firstname']}"? />"
in the css:
input.error {
border: 2px inset red;
margin:0;
font-family: arial, helvetica, sans-serif;
color: #036;
width: 15em;
padding-left: .25em;
font-weight: bold;
background: #eee;
}
--- End Message ---
--- Begin Message ---
Bruce Gilbert wrote:
---------- Forwarded message ----------
From: "Richard Lynch" <[EMAIL PROTECTED]>
To: "Mark Rees" <[EMAIL PROTECTED]>
Date: Mon, 17 Oct 2005 15:12:50 -0500 (CDT)
Subject: Re: [PHP] Re: a couple of problems with PHP form
On Mon, October 17, 2005 5:32 am, Mark Rees wrote:
-----------------------------------------------------
sorry, my editor has not indented again
-----------------------------------------------------
also, I want the field to appear hilighted when there is no
information so I am doing this:
<input class="<? if($error_msg){ echo "error"; } ELSE { echo
"normal"; } id="firstname" name="firstname" type="text"
value="{$_POST['firstname']}"? />"
I think the quote mark balancing is messed up here...
<input class="
this starts a quote for the class=
There appears to be no ending quote for that...
I>t may simply have been lost in email editing, however...
adding the input.error didn't solve the problem dang it.! If there is
a ending quote missing, I don't see it right off hand.
I know have:
<input class="<? if($error_msg){ echo "input.error"; } ELSE { echo
"input.normal"; } id="firstname" name="firstname" type="text"
value="{$_POST['firstname']}"? />"
Shouldn't you jsut be echoing "error" or "normal" . A period isn't
allowed in a class dafinition, and the css will work for all elements of
type input with a class of error. Also you don't seem to be closing the
PHP tag at the right place
This is how I would do what it looks like you're trying to do.
<input class="<?php echo !empty($error_msg)?'error':'normal'?>" id="firstname" name="firstname"
type="text" value="<?php echo htmlspecialchars($_POST['firstname'])?>" />
Chris
in the css:
input.error {
border: 2px inset red;
margin:0;
font-family: arial, helvetica, sans-serif;
color: #036;
width: 15em;
padding-left: .25em;
font-weight: bold;
background: #eee;
}
--- End Message ---
--- Begin Message ---
Minuk,
your revisions gives me an error:
*Parse error*: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
T_STRING or T_VARIABLE or T_NUM_STRING in *
/hsphere/local/home/bruceg/inspired-evolution.com/Contact_Form_test.php<http://evolution.com/Contact_Form_test.php>
* on line *63*
-Bruce
On 10/17/05, Minuk Choi <[EMAIL PROTECTED]> wrote:
>
> Wait a minute... you meant
>
> <input class="
> <?PHP
> if ($error_msg)
> {
> echo "input.error";
> }
> else
> {
> echo "input.normal";
> }
> ?>" id="firstname" name="firstname" type="text" value="<?PHP echo
> $_POST['firstname'];?>">
>
>
> ...or am I looking at the wrong thing?
>
> Bruce Gilbert wrote:
>
> >---------- Forwarded message ----------
> >From: "Richard Lynch" <[EMAIL PROTECTED]>
> >To: "Mark Rees" <[EMAIL PROTECTED]>
> >Date: Mon, 17 Oct 2005 15:12:50 -0500 (CDT)
> >Subject: Re: [PHP] Re: a couple of problems with PHP form
> >On Mon, October 17, 2005 5:32 am, Mark Rees wrote:
> >
> >
> >>-----------------------------------------------------
> >>sorry, my editor has not indented again
> >>-----------------------------------------------------
> >>also, I want the field to appear hilighted when there is no
> >>information so I am doing this:
> >>
> >><input class="<? if($error_msg){ echo "error"; } ELSE { echo
> >>"normal"; } id="firstname" name="firstname" type="text"
> >>value="{$_POST['firstname']}"? />"
> >>
> >>
> >I think the quote mark balancing is messed up here...
> >
> >
> >><input class="
> >>this starts a quote for the class=
> >>There appears to be no ending quote for that...
> >>
> >>
> >I>t may simply have been lost in email editing, however...
> >
> >
> >adding the input.error didn't solve the problem dang it.! If there is
> >a ending quote missing, I don't see it right off hand.
> >
> >I know have:
> >
> >
> ><input class="<? if($error_msg){ echo "input.error"; } ELSE { echo
> >"input.normal"; } id="firstname" name="firstname" type="text"
> >value="{$_POST['firstname']}"? />"
> >
> >in the css:
> >
> >input.error {
> > border: 2px inset red;
> > margin:0;
> > font-family: arial, helvetica, sans-serif;
> > color: #036;
> > width: 15em;
> > padding-left: .25em;
> > font-weight: bold;
> > background: #eee;
> >}
> >
> >
> >
>
--
::Bruce::
--- End Message ---
--- Begin Message ---
Can you post your Contact_Form_test.php?
<input class="<?PHP
if ($error_msg)
{
echo "input.error";
}
else
{
echo "input.normal";
}
?>" id="firstname" name="firstname" type="text" value="<?PHP echo
$_POST['firstname'];?>">
should parse into HTML by PHP. This block, I am assuming is placed in a HTML tag
and not in a <?PHP block, correct?
Bruce Gilbert wrote:
Minuk,
your revisions gives me an error:
*Parse error*: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
T_STRING or T_VARIABLE or T_NUM_STRING in *
/hsphere/local/home/bruceg/inspired-evolution.com/Contact_Form_test.php<http://evolution.com/Contact_Form_test.php>
* on line *63*
-Bruce
On 10/17/05, Minuk Choi <[EMAIL PROTECTED]> wrote:
Wait a minute... you meant
<input class="
<?PHP
if ($error_msg)
{
echo "input.error";
}
else
{
echo "input.normal";
}
?>" id="firstname" name="firstname" type="text" value="<?PHP echo
$_POST['firstname'];?>">
...or am I looking at the wrong thing?
Bruce Gilbert wrote:
---------- Forwarded message ----------
From: "Richard Lynch" <[EMAIL PROTECTED]>
To: "Mark Rees" <[EMAIL PROTECTED]>
Date: Mon, 17 Oct 2005 15:12:50 -0500 (CDT)
Subject: Re: [PHP] Re: a couple of problems with PHP form
On Mon, October 17, 2005 5:32 am, Mark Rees wrote:
-----------------------------------------------------
sorry, my editor has not indented again
-----------------------------------------------------
also, I want the field to appear hilighted when there is no
information so I am doing this:
<input class="<? if($error_msg){ echo "error"; } ELSE { echo
"normal"; } id="firstname" name="firstname" type="text"
value="{$_POST['firstname']}"? />"
I think the quote mark balancing is messed up here...
<input class="
this starts a quote for the class=
There appears to be no ending quote for that...
I>t may simply have been lost in email editing, however...
adding the input.error didn't solve the problem dang it.! If there is
a ending quote missing, I don't see it right off hand.
I know have:
<input class="<? if($error_msg){ echo "input.error"; } ELSE { echo
"input.normal"; } id="firstname" name="firstname" type="text"
value="{$_POST['firstname']}"? />"
in the css:
input.error {
border: 2px inset red;
margin:0;
font-family: arial, helvetica, sans-serif;
color: #036;
width: 15em;
padding-left: .25em;
font-weight: bold;
background: #eee;
}
--
::Bruce::
--- End Message ---
--- Begin Message ---
This discussion is starting to go over my head, but fgetscv works with
uploaded files (in PHP5 anyway). Here's some sample code:
if(isset($_FILES['userfile']['tmp_name'])){
$csvfile=fopen($_FILES['userfile']['tmp_name'],"rb");
if($csvfile==FALSE){die('error opening file');};
while(($aryData=fgetcsv($csvfile))!==FALSE){
//etc
}
> Actually I think fgetcsv will work with any valid file pointer and at
> least in PHP 5, the streams implementation will allow you to use a variety
> of protocols to create the stream.
>
> http://us2.php.net/manual/en/wrappers.php
>
> I understand that it isn't even too teribbly difficult to implement your
> own stream if one isn't already to your liking, but I'm afraid I haven't
> found need to go beyond the simple read-a-file-from disk style operation.
>
> Ben
>
> On Mon, 17 Oct 2005 11:45:04 -0400, Jim Moseby <[EMAIL PROTECTED]>
> wrote:
>
> >> -----Original Message-----
> >> From: Brian Dunning [mailto:[EMAIL PROTECTED]
> >> Sent: Monday, October 17, 2005 11:39 AM
> >> To: [email protected]
> >> Subject: Re: [PHP] Uploaded CSV -> database
> >>
> >>
> >> It looks like all of those tips will easily cover me for the latter
> >> half of the operation. Any tips on how to get the uploaded CSV file
> >> into memory in order to attack it with fgetcsv()? I'd rather
> >> not ever
> >> have to actually write the file to the server's disk.
> >>
> >> Thanks!
> >>
> >
> > If you are using the "standard" file upload facilities, your file is
> > being
> > written to disk when it is being uploaded. As far as I can tell,
> > fgetcsv()
> > will only read a file from disk:
> >
> > <?php // from the manual
> > $row = 1;
> > $handle = fopen ("test.csv","r");
> > while ($data = fgetcsv ($handle, 1000, ",")) {
> > $num = count ($data);
> > print "<p> $num fields in line $row: <br>\n";
> > $row++;
> > for ($c=0; $c < $num; $c++) {
> > print $data[$c] . "<br>\n";
> > }
> > }
> > fclose ($handle);
> > ?>
> >
> > If you are instead using a socket connection to receive the file in a
> > stream
> > from the client, you could assign it to a string variable, and use
> > explode().
> >
> > These are fairly uncharted territories for me, so others will likely
have
> > better answers.
--- End Message ---
--- Begin Message ---
Amazing - it works! The uploaded file is always stored in the temp
directory, so that issue was kind of moot. Here's my complete code,
if anyone else has this same need:
if(isset($_FILES['userfile']['tmp_name'])) {
$csvfile = fopen($_FILES['userfile']['tmp_name'], "r");
if($csvfile == FALSE) die('error opening file');
while(($datarow = fgetcsv($csvfile, 1000)) !== FALSE) {
$name = isset($datarow[0]) ? $datarow[0] : '';
$addr = isset($datarow[1]) ? $datarow[1] : '';
$city = isset($datarow[4]) ? $datarow[4] : '';
$state = isset($datarow[5]) ? $datarow[5] : '';
$zip = isset($datarow[6]) ? $datarow[6] : '';
$query = "insert into dealers
(account_id,name,addr,city,state) values
('$account_id','$name','$addr','$city','$state','$zip');";
$result = mysql_query($query) or die(mysql_error());
}
fclose($csvfile);
}
I was really surprised at how short & simple this turned out to be.
There is plenty of room for error-checking in the above snippet, but
what's there works when there are no problems.
--- End Message ---
--- Begin Message ---
Hi,
I have problem with PHP DOM extension. How can I add my own javascript
to javascript tag?
I tried it using this code
$html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n" .
" \n" .
"<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"
lang=\"en\">\n" .
"<head>\n" .
" <script type=\"text/javascript\" language=\"Javascript\" />\n" .
"</head>\n" .
"<body>hello\n" .
"</body>\n" .
"</html>";
$dom = new DomDocument();
$dom->preserveWhiteSpace = true;
$dom->loadXML($html);
$params = $dom->getElementsByTagName('script');
foreach ($params as $param) {
$dat = $dom->createTextSection("\n\nalert('ddd');\n\n");
$param->appendChild($dat);
}
echo $dom->saveXML();
but it encloses it to CDATA section automatically like this:
<script type="text/javascript"
language="Javascript"><![CDATA[alert('ddd');]]></script>
but I need it like this (because otherwise the javascript don't work):
<script type="text/javascript" language="Javascript">
//<![CDATA[
alert('ddd');
//]]>
</script>
Thanks for any idea,
Petr
--- End Message ---
--- Begin Message ---
it was the doc_root that was casuing the problem
thanks anyway
"Richard Lynch" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Mon, October 17, 2005 6:24 am, tony yau wrote:
> > the security for my 'Project' folder (aliases 'phpproject' where
> > test.php
> > is under) has
>
> Are there any security settings on the alias itself 'phpproject'?
>
> Is an alias folder the same as a "shortcut" like you make in Windows
> desktop explorer thingie?
>
> Cuz those damn things are useless to anything but Windows Explorer
> itself, as far as I could ever tell...
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Hello peoples!
short question: How can I count the usage of mail function in scripts?
long description :D
I have a webserver, and I want to limit the usage of mail function for
each host I have there.. Notice that i have a couple of hundrest of
virtual hosts (domains and subdomains) there, and i want to limit
them, let`s say.. 100 mails per day.. there is any solution to do
that? (i know there is, i saw that in a nwebhosting company) .. can
you guide me find this solution?
thanks in advance!
cheers, cajbecu
--- End Message ---
--- Begin Message ---
Cristea Adrian wrote:
Hello peoples!
short question: How can I count the usage of mail function in scripts?
question: what does this have to do with php?
(I gather you probably have lots of users mailing via php but
that doesn't mean that php should responsible for managing send quotas,
and if it was then whats to stop me using exec() to call a cmdline
mailer and bypass whatever security you have put in place?)
sounds to me like you need to look into the possibilities of
customizing you smtp server (and/or) creating some OS level
wrapper that is resonsible for quota checking.
long description :D
I have a webserver, and I want to limit the usage of mail function for
each host I have there.. Notice that i have a couple of hundrest of
virtual hosts (domains and subdomains) there, and i want to limit
them, let`s say.. 100 mails per day.. there is any solution to do
that? (i know there is, i saw that in a nwebhosting company) .. can
you guide me find this solution?
question is why you would want to set such limits - if you have abusive
domains - drop them?
thanks in advance!
cheers, cajbecu
--- End Message ---
--- Begin Message ---
Hi list,
I'm wondering if any one has any experience at connecting to a screen
session under linux with a PHP script, and reading the pty output
(and maybe writing somme stuff as well)
I have an interactive program runing under screen which give me some
status info, and I may also issue command to it and would like to
interfce that whole thing using PHP... and screen because I can(t
keep a console attached forever to it.
Any idea ?
thanks all
--- End Message ---
--- Begin Message ---
[snip]
You can build your own dll -or use that older dll as you say-, assuming
it have exported the necessary functions and calling them using the
php_w32api extension, just register necessary types, functions and
you're ready to go, without any kind of recompilation of php or any dll
static linking, the dll is just loaded when you register the dll
functions from the php code using that beautiful extension. There are
some tricks if you take this way, in relation with the type and size of
data you need to send or receive from the dll, but it works pretty well.
And you could code your own dll wrapper interface to the older dll if
some workaround is needed to have it working -perhaps callbacks, hard
data types, etc.-
[/snip]
php_w32api extension...that sounds like a plan....I wonder why it is not
mentioned with regards to things like this?
--- End Message ---
--- Begin Message ---
[snip]
[snip]
You can build your own dll -or use that older dll as you say-, assuming
it have exported the necessary functions and calling them using the
php_w32api extension, just register necessary types, functions and
you're ready to go, without any kind of recompilation of php or any dll
static linking, the dll is just loaded when you register the dll
functions from the php code using that beautiful extension. There are
some tricks if you take this way, in relation with the type and size of
data you need to send or receive from the dll, but it works pretty well.
And you could code your own dll wrapper interface to the older dll if
some workaround is needed to have it working -perhaps callbacks, hard
data types, etc.-
[/snip]
php_w32api extension...that sounds like a plan....I wonder why it is not
mentioned with regards to things like this?
[/snip]
I also forgot to ask if you would expand on your methodology a little,
perhaps with an example?
--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
On Mon, October 17, 2005 3:56 pm, Torgny Bjers wrote:
Also, when using <iframe/> you are weeding out those old browsers that
If somebody else wants to weed out old browsers, that's all fine and
good, but that's not me...
Besides, if this is for an editor interface, for a specific client,
one
could reasonably demand that they use at least one of the newer
browsers
such as IE5+ or Mozilla. If not for a specific client, or subset of
clients, but for a general update of an entire application that is
open
sourced, I agree with Jasper, don't touch it. :)
I personally don't think I should demand editors use a specific browser.
I believe in customer choice.
NOAM CHOMPSKY --> Manufactured Consent
just a loose cannon :-)
For that matter, *I* probably don't use a browser that does this
right, being as I'm usually on Linux, almost always on Netscape, and
very very very rarely do PDF and/or Flash work really right for me.
And you know what?
I very very very seldom care badly enough about any of the content I'm
"missing" and when I do care enough to go get it, I'm disappointed by
the content more often than I'm pleased that I took that effort.
I feel that - most of the all-signing all-dancing 'content' out there
is less substantial as styrofoam and less interesting.
and the next site that displays a PDF when I wasn't expecting it
and I have to spend the next five minutes waiting for the b'std to load
(with the alternative being to KILL the browser - losing all open pages
in the process) ... might just make me snap ;-)
Again, this is obviously MY weird world-view at work here. :-)
--- End Message ---