Re: [PHP] Uploaded CSV -> database

2005-10-18 Thread Mark Rees
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: php-general@lists.php.net
> >> 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:
> >
> >  > $row = 1;
> > $handle = fopen ("test.csv","r");
> > while ($data = fgetcsv ($handle, 1000, ",")) {
> > $num = count ($data);
> > print " $num fields in line $row: \n";
> > $row++;
> > for ($c=0; $c < $num; $c++) {
> > print $data[$c] . "\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.

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



[PHP] PHP DOM XHTML - let me set my own javascript from code

2005-10-18 Thread Petr Smith

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 = "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\";>\n" .

"\n" .
"http://www.w3.org/1999/xhtml\"; xml:lang=\"en\" 
lang=\"en\">\n" .

 "\n" .
"\n" .
"\n" .
"hello\n" .
"\n" .
"";
$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:

language="Javascript">


but I need it like this (because otherwise the javascript don't work):


//


Thanks for any idea,

Petr

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



[PHP] Re: Re: can't get IIS to run php if the script is not directly under wwwroot

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
>
>

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



[PHP] How can I count the usage of mail function in scripts?

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

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



[PHP] php, expect and screen


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

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



Re: [PHP] How can I count the usage of mail function in scripts?


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



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



RE: [PHP] Invoking a DLL with PHP

[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 planI wonder why it is not
mentioned with regards to things like this?

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



RE: [PHP] Invoking a DLL with PHP

[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 planI 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?

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



Re: [PHP] Uploaded CSV -> database

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.


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



Re: [PHP] re: some problems with php form

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
* on line *63*
 -Bruce

 On 10/17/05, Minuk Choi <[EMAIL PROTECTED]> wrote:
>
> Wait a minute... you meant
>
>  }
> else
> {
> echo "input.normal";
> }
> ?>" id="firstname" name="firstname" type="text" value=" $_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:
> >>
> >> >>"normal"; } id="firstname" name="firstname" type="text"
> >>value="{$_POST['firstname']}"? />"
> >>
> >>
> >I think the quote mark balancing is messed up here...
> >
> >
> >> >"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::


Re: [PHP] fckeditor and PDF and pesky users


Richard Lynch wrote:

On Mon, October 17, 2005 3:56 pm, Torgny Bjers wrote:


Also, when using  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. :-)



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



Re: [PHP] re: some problems with php form


Can you post your Contact_Form_test.php?

" id="firstname" name="firstname" type="text" value="">

should parse into HTML by PHP.  This block, I am assuming is placed in a HTML tag 
and not in a 
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
* on line *63*
-Bruce

On 10/17/05, Minuk Choi <[EMAIL PROTECTED]> wrote:
 


Wait a minute... you meant

" id="firstname" name="firstname" type="text" value="">


...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:

"


   


I think the quote mark balancing is messed up here...


 



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:


"

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::

 



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



Re: [PHP] re: some problems with php form

I think so Minuk. Here is the *entire* form code below. Maybe someone can
also point out why the email regex validation code isn't working?
 TIA
 /begin PHP form
code*/



About You

* First Name: 

" id="firstname" name="firstname" type="text" value="">

* Last Name:



* Company: 



* Phone: 



* e-mail: 



* re-enter e-mail:





More Info.
*
URL:http://mail.google.com/mail//>

 

* Best way to
reach:


email
phone
snail mail




* Best time to
contact:



morning
evening
anytime





Send us a detailed
message specifying what you wish to accomplish with your web site.






* indicates a required field (all fields are
required).
END_FORM;
if ($_POST['op']!='ds') {
echo "$form_block";
} else if ($_POST["op"] == "ds") {

//Function saves time and space by eliminating unneccesary code
function check($fieldname)
{
global $err_msg;
if($_POST[$fieldname] == "")
{
if ( !isset($err_msg)) { $err_msg = "You haven't entered
your ".$fieldname."!"; }
elseif ( isset($err_msg)) { $err_msg="You haven't entered
your ".$fieldname."!"; }
}
return $err_msg;
}

if(!eregi("^(.+)@(.+)\\.(.+)$",$_POST['email']))
{
$error_msg .= "Your email appears to be invalid.";
$ok = "false";
}

 //
///Function execution/
//

check('firstname');
check('lastname');
check('company');
check('phone');
check('email');
check('email2');
check('URL');
check('Contact_Preference');
check('Contact_Time');
check('message');

//Validating Email Address
if ($_POST['email'] != $_POST['email2']) { $email_err = "\ne-mail address fields do not match!"; }

if (isset($err_msg) || isset($email_err)) { echo
$err_msg.$email_err."\n\n".$form_block; }
else {
//it's ok to send, so build the mail
$msg = "E-mail sent from
www.inspired-evolution.com\n
";
$msg .="Sender's first name: {$_POST['firstname']}\n";
$msg .="Sender's last name: {$_POST['lastname']}\n";
$msg .="Company name: {$_POST['company']}\n";
$msg .="Senders Phone number: {$_POST['phone']}\n";
$msg .="Senders email address: {$_POST['email']}\n";
$msg .="Senders email address (re-typed): {$_POST['email2']}\n";
$msg .="The website is : {$_POST['URL']}\n";
$msg .="I prefer to be contacted via: {$_POST['Contact_Preference']}\n";
$msg .="The Best time to contact is: {$_POST['Contact_Time']}\n";
$msg .="Message: {$_POST['message']}\n\n";
$to ="[EMAIL PROTECTED]";
$subject ="There has been a disturbance in the force";
$mailheaders ="From: Inspired-Evolution.com
\n /n>
";
$mailheaders .="Reply-To: {$_POST['email']}\n";
//send the mail
mail ($to, $subject, $msg, $mailheaders);
//display information to user
echo "Hola, $firstname!.
We have received your request for a web site review , and will respond
shortly.
Thanks for visiting inspired-evolution.com
and have a wonderful day!
Regards,
Inspired Evolution";
}

}
?>
/end PHP form
code*/


 On 10/18/05, Minuk Choi <[EMAIL PROTECTED]> wrote:
>
> Can you post your Contact_Form_test.php?
>
>  }
> else
> {
> echo "input.normal";
> }
> ?>" id="firstname" name="firstname" type="text" value=" $_POST['firstname'];?>">
>
> should parse into HTML by PHP. This block, I am assuming is placed in a
> HTML tag and not in a 
>
>
> 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
> 
> >* on line *63*
> > -Bruce
> >
> > On 10/17/05, Minuk Choi <[EMAIL PROTECTED]> wrote:
> >
> >
> >>Wait a minute... you meant
> >>
> >> >>}
> >>else
> >>{
> >>echo "input.normal";
> >>}
> >>?>" id="firstname" name="firstname" type="text" value=" >>$_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:
> 
>  "normal"; } id="firstname" name="firstname" type="text"
> value="{$_POST['firstname']}"? />"
> 
> 
> 
> 
> >>>I think the quote mark balancing is messed up here...
> >>>
> >>>
> >>>
> >>>
>  >

Re: [PHP] re: some problems with php form


Seems like you're using some sort of a template or something.

I am not familiar with this type, so I'm afraid I can't be of much 
help... but if i had to guess, it seems that you have to use {} instead 
of   So try this :


replace from the with this


/* 
* Do all the logic BEFORE the form layout

*/
$class = "input.normal";

if ($error_msg)
$class = "input.error";

$form_block=<<

About You

* First Name: 



Regarding the regex,

check out this page http://www.sitepoint.com/article/regular-expressions-php

the gist of it is
|
eregi('[EMAIL PROTECTED],5}$', $email)|


Good Luck

Bruce Gilbert wrote:


I think so Minuk. Here is the *entire* form code below. Maybe someone can
also point out why the email regex validation code isn't working?
TIA
/begin PHP form
code*/



About You

* First Name: 

" id="firstname" name="firstname" type="text" value="">

* Last Name:



* Company: 



* Phone: 



* e-mail: 



* re-enter e-mail:





More Info.
*
URL:http://mail.google.com/mail//>

 

* Best way to
reach:


email
phone
snail mail




* Best time to
contact:



morning
evening
anytime





Send us a detailed
message specifying what you wish to accomplish with your web site.






* indicates a required field (all fields are
required).
END_FORM;
if ($_POST['op']!='ds') {
echo "$form_block";
} else if ($_POST["op"] == "ds") {

//Function saves time and space by eliminating unneccesary code
function check($fieldname)
{
global $err_msg;
if($_POST[$fieldname] == "")
{
if ( !isset($err_msg)) { $err_msg = "You haven't entered
your ".$fieldname."!"; }
elseif ( isset($err_msg)) { $err_msg="You haven't entered
your ".$fieldname."!"; }
}
return $err_msg;
}

if(!eregi("^(.+)@(.+)\\.(.+)$",$_POST['email']))
{
$error_msg .= "Your email appears to be invalid.";
$ok = "false";
}

//
///Function execution/
//

check('firstname');
check('lastname');
check('company');
check('phone');
check('email');
check('email2');
check('URL');
check('Contact_Preference');
check('Contact_Time');
check('message');

//Validating Email Address
if ($_POST['email'] != $_POST['email2']) { $email_err = "\ne-mail address fields do not match!"; }

if (isset($err_msg) || isset($email_err)) { echo
$err_msg.$email_err."\n\n".$form_block; }
else {
//it's ok to send, so build the mail
$msg = "E-mail sent from
www.inspired-evolution.com\n
";
$msg .="Sender's first name: {$_POST['firstname']}\n";
$msg .="Sender's last name: {$_POST['lastname']}\n";
$msg .="Company name: {$_POST['company']}\n";
$msg .="Senders Phone number: {$_POST['phone']}\n";
$msg .="Senders email address: {$_POST['email']}\n";
$msg .="Senders email address (re-typed): {$_POST['email2']}\n";
$msg .="The website is : {$_POST['URL']}\n";
$msg .="I prefer to be contacted via: {$_POST['Contact_Preference']}\n";
$msg .="The Best time to contact is: {$_POST['Contact_Time']}\n";
$msg .="Message: {$_POST['message']}\n\n";
$to ="[EMAIL PROTECTED]";
$subject ="There has been a disturbance in the force";
$mailheaders ="From: Inspired-Evolution.com
\n /n>
";
$mailheaders .="Reply-To: {$_POST['email']}\n";
//send the mail
mail ($to, $subject, $msg, $mailheaders);
//display information to user
echo "Hola, $firstname!.
We have received your request for a web site review , and will respond
shortly.
Thanks for visiting inspired-evolution.com
and have a wonderful day!
Regards,
Inspired Evolution";
}

}
?>
/end PHP form
code*/


On 10/18/05, Minuk Choi <[EMAIL PROTECTED]> wrote:
 


Can you post your Contact_Form_test.php?

" id="firstname" name="firstname" type="text" value="">

should parse into HTML by PHP. This block, I am assuming is placed in a
HTML tag and not in a


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
 



   


* on line *63*
-Bruce

On 10/17/05, Minuk Choi <[EMAIL PROTECTED]> wrote:


 


Wait a minute... you meant

" id="firstname" name="firstname" type="text" value="">


...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

[PHP] Re: How can I count the usage of mail function in scripts?

Cristea Adrian schrieb:
> 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?

This is not a PHP problem. The mail() function just uses the mail server
of the system it is running on. There are several solutions to the problem.

For exmaple: If you could configure your server so that the user's PHP
scripts run under their user ID (chroot/CGI), you can use the normal
mail quota system.

And: No, I can't help you any further on this.

OLLi

Mal: "You only gotta scare him."
Jayna: "Pain is scary..."
[firefly]

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



[PHP] Re: How can I count the usage of mail function in scripts?

One more point: If I were your customer and you'd deploy such
restrictions, I would leave you. Usually customers pay a fix fee for
some free traffic and then must pay for traffic exceeding those limits.
What they do with that traffic is none of your business.

There are a lot of companies sending out newsletters in a mothly fashion
to all of their 2 users who requested to get that newsletter...

OLLi


"Time continues to skip forward randomly. Details at eleven...This is
the news at eleven.
The mysterious and unexplained... Turning to Entertainment News. Teen
Singer Wendy might
just be the latest... won three Emmies last night...found dead in her
bathtub."
[Futurama 314]

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



[PHP] Inserting NULL Integer Values

Hi,

Up to this point in time I used to construct my insert statements like this

$qid = mysql_query('INSERT INTO MYTABLE (
column1,
column2,
   ) VALUES (
"'.$value1.'",
"'.$value2.'"
   )');

However I understand it is better to remove the quote marks around an insert 
if the column type is an integer. This is easy to do, however if the $value 
is empty it causes a mysql error. Has anyone encountered this and found a 
solution?

Thanks for your advice 

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



[PHP] Re: No redirect with header()

Snippets are bad ;-)

Please post a full example that is _not_ working on your server.
Perhaps this is no PHP problem at all.

OLLi

Byers: "What proof do you have?"
Bond: "I got this!"
Byers: "You're on the phone, Jimmy!"
[Lone Gunmen 09]

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



Re: [PHP] Re: How can I count the usage of mail function in scripts?

On 10/18/05, Oliver Grätz <[EMAIL PROTECTED]> wrote:
> Usually customers pay a fix fee for
> some free traffic and then must pay for traffic exceeding those limits.
> What they do with that traffic is none of your business.

You've obviously never been a hosting provider.


--
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/


[PHP] Re: asynchronous PHP to PHP call

James schrieb:
> I have a PHP script running on server 1.  I want it to call another 
> script on server 2 to clean up some files.  There may be tons of 
> files and I don't want to wait until the second script is finished.
> 
> Is there a way to asynchronously call the second PHP script?
> 
> Right now I'm using fopen() to call the script on the second server.

Other option: Don't let the called script on server 2 do the work. Use
it to start another phpcli-script, then immediately send out the answer.
Something like



OLLi


To the optimist, the glass is half full.
To the pessimist, the glass is half empty.
To the engineer, the glass is twice as big as it needs to be.

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



[PHP] Re: Inserting NULL Integer Values

Either cast your empty ints (which should make it zero) or do an if  
(!isset($variable)) { $variable = 'NULL'; }


Ben

On Tue, 18 Oct 2005 12:15:41 -0400, "Shaun" <[EMAIL PROTECTED]>  
wrote:



Hi,

Up to this point in time I used to construct my insert statements like  
this


$qid = mysql_query('INSERT INTO MYTABLE (
column1,
column2,
   ) VALUES (
"'.$value1.'",
"'.$value2.'"
   )');

However I understand it is better to remove the quote marks around an  
insert
if the column type is an integer. This is easy to do, however if the  
$value

is empty it causes a mysql error. Has anyone encountered this and found a
solution?

Thanks for your advice




--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

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



[PHP] Re: php, expect and screen


Olivier Cant said the following on 10/18/05 02:53:

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 ?


man screen suggests you might be attempting the impossible.  Does your 
program have to be run interactively or are there other non-interactive 
ways to get your status information?


- Ben

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



Re: [PHP] Re: Inserting NULL Integer Values

What Ben said is correct, but I'd like to elaborate so you know why it's 
correct.

The INSERT statement you're trying to end up with is:

INSERT INTO MYTABLE (column1, column2) VALUES ('somevalue1', 'somevalue2')


I'm not sure why it wouldn't work if you ended up with:
INSERT INTO MYTABLE (column1, column2) VALUES ('', '')

That should work.  You can set it so you can't have NULL, but dont know of 
anything that tells the database not to accept '' as a value (barring triggers 
or other things that check on insert).

Anyway, assuming that the first example is what youre going for, then it sounds 
like this is what you want if the first value is empty:

INSERT INTO MYTABLE (column1, column2) VALUES (NULL, 'somevalue2')

So I might try something like this:

$value1 = "";
$value2 = "somevalue";

if (is_empty($value1)) {
  $value1 = "NULL";
} else {
  $value1 = "'" . $value1 . "'";
}

if (is_empty($value2)) {
  $value2 = "NULL";
} else {
  $value2 = "'" . $value2 . "'";
}

$qid = mysql_query("INSERT INTO MYTABLE (column1, column2) VALUES ($value1, 
$value2)");

That way, if it's empty, you'll get NULL, otherwise you'll get 'somevalue'.

I use double quotes (") PHP variable values (yeah, I know.. some people have 
issues because it makes everything inside interpret..blah blah..) and use 
single quotes (') for SQL stuff.  Looks like you do the opposite.  Whatever 
works for you.

Good luck!

-TG

= = = Original message = = =

Either cast your empty ints (which should make it zero) or do an if  
(!isset($variable))  $variable = 'NULL'; 

Ben

On Tue, 18 Oct 2005 12:15:41 -0400, "Shaun" <[EMAIL PROTECTED]>  
wrote:

> Hi,
>
> Up to this point in time I used to construct my insert statements like  
> this
>
> $qid = mysql_query('INSERT INTO MYTABLE (
> column1,
> column2,
>) VALUES (
> "'.$value1.'",
> "'.$value2.'"
>)');
>
> However I understand it is better to remove the quote marks around an  
> insert
> if the column type is an integer. This is easy to do, however if the  
> $value
> is empty it causes a mysql error. Has anyone encountered this and found a
> solution?
>
> Thanks for your advice


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



[PHP] Using .htaccess files with PHP CGI

I am using PHP5 as a CGI and I can't seem to figure out
how to set INI values through httpd.conf or .htaccess files.
Since PHP isn't built as a module, the php_admin_value
and php_value directives don't exist.

If I had a module version of PHP along side the CGI, this
would not help because as far as I know Apache won't parse
those php directives and pass them to the CGI instance.

I know I can call the CGI binary using a Handler and pass
var=value arguments using the '-d' flag, but I want to be able
to set them differently per Virtual Host.

Specifically, I want to set 'session.save_path' for each virtual
host to a directory other than the one set in php.ini that only
apache can read/write to since my suexec'd php cgi binary
can only write session data to a directory owned by the
virtual host user.

How can this be done?  Any help would be appreciated, thanks.

-Jason Kovacs


[PHP] Re: Inserting NULL Integer Values

Hi Ben,

Thanks for your reply, woudn't that insert a string with a value of'NULL';?

""Ben Litton"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Either cast your empty ints (which should make it zero) or do an if 
> (!isset($variable)) { $variable = 'NULL'; }
>
> Ben
>
> On Tue, 18 Oct 2005 12:15:41 -0400, "Shaun" <[EMAIL PROTECTED]> 
> wrote:
>
>> Hi,
>>
>> Up to this point in time I used to construct my insert statements like 
>> this
>>
>> $qid = mysql_query('INSERT INTO MYTABLE (
>> column1,
>> column2,
>>) VALUES (
>> "'.$value1.'",
>> "'.$value2.'"
>>)');
>>
>> However I understand it is better to remove the quote marks around an 
>> insert
>> if the column type is an integer. This is easy to do, however if the 
>> $value
>> is empty it causes a mysql error. Has anyone encountered this and found a
>> solution?
>>
>> Thanks for your advice
>
>
>
> -- 
> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ 

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



[PHP] Re: Inserting NULL Integer Values

Yes, but NULL is a special thing to MySQL. If you don't quote 'NULL' it  
just means 'empty' to mySQL. If your database schema allows NULLS (it's  
optional), your insert will go through.


On Tue, 18 Oct 2005 13:10:32 -0400, "Shaun" <[EMAIL PROTECTED]>  
wrote:



Hi Ben,

Thanks for your reply, woudn't that insert a string with a value  
of'NULL';?


""Ben Litton"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

Either cast your empty ints (which should make it zero) or do an if
(!isset($variable)) { $variable = 'NULL'; }

Ben

On Tue, 18 Oct 2005 12:15:41 -0400, "Shaun"  
<[EMAIL PROTECTED]>

wrote:


Hi,

Up to this point in time I used to construct my insert statements like
this

$qid = mysql_query('INSERT INTO MYTABLE (
column1,
column2,
   ) VALUES (
"'.$value1.'",
"'.$value2.'"
   )');

However I understand it is better to remove the quote marks around an
insert
if the column type is an integer. This is easy to do, however if the
$value
is empty it causes a mysql error. Has anyone encountered this and  
found a

solution?

Thanks for your advice




--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/




--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

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



Re: [PHP] Re: Inserting NULL Integer Values

Good explanation but I think he wanted to avoid quoting the integers. I  
may be wrong, but I think not quoting integers is a decent practice  
because it makes it easier to port your SQL over to a different database  
if you later decide you must do so. Of course he could just add a single  
quote to both sides of the string, whether it is empty or not, but if he  
wants to go without any single quotes, he'll have to use NULL or a  
numberic value for every column.


Everything you said is of course correct and a bit less lazy than my  
explanation. I would just say that if he didn't want any single quotes at  
all he could just replace your elses of $value = "'" . $value2 . "'"; with  
$value = (int) $value1; OR $value1 = intval($value1).


If he decies not going to use quotes, it's probably a good idea to make  
sure it's really an number or it'll break the query. He could also do an  
is_numeric($value1) to make sure it really is one, but if you don't mind  
converting an errant string to a zero, casting works fine.


As for the double quotes inside the parser thing, I do that too out of  
laziness on occasion, but try not to. If the OP wants to stick to the  
gospel and employ quotes he could make your else $value1 = '\'.$value1.\'';


_Ben

On Tue, 18 Oct 2005 13:42:19 -0400, <[EMAIL PROTECTED]> wrote:

What Ben said is correct, but I'd like to elaborate so you know why it's  
correct.


The INSERT statement you're trying to end up with is:

INSERT INTO MYTABLE (column1, column2) VALUES ('somevalue1',  
'somevalue2')



I'm not sure why it wouldn't work if you ended up with:
INSERT INTO MYTABLE (column1, column2) VALUES ('', '')

That should work.  You can set it so you can't have NULL, but dont know  
of anything that tells the database not to accept '' as a value (barring  
triggers or other things that check on insert).


Anyway, assuming that the first example is what youre going for, then it  
sounds like this is what you want if the first value is empty:


INSERT INTO MYTABLE (column1, column2) VALUES (NULL, 'somevalue2')

So I might try something like this:

$value1 = "";
$value2 = "somevalue";

if (is_empty($value1)) {
  $value1 = "NULL";
} else {
  $value1 = "'" . $value1 . "'";
}

if (is_empty($value2)) {
  $value2 = "NULL";
} else {
  $value2 = "'" . $value2 . "'";
}

$qid = mysql_query("INSERT INTO MYTABLE (column1, column2) VALUES  
($value1, $value2)");


That way, if it's empty, you'll get NULL, otherwise you'll get  
'somevalue'.


I use double quotes (") PHP variable values (yeah, I know.. some people  
have issues because it makes everything inside interpret..blah blah..)  
and use single quotes (') for SQL stuff.  Looks like you do the  
opposite.  Whatever works for you.


Good luck!

-TG

= = = Original message = = =

Either cast your empty ints (which should make it zero) or do an if
(!isset($variable))  $variable = 'NULL';

Ben

On Tue, 18 Oct 2005 12:15:41 -0400, "Shaun" <[EMAIL PROTECTED]>
wrote:


Hi,

Up to this point in time I used to construct my insert statements like
this

$qid = mysql_query('INSERT INTO MYTABLE (
column1,
column2,
   ) VALUES (
"'.$value1.'",
"'.$value2.'"
   )');

However I understand it is better to remove the quote marks around an
insert
if the column type is an integer. This is easy to do, however if the
$value
is empty it causes a mysql error. Has anyone encountered this and found  
a

solution?

Thanks for your advice



___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.




--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

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



Re: [PHP] Inserting NULL Integer Values



$value2 = strlen($value2) ? $value2 : 'NULL';

On Tue, October 18, 2005 11:15 am, Shaun wrote:
> Hi,
>
> Up to this point in time I used to construct my insert statements like
> this
>
> $qid = mysql_query('INSERT INTO MYTABLE (
> column1,
> column2,
>) VALUES (
> "'.$value1.'",
> "'.$value2.'"
>)');
>
> However I understand it is better to remove the quote marks around an
> insert
> if the column type is an integer. This is easy to do, however if the
> $value
> is empty it causes a mysql error. Has anyone encountered this and
> found a
> solution?
>
> Thanks for your advice
>
> --
> 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

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



RE: [PHP] re: some problems with php form

On 18 October 2005 15:50, Bruce Gilbert wrote:

> I think so Minuk. Here is the *entire* form code below. Maybe
> someone can
> also point out why the email regex validation code isn't working?  TIA
>  /begin PHP form
> code*/
> 
>  $form_block=<<  class="info_request" > 
> About You
> 
> * First
> Name:  />
> 
>  input.normal";}?>" id="firstname" name="firstname"
> type="text" value=" echo $_POST['firstname'];?>">

Again, you're trying to use PHP code inside a heredoc -- this one's solvable, 
though: as you just want the value of the variable, you can use 
{$_POST['firstname']} (which I notice you do elsewhere!).

Actually, since you use the heredoc's value once almost immediately after 
assigning it, I think you probably would be better breaking out into PHP for 
most of this, thusly:

if ($_POST['op']!='ds') {

?>


About You

* First Name: 

" id="firstname" name="firstname" type="text" value="">

   ... etc. ...

http://disclaimer.leedsmet.ac.uk/email.htm

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



[PHP] Recommended Reading?

Hi all,

Forgive this long diatribe, a bit off-topic I know, but it might
stimulate a good discussion...

I have built a few small apps in PHP before and, whilst they work, I
can't but help feeling that I go about the whole thing the WRONG way...

I am not a professional software person (far from it) but I am
reasonably competent in most things "technical". I trained in
Electronics, build my own PCs and Linux systems from scratch, have used
- just for fun - Java, Delphi, Visual Basic, PHP and a little C/C++.

I am now wanting to write my own application (using PHP of course) to do
something "really useful". And I am looking for some recommendations on
reading [books or links] about "how to design" my application and how to
think about the design in it's abstract form before I start writing
code. 

Normally I end up writing little bits of code to solve small problems
and then sort of kludging them together to do something useful. 

I would really like to try and go about this one the RIGHT way.

Thanks in advance.

Al

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



Re: [PHP] Re: Inserting NULL Integer Values

On Tue, October 18, 2005 12:42 pm, [EMAIL PROTECTED] wrote:
> That should work.  You can set it so you can't have NULL, but dont
> know of anything that tells the database not to accept '' as a value

Any database, other than MySQL, is *NOT* going to accept '' as an
integer value.

Because '' is not an integer by any stretch of the imagination.

If you don't care about ever porting your application to something
other than MySQL, then you can IGNORE the advice to not use '' on
integers.

If there's ANY possibility that some day somebody might maybe wanna
use a different database with your application, then don't confuse
strings with integers.

Actually, it might be better for your own
education/sanity/comprehension/documentation/code to not confuse
strings and integers with '' around integers in the SQL, but if
everything ELSE is good in your code, and it's "always going to be
MySQL" then it's fine.

Note that:

$value2 = 'NULL'; //PHP $value2 is a string

$query = "insert into (integer_field) values ($value2)";
//PHP $query is a string, but...

The place-holder in $value2 will be just: NULL

No quotes.

No apostrophes.

Not a string.

NULL

SQL NULL value representing "no value"

-- 
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



[PHP] Open Lampshade


Hi everyone,

Just thought you might like to know that Lampshade, our previously 
closed PHP framework, is now open-source:


http://www.thinkcomputer.com/corporate/news/pressreleases.html?id=24

Aaron

Aaron Greenspan
President & CEO
Think Computer Corporation

http://www.thinkcomputer.com

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



Re: [PHP] fckeditor and PDF and pesky users

On Tue, October 18, 2005 8:30 am, Jochem Maas wrote:
> 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 ;-)

Fire up Acrobat reader and change the preferences to only display
documents OUTSIDE the browser context.

Then you can nuke Acrobat and keep surfin'

I do it all the time.

-- 
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



Re: [PHP] Re: Inserting NULL Integer Values

Hi all,

Thanks for your replies, rather than check each vaule by name I am trying to 
produce a more dynamic solution:

foreach ($_POST as $key => $value) {
  if ($value == '') {
$_POST[$key] == 'NULL';
  }
}

I was expecting $_POST[$key] to be the same as $key, however this isnt the 
case:

$key = city
$_POST[$key] = London
$value = London

Any ideas?

""Richard Lynch"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Tue, October 18, 2005 12:42 pm, [EMAIL PROTECTED] wrote:
>> That should work.  You can set it so you can't have NULL, but dont
>> know of anything that tells the database not to accept '' as a value
>
> Any database, other than MySQL, is *NOT* going to accept '' as an
> integer value.
>
> Because '' is not an integer by any stretch of the imagination.
>
> If you don't care about ever porting your application to something
> other than MySQL, then you can IGNORE the advice to not use '' on
> integers.
>
> If there's ANY possibility that some day somebody might maybe wanna
> use a different database with your application, then don't confuse
> strings with integers.
>
> Actually, it might be better for your own
> education/sanity/comprehension/documentation/code to not confuse
> strings and integers with '' around integers in the SQL, but if
> everything ELSE is good in your code, and it's "always going to be
> MySQL" then it's fine.
>
> Note that:
>
> $value2 = 'NULL'; //PHP $value2 is a string
>
> $query = "insert into (integer_field) values ($value2)";
> //PHP $query is a string, but...
>
> The place-holder in $value2 will be just: NULL
>
> No quotes.
>
> No apostrophes.
>
> Not a string.
>
> NULL
>
> SQL NULL value representing "no value"
>
> -- 
> 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



Re: [PHP] Re: Inserting NULL Integer Values

Sorry everyone, I missed the "integer" requirement here.  I apologize.  And 
yes, '' isn't a good integer value and will throw an error.

That's what I get for not reading thoroughly enough :)

-TG

= = = Original message = = =

On Tue, October 18, 2005 12:42 pm, [EMAIL PROTECTED] wrote:
> That should work.  You can set it so you can't have NULL, but dont
> know of anything that tells the database not to accept '' as a value

Any database, other than MySQL, is *NOT* going to accept '' as an
integer value.

Because '' is not an integer by any stretch of the imagination.

If you don't care about ever porting your application to something
other than MySQL, then you can IGNORE the advice to not use '' on
integers.

If there's ANY possibility that some day somebody might maybe wanna
use a different database with your application, then don't confuse
strings with integers.

Actually, it might be better for your own
education/sanity/comprehension/documentation/code to not confuse
strings and integers with '' around integers in the SQL, but if
everything ELSE is good in your code, and it's "always going to be
MySQL" then it's fine.

Note that:

$value2 = 'NULL'; //PHP $value2 is a string

$query = "insert into (integer_field) values ($value2)";
//PHP $query is a string, but...

The place-holder in $value2 will be just: NULL

No quotes.

No apostrophes.

Not a string.

NULL

SQL NULL value representing "no value"


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



[PHP] White background with imagecreatetruecolor()

I'm diving into the gd functions for the first time, and I'm having a 
problem creating a white background for an image when using 
imagecreatetruecolor().  The manual says that this function will create 
a _black_ image, but looking at imagecolorallocate() it says that the 
first call to this function fills the background color, and they have 
examples like this...


$im = imagecreatetruecolor('example.jpg');
// sets background to red
$background = imagecolorallocate($im, 255, 0, 0);

So, thinking that I could make a this with a white background, I did this...

$im = imagecreatetruecolor ( 140, 140 );
$bg = imagecolorallocate ( $im, 255, 255, 255 );
$orgimg = imagecreatefromjpeg ( $image_data['image'] );

imagecopyresampled ( $im, $orgimg, $thumb_x_offset, $thumb_y_offset, 0, 
0, $new_thumb_x, $new_thumb_y, $image_data['image_x'], 
$image_data['image_y'] );


imagejpeg ( $im, $image_paths['thumbs'] . $file_name );

And that creates the image with the right sizes and positions, but the 
background is black.  Is there something wrong in my code, or is the 
manual wrong on the imagecolorallocate() function?  TIA.


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] Recommended Reading?

Zandstra's "PHP 5 objects patterns practice" has been getting  
excellent reviews. i also recommend it.


http://www.amazon.com/gp/product/1590593804/




On Oct 18, 2005, at 1:43 PM, Alan Lord wrote:



Hi all,

Forgive this long diatribe, a bit off-topic I know, but it might
stimulate a good discussion...

I have built a few small apps in PHP before and, whilst they work, I
can't but help feeling that I go about the whole thing the WRONG  
way...


I am not a professional software person (far from it) but I am
reasonably competent in most things "technical". I trained in
Electronics, build my own PCs and Linux systems from scratch, have  
used

- just for fun - Java, Delphi, Visual Basic, PHP and a little C/C++.

I am now wanting to write my own application (using PHP of course)  
to do
something "really useful". And I am looking for some  
recommendations on
reading [books or links] about "how to design" my application and  
how to

think about the design in it's abstract form before I start writing
code.

Normally I end up writing little bits of code to solve small problems
and then sort of kludging them together to do something useful.

I would really like to try and go about this one the RIGHT way.

Thanks in advance.

Al

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







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



Re: [PHP] White background with imagecreatetruecolor() [SOLVED]


John Nichel wrote:
I'm diving into the gd functions for the first time, and I'm having a 
problem creating a white background for an image when using 
imagecreatetruecolor().  The manual says that this function will create 
a _black_ image, but looking at imagecolorallocate() it says that the 
first call to this function fills the background color, and they have 
examples like this...


$im = imagecreatetruecolor('example.jpg');
// sets background to red
$background = imagecolorallocate($im, 255, 0, 0);

So, thinking that I could make a this with a white background, I did 
this...


$im = imagecreatetruecolor ( 140, 140 );
$bg = imagecolorallocate ( $im, 255, 255, 255 );
$orgimg = imagecreatefromjpeg ( $image_data['image'] );

imagecopyresampled ( $im, $orgimg, $thumb_x_offset, $thumb_y_offset, 0, 
0, $new_thumb_x, $new_thumb_y, $image_data['image_x'], 
$image_data['image_y'] );


imagejpeg ( $im, $image_paths['thumbs'] . $file_name );

And that creates the image with the right sizes and positions, but the 
background is black.  Is there something wrong in my code, or is the 
manual wrong on the imagecolorallocate() function?  TIA.




The manual is _my_ friendat least the comments in the manual are.  I 
had to use the imagefill() function...


$im = imagecreatetruecolor ( 140, 140 );
$bg = imagecolorallocate ( $im, 255, 255, 255 );
imagefill ( $im, 0, 0, $bg );

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] Re: Inserting NULL Integer Values


You're using two =='s for your assignment.

On Tue, 18 Oct 2005 15:15:59 -0400, "Shaun" <[EMAIL PROTECTED]>  
wrote:



Hi all,

Thanks for your replies, rather than check each vaule by name I am  
trying to

produce a more dynamic solution:

foreach ($_POST as $key => $value) {
  if ($value == '') {
$_POST[$key] == 'NULL';
  }
}

I was expecting $_POST[$key] to be the same as $key, however this isnt  
the

case:

$key = city
$_POST[$key] = London
$value = London

Any ideas?

""Richard Lynch"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

On Tue, October 18, 2005 12:42 pm, [EMAIL PROTECTED] wrote:

That should work.  You can set it so you can't have NULL, but dont
know of anything that tells the database not to accept '' as a value


Any database, other than MySQL, is *NOT* going to accept '' as an
integer value.

Because '' is not an integer by any stretch of the imagination.

If you don't care about ever porting your application to something
other than MySQL, then you can IGNORE the advice to not use '' on
integers.

If there's ANY possibility that some day somebody might maybe wanna
use a different database with your application, then don't confuse
strings with integers.

Actually, it might be better for your own
education/sanity/comprehension/documentation/code to not confuse
strings and integers with '' around integers in the SQL, but if
everything ELSE is good in your code, and it's "always going to be
MySQL" then it's fine.

Note that:

$value2 = 'NULL'; //PHP $value2 is a string

$query = "insert into (integer_field) values ($value2)";
//PHP $query is a string, but...

The place-holder in $value2 will be just: NULL

No quotes.

No apostrophes.

Not a string.

NULL

SQL NULL value representing "no value"

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




--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

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



[PHP] Re: Recommended Reading?

I liked Schlossnagle's 'Advanced PHP Programming'  
http://www.amazon.com/exec/obidos/tg/detail/-/0672325616/qid=1129664190/sr=8-1/ref=pd_bbs_1/002-6178615-3953615?v=glance&s=books&n=507846


It has a little primer on a variety of things but is for the php5 user.  
You might also want to read a book called Code Complete


http://www.amazon.com/exec/obidos/tg/detail/-/0735619670/qid=1129664509/sr=8-1/ref=pd_bbs_1/002-6178615-3953615?v=glance&s=books&n=507846

It's probably written more for the C/C++/Java crowd, but is meant to  
mostly be language neutral. It gives some great pointers on software  
construction. Some seems fairly obvious, but if you're self-taught (like I  
am) then you're sure to take a few things away from it.


Ben

On Tue, 18 Oct 2005 14:43:36 -0400, "Alan Lord" <[EMAIL PROTECTED]>  
wrote:



Hi all,

Forgive this long diatribe, a bit off-topic I know, but it might
stimulate a good discussion...

I have built a few small apps in PHP before and, whilst they work, I
can't but help feeling that I go about the whole thing the WRONG way...

I am not a professional software person (far from it) but I am
reasonably competent in most things "technical". I trained in
Electronics, build my own PCs and Linux systems from scratch, have used
- just for fun - Java, Delphi, Visual Basic, PHP and a little C/C++.

I am now wanting to write my own application (using PHP of course) to do
something "really useful". And I am looking for some recommendations on
reading [books or links] about "how to design" my application and how to
think about the design in it's abstract form before I start writing
code.

Normally I end up writing little bits of code to solve small problems
and then sort of kludging them together to do something useful.

I would really like to try and go about this one the RIGHT way.

Thanks in advance.

Al




--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

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



[PHP] LDAPS agaisnt Active Directory

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
 
Hello,

I am trying to authenticate against an Active Directory 2003 server
using LDAPS.  I have the cert from the server, however i'm not exactly
sure how to set it up so that php will recognize it.  I have read the
docs and googled a bit, but everyone seems to have a different way.
What is the best way to accomplish this?

- --
Aaron Axelsen
[EMAIL PROTECTED]

Great hosting, low prices.  Modevia Web Services LLC --
http://www.modevia.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
 
iD8DBQFDVWc2uucONIvD0AMRApAhAJ4uc7kriaMLXavTWHz6eFUYZjcLSgCfWQgo
wypmsI10a/J5goQi8cp1ZuU=
=fpYX
-END PGP SIGNATURE-

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



[PHP] has anyone a script for generating dates to a rule?

Hi

OK I am being lazy but unnecessarily reinventing the wheel is not my idea of 
fun. 

I need a script to populate database fields for year, month, day of month, day 
of week to a rule

e.g start year, month, day  end year month day
exclude [days of week] [from year, month, day to year, month, day] [specific 
dates]

If no one has one you can point me to  then contact me in a week or two and 
ask for mine 

thanks 
david



-- 
40 yrs navigating and computing in blue waters.
English Owner & Captain of British Registered 60' bluewater Ketch S/V Taurus.
 Currently in San Diego, CA. Sailing bound for Europe via Panama Canal after 
completing engineroom refit.

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



[PHP] PHP and files Upload

hello all.

I've managed to create files uploads pages in the past (dont remember if alredy 
with php 5).

till now, i havent need for testing or using.
today, i've tried to test an upload page (a very simple one) with php 5.0.5 and 
i was
unable to do it.

the script always says it was sucessful to upload the file, but the destination
directory was always empty... 
even when checking the $_FILES global

$_FILES['var_name']['tmp_name'] and
$_FILES['var_name']['name'] and
$_FILES['var_name']['size'], the vars alwyas return empty values...

is there any issue with php5 about files uploads ?

in php.ini i set the temp directory to /tmp and still nothing works...

Cheers,

Bruno Santos

--
Open WebMail Project (http://openwebmail.org)


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

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



[suspicious - maybe spam] [PHP] [suspicious - maybe spam] RE: [PHP] Recommended Reading?




I've never read a book to do PHP or anything else. I simply google and go to 
site after site reading tutorials and docs then making a sample page with 
what I've read and learned.


--Death Gauge
"How do you gauge your death?!"




Original Message Follows
From: "Alan Lord" <[EMAIL PROTECTED]>
To: 
Subject: [PHP] Recommended Reading?
Date: Tue, 18 Oct 2005 19:43:36 +0100

Hi all,

Forgive this long diatribe, a bit off-topic I know, but it might
stimulate a good discussion...

I have built a few small apps in PHP before and, whilst they work, I
can't but help feeling that I go about the whole thing the WRONG way...

I am not a professional software person (far from it) but I am
reasonably competent in most things "technical". I trained in
Electronics, build my own PCs and Linux systems from scratch, have used
- just for fun - Java, Delphi, Visual Basic, PHP and a little C/C++.

I am now wanting to write my own application (using PHP of course) to do
something "really useful". And I am looking for some recommendations on
reading [books or links] about "how to design" my application and how to
think about the design in it's abstract form before I start writing
code.

Normally I end up writing little bits of code to solve small problems
and then sort of kludging them together to do something useful.

I would really like to try and go about this one the RIGHT way.

Thanks in advance.

Al

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

_
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


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



[PHP] Re: Inserting NULL Integer Values

Shaun schrieb:
> $qid = mysql_query('INSERT INTO MYTABLE (
> column1,
> column2,
>) VALUES (
> "'.$value1.'",
> "'.$value2.'"
>)');

A bit off-topic but important: Always make sure that you check the
contents of $value1 and $value2 before putting them into the query!
With

$value1 = 'xyz","xyz"); DELETE FROM MYTABLE;';

you might get surprising results!

This is called SQL injection and it's important to escape all the values
before putting them into the statement.

An even better solution are prepared statements! With PDO (available as
an extension for PHP 5.x) these are natively supported. You prepare the
statements without any of the values and call them with the values. The
engine automatically escapes your data.

OLLi

Bug? That's not a bug, that's a feature.
[T. John Wendel]

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



Re: [PHP] Re: How can I count the usage of mail function in scripts?

Greg Donald schrieb:
> On 10/18/05, Oliver Grätz <[EMAIL PROTECTED]> wrote:
> 
>>Usually customers pay a fix fee for
>>some free traffic and then must pay for traffic exceeding those limits.
>>What they do with that traffic is none of your business.
> 
> 
> You've obviously never been a hosting provider.

Did I say that? I was talking about being a customer.

The type of content that might be forbidden in some countries is off
topic. The question deals with restricting the amount of mails a
customer may send in a certain amount of time. This is what I mean by
"none of his business".

I simply spoke of what the provider puts in the contract and on this
point the provider guarantees it's customers something like 50GB free
traffic with a fee of 49ct for each GB of traffic exceeding this limit.
Nothing about any restrictions on the amount of data of a certain type.

If the provider decides to limit the amount of mails per day to 100 the
why not limiting the amount of web pages served to 500? Or "not more
than 20 files per directory"? Or "may not serve GIF images"? Such
restrictions are simply ridiculous.

OLLi

All Glory to the Hypno-Toad!
[Futurama 307]

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



[PHP] Re: Recommended Reading?

>From a practical view:

*For big web projects:*
Make a plan! Do not start to write code before you exactly know what you
want to do. An important concept in the development of large web
applications is the MVC princinple (Model View Controller) which
basically urges you to seperate the data and the display. Get an insight
into MVC, it will help you in designing your application and it will
come in handy if you decide to implement more ways of displaying your
data than you thought of in the first place.

*For a certain problem:*
Do not reinvent the wheel! PHP is a language with a really large
function library. The amount of extensions that are directly available
is so high that chances are good you'll find a solution right there as a
function ready to use. So: Dig through the documentation at php.net!
Learn what extensions there are. Use the comments in the documentation,
they provide valuable examples.
If you can't solve your problem with the internal functions: Search the
web! The PEAR repository offers a lot of packages solving a lot of
problems BUT they are not always the best solution. Projects like AdoDB,
Propel etc. show that there are often more solutions than you wanted. So
do not compromise too much: If a solution does not exactly fit your
needs, continue the search.

*For the next project:*
DRY (Don't repeat yourself)! Code you've written once can come in handy
for the next project. So start to seperate the code you write into
application specific code and library code. You can reuse your library
for all of your projects.

*For any large development:*
It's a good idea to use a versioning system. Subversion is free and
ready to install on any Apache server. With PHP it's also an ideal
solution for deployment: Just make a release tag and check it out on
your production server. Add some config and off you go!

Happy Development!

OLLi

"You see, Mr. President: The worlds hates America. And for good reason.
(I wont bother going into details)"
[24 319]

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



[PHP] Java editor

Is there a OS java (or other) html editor I can implement on a Web page. 
I want a user to type text, use bold, italics, etc.
I would then store the html in a MySQl record and then use php to insert 
the edited text.

I've seen some packaged, in Moodle for example.
John

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



Re: [PHP] Java editor

On Tue, 2005-10-18 at 23:52, John Taylor-Johnston wrote:
> Is there a OS java (or other) html editor I can implement on a Web page. 
> I want a user to type text, use bold, italics, etc.
> I would then store the html in a MySQl record and then use php to insert 
> the edited text.
> I've seen some packaged, in Moodle for example.

Here's a couple of popular ones.

http://tinymce.moxiecode.com/example_full.php?example=true
http://www.fckeditor.net/demo/default.html

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] fckeditor and PDF and pesky users

Jochem Maas wrote:

> 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 ;-)

I agree, those moments are annoying. That's why one needs to make sure
that the user expects, and is aware, that a PDF is going to open down
there in that little . I do not see any motivated use for a PDF
in this fashion on a normal site, but, in a document versioning system
or a CMS, sure, that would be awesome. Otherwise I side with Jochem.

This is not an approach that should be used in any normal web page, it
should be utilized with care, where it is needed, and the user has to be
made aware that when clicking on a specific link, a PDF will be loading.
Otherwise, some poor webmaster's going to have to answer to Jochem, and
they don't want that. ;)

Regards,
Torgny

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