Re: [PHP] elseif statements

2009-05-05 Thread Jim Lucas

Well, since nobody seems to want to answer your question, I will...  :)

It has to do with you using an assignment '=' instead of a comparison '==' 
operator in your condition.

Follow along with my inline notes below.

Gary wrote:
I am trying to get this to work, however it only reads the second if 
statement.  I get no error messages, but as I change counties, the % stays 
the same.


Can someone enlighten me, or should I be looking at switch statements?

Thanks for your help.

Gary



/*$correct_assess=($sale_value)*($ratio); this is now the assessment should 
be */

$chester_correct_assess=($sale_value)*($chester_ratio);
$montco_correct_assess=($sale_value)*($montco_ratio);
$delco_correct_assess=($sale_value)*($delco_ratio);


$chester_assess_difference=($assess_value)-($chester_correct_assess);
$montco_assess_difference=($assess_value)-($montco_correct_assess);
$delco_assess_difference=($assess_value)-($delco_correct_assess);

/*  $assess_difference=($assess_value)-($sale_value * $ratio);
$percent_difference=($assess_difference)/($assess_value);*/
$chester_percent_difference=($chester_assess_difference)/($assess_value);
$delco_percent_difference=($delco_assess_difference)/($assess_value);
$montco_percent_difference=($montco_assess_difference)/($assess_value);

$chester_percent_savings=($chester_percent_difference)*100;
$delco_percent_savings=($delco_percent_difference)*100;
$montco_percent_savings=($montco_percent_difference)*100;

if(($_COOKIE['county_cookie'] ='Chester') && ($chester_assess_difference 
 >=5))




The previous line should be, notice the missing == comparison ???
if(($_COOKIE['county_cookie'] == 'Chester') && ($chester_assess_difference  >= 
5))



{
echo 'Yes, Your property appears to 
qualify!';
echo "You 1 believe your home would today sell for  
$".number_format($sale_value)." ";
echo "Your current tax assessment is 
$".number_format($assess_value)."";

echo "You live in $county ";
echo "Your potential savings could be " 
.number_format($chester_percent_savings,0)."%";
echo "According to preliminary calculations based on the information you 
have entered, you may enjoy a savings of   
".number_format($chester_percent_savings,0)."% off a combined total of 
county, school and township real estate taxes. Actual dollar amount savings 
will differ depending on the township that the property is located.  Please 
contact my office for a more precise estimate of savings.";


}
elseif(($_COOKIE['county_cookie']='Delaware') && ($delco_assess_difference 
 >=3)) {


Same thing here




echo 'Yes, Your property appears to 
qualify!';
echo "You 2 believe your home would today sell for  
$".number_format($sale_value)." ";
echo "Your current tax assessment is 
$".number_format($assess_value)."";

echo "You live in $county ";
echo "Your potential savings could be " 
.number_format($delco_percent_savings,0)."%";
echo "According to preliminary calculations based on the information you 
have entered, you may enjoy a savings of   
".number_format($delco_percent_savings,0)."% off a combined total of 
county, school and township real estate taxes. Actual dollar amount savings 
will differ depending on the township that the property is located.  Please 
contact my office for a more precise estimate of savings.";

}
elseif(($_COOKIE['county_cookie']='Montgomery') && 
($montco_assess_difference >=5))




Same thing here



{
echo 'Yes, Your property appears to 
qualify!';
echo "You 3 believe your home would today sell for  
$".number_format($sale_value)." ";
echo "Your current tax assessment is 
$".number_format($assess_value)."";

echo "You live in $county ";
echo "Your potential savings could be " 
.number_format($montco_percent_savings,0)."%";
echo "According to preliminary calculations based on the information you 
have entered, you may enjoy a savings of   
".number_format($montco_percent_savings,0)."% off a combined total of 
county, school and township real estate taxes. Actual dollar amount savings 
will differ depending on the township that the property is located.  Please 
contact my office for a more precise estimate of savings.";

}

else if(($chester_assess_difference <=5) && 
($chester_assess_difference>=1000)) {
echo 'While it appears you may enjoy some savings, the 
dollar amount may not reach the threshold required for action. If property 
values in your area continue to decline, you may wish to revisit this issue 
again next year.';

}
else if(($delco_assess_difference <=3) && 
($delco_assess_difference>=1000)) {
echo 'While it appears you may enjoy some savings, the 
dollar amount may not reach the threshold required for action. If property 
values in your area continue to decline, you may wish to revisit this issue 
again next year.';

}
else if(($montco_assess_difference <=5) && 
($montco_assess_difference>=1000)) {
echo 'While it appears you may enjoy some savings, the 
dollar amount may not reach the threshold required for action. If property 
values in y

Re: [PHP] SimpleXML output encoding

2009-05-05 Thread Ondrej Kulaty
Because i am working on an old system which is in ISO, i cant use unicode.

--
Ondrej Kulaty

"tedd"  píse v diskusním príspevku 
news:p06240802c625f6b4e...@[192.168.1.101]...
> At 2:40 PM +0200 5/5/09, Ondrej Kulaty wrote:
>>Hi,
>>is there any way how to set output encoding for SimpleXML?
>>It will load XML document in any encoding, but internally, it converts the
>>document to UTF-8 and outputs it in this encoding.
>>I would like to have output encoding set to ISO-8859-2, is it possible?
>>thanks.
>>
>>--
>>Ondrej Kulaty
>
> Why?
>
> 
>
> tedd
>
> -- 
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com 



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



Re: [PHP]Muticast Support in PHP

2009-05-05 Thread Shameem Muhammed

Hi,

I woud like to know ,whether PHP can Support muticast messages.I wand 
sent and receive muticast messages using PHP.



--
Thanks & Regards

Muhammed Shameem PV
Product Devpt & Support
Kalki Communication Technologies Ltd
Bangalore
India   


"Disclaimer: This message is being sent from Kalki Communication Technologies 
Ltd (KALKITECH). and may contain information which is confidential or
privileged. If you are not the intended recipient, please advise the sender 
immediately by reply e-mail and delete this message and any attachments
without retaining a copy. Any unauthorized use of the content of this message 
can expose the responsible party to civil and/or criminal penalties,
and may constitute a more serious offense. Further the company does not accept 
liability for any errors, omissions, viruses or computer problems
experienced as a result of this transmission. If you have received this message 
in error, notice is hereby given that no representation, contract or
other binding obligation shall be created by this e-mail."

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



Re: [PHP] Re: Generating dynamic PDFs

2009-05-05 Thread Phpster

There are way too many php based options to even waste time with this.

Bastien

Sent from my iPod

On May 5, 2009, at 17:54, "O. Lavell"  wrote:


Kevin Kaiser wrote:

[..]


All you have to do is sign up for an API key, upload your document
templates and POST data to our server. We handle everything else. A
stream of PDF data is passed back to your application and you can  
save

it as a file, prompt the user to download it right then and there or
push it into a database.


So what else do you do with the documents that get posted to your  
server,

and why should anyone trust you?

--
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] speaking of control structures...

2009-05-05 Thread Clancy
On Tue, 05 May 2009 14:13:23 -0400, rob...@interjinn.com (Robert Cummings) 
wrote:

>On Tue, 2009-05-05 at 13:56 -0400, Tom Worster wrote:
>> there's a control structure i wish php had: a simple block that you can 
>> ...

>But PHP 5.3 introduces goto:
>
>
>header:
>
>if( $something ) ...
>
>goto body;
>
>body:
>
>if( $soemthingElse ) ...
>goto footer;
>
>if( $seomthingerElse ) ...
>
>goto footer;
>
>footer:
>
>// blah blah blah
>goto done;
>
>done;

I heartily agree. In my opinion 'break' is like a 'goto' without a label. As I 
used to
tell my students "if I say 'break' the one thing I can be sure of is that you 
will all
disappear. I had no idea where most of you go, or what you do, and I'm not even 
sure if
I'll ever see some of you again."

'Goto' makes it possible to set up the more complex control sequences you 
sometimes need,
yet have them clearly defined. For example:



I find it very difficult to set up sequences like this using if/else if (or 
switches, but
I don't like them anyway), and have to resort to setting flags and very careful
indentation to make sure that I'm doing what I intended. Unfortunately my 
provider is
still using PHP 4.something, and I have been too busy to switch to someone more
up-to-date.


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



[PHP] Re: Newbie - Setting Up Some Basic Sendmail Scripts

2009-05-05 Thread Manuel Lemos
Hello,

on 05/05/2009 02:20 PM revDAVE said the following:
> I'm trying to set up some basic php send mail scripts - and I'm curious of
> the best way to go...
> 
> 
> I checked these basics out:
> 
> http://us.php.net/manual/en/function.mail.php
> 
> And got this code below going, but I'll bet I need a bit more - like adding
> authentication - smtp - port - sending user / pass etc.
> 
> Any hints how to get this to the next level?

It seems the SMTP server is only requiring authentication because it is
in a different machine of what you run PHP. In that case, you may want
to read this article:

http://www.phpclasses.org/blog/package/9/post/1-Sending-email-using-SMTP-servers-of-Gmail-Hotmail-or-Yahoo-with-PHP.html

-- 

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

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

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



[PHP] Need Help! - Looking over a wireframe doc...

2009-05-05 Thread bruce
Hi..

I'm playing around with creating an app to allow users to
add/checkin/checkout docs from a web based app. The backend will tie into
SVN as a repository.

The app is intended to be a php/mysql/linux app.

I'm trying to find a few people that I might get to take a look at the
current doc(s) I have and give me some comments/feedback...

The goal of the app is to allow a user to register, and then select the
given doc he wants to work on, as well as the given workflow phase. This
allows the app to kind of restrict the access rights a user has to the doc,
based on where in the workflow the doc is..

Get to me offline if you're interested in taking a look.

thanks

-bruce


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



Re: [PHP] how to enable ttf support in php 5.2.9

2009-05-05 Thread Michael A. Peters

Ashley Sheridan wrote:




content coming from MS Office clipboard pastes generally contain
characters that are encoded wrong, and do not display correctly in web
pages unless they have very relaxed doctypes. The function I generally
use is:

function removeMSCrap($crap)
{
$find = Array(chr(128), chr(133), chr(8226), chr(145), chr(8217),
chr(146), chr(8220), chr(147), chr(8221), chr(148), chr(8226), chr(149),
chr(8211), chr(150), chr(8212), chr(151), chr(8282), chr(153), chr(169),
chr(174));
$replace = Array("€", "…", "″", "'", "'",
"'", "'", """, """, """, """, "•",
"•", "–", "–", "—", "—", "™", "™",
"©", "®");

$roses = str_replace($find, $replace, $crap);
return $roses;
}


Is that something you would suggest be used in any web app that has a 
textarea for input?


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



RE: [PHP] Avoid to open mysql querries then times in the page

2009-05-05 Thread Daevid Vincent
 

> -Original Message-
> From: tedd [mailto:tedd.sperl...@gmail.com] 
> Sent: Tuesday, May 05, 2009 7:55 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] Avoid to open mysql querries then times in the page
> 
> On 5/4/09, Matthieu  wrote:
> >  Hello,
> >
> >  I'm a totally newbie to php/Mysql but I'd like to know if 
> it is normal that
> >  I have to connect 3 times to the db in one page.
> >
> >  For example, I have
> >
> >  1. A connection for the login / pass a $_SESSION['login'] 
> before the HTML
> >  tags
> >
> >  2. I need to say hello to the user so I reconnect, run a 
> query to select the
> >  user having the login and echo 'Hello '.$user['login'].'!''
> >
> >  3. I need to show him his friends a bit later, so I have 
> to connect a last
> >  time and re-run a querry because I can't use the data 
> $user that I used in
> >  my upper php code...
> >
> >
> >  Is there a walkthroug to have only one connection for the page?
> >
> >  Thanks
> >
> >  Matthieu
> 
> 
> Matthieu:
> 
> The way I usually have a user navigate a protected site is to first 
> to have them identify themselves via a logon/password script -- and 
> then I store their user_id in a SESSION. Note, I do not store all 
> their data in a SESSION, just their user_id. The user_id should be an 
> unique auto_increment integer primary key from your users' table.
> 
> At the start of each protected page, I have:
> 
>  
> $user_id = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : 0;
> 
> if($user_id == 0)
> {
> header('location: login.php);
> exit();
> }
> 
> // proceed with processing
> 
> As such, I check if $user_id > 0 -- if so, then I process the request 
> as directed. If not, then I send the user back to login.
> 
> As for connecting to the database, I connect as needed to get 
> information needed. I do not use SESSIONs to store all the data to be 
> passed from page to page, I gather only what's needed for that page.
> 
> I also make sure that when I open a connection, I close the 
> connection I may have several open/close statements within a page, 
> but normally I try to avoid that.
> 
> HTH's
> 
> tedd

I would disagree with this. I strongly believe you should use a
User.class.php and store that instance in the $_SESSION. This gives you the
ID, name, login name, login state, roles, and every other thing you could
want to know about a user on a given page in a handy to access object. In
fact, a User class is one of those things that really benefits from being
OOP.

The only trick here Matthieu is to make sure you
require_once('User.class.php') BEFORE you session_start(); or it won't work.

Opening and closing the connections is also IMHO a bad idea. The connection
is one of the slowest parts. In mySQL it's not so bad, but it's very narrow
sighted to think in terms of only one RDBMS. Other RDBMS like Oracle for
example have a very slow connection. Why not just keep it around. Your page
only lasts a few seconds and will automatically close when completed
anyways.

If you're writing a command line tool like a daemon, then that's another
story, but I doubt the OP is doing that.

Lastly, why all the extra variable, assignment and checking stuff here?

$user_id = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : 0;

Why not just this?

if( intval($_SESSION['user_id']) < 1 ) { ... }

What I normally do is set a $_SESSION['login'] = true; 

A boolean is always faster to check and in your code you could do this:

if ( !$_SESSION['login'] ) { ... }

or if you're really paranoid use the '===':

if ( $_SESSION['login'] !== true ) { ... }


D.Vin
http://daevid.com





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



Re: [PHP] How to deal with identical fields in db

2009-05-05 Thread PJ
Tom Worster wrote:
> On 5/5/09 4:42 PM, "Richard S. Crawford"  wrote:
>
>   
>> On Tue, May 5, 2009 at 1:34 PM, PJ  wrote:
>> 
>>> I'm coming up with a bit of a quandry: how to enter and retrieve an
>>> identical book title with different authors.
>>> It is rather unbelievable what contortions one finds as authors :-(
>>> like editors, associations and then the unknowns and anon y mouses.
>>> I suppose one has to get really creative...
>>>   
>
> don't forget to consider the handling of anthologies :-)
>   
Well, that usually comes under editors and I have a couple of options
where to enter that info: sub_title or description fields and I can
always add a   for author first_name and Various or whatever for
last_name :-)
>
>   
>>> Anyone for tea?
>>>   
>
> yes please, i'd love some.
>
>
>   
>> What I've done for this sort of project in the past was create
>> separate tables for authors, books, and author relationships (e.g.,
>> author, translator, editor), then linking tables for each of those.
>> You seriously want to do some normalization on this task; otherwise,
>> you end up with a giant table of books, with multiple rows duplicating
>> the title of the book, leading to a huge "books" table, and nobody
>> wants that.
>> 
>
> i have a db with 10s of millions of artists, disks, songs etc. i've tried it
> both ways. and after 5 years working with it i still can't make up my mind
> which way i prefer it. i keep finding pros and cons to each approach that
> differ depending on what functionality i'm programming. i will never have a
> simple answer.
>
> so i can't help answer the original question other than to say that, for me,
> personally, in my opinion, i don't accept the dogma that normal forms are
> always good for you. they might be. it depends. it's like being dogmatic
> about specific foods without taking the overall diet and lifestyle into
> account. despite the simple dogma some may espouse, whether or not a big mac
> with fries is bad for you depends on many factors.
>
> in any case, it's amazing what you can do these days with one huge table and
> some well chosen indexes. and it's amazing how mind bending it can get when
> joining 5 data tables using 3 join tables.
>   
ain't that the truth !
> good luck, phil.
>   
Thank you guys, for the input. Never thought so many would help so
few(little me). ;-)
I'm really just a little shorter than BG at 6'5" :-D
Actually, I started out and still am with the db normalized. It all
works quite well, it's just frustrating to have to go through all the
contortions to check things. I started out with just checking the title,
then had to add a check to the sub_title, (already have a check for
author) but now have to add another to go with the specific book... oh,
well... all a part of the learning process. :-)

-- 
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


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



RE: [PHP] Avoid to open mysql querries then times in the page

2009-05-05 Thread Daevid Vincent
 

> -Original Message-
> From: tedd [mailto:tedd.sperl...@gmail.com] 
> Sent: Tuesday, May 05, 2009 7:55 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] Avoid to open mysql querries then times in the page
> 
> On 5/4/09, Matthieu  wrote:
> >  Hello,
> >
> >  I'm a totally newbie to php/Mysql but I'd like to know if 
> it is normal that
> >  I have to connect 3 times to the db in one page.
> >
> >  For example, I have
> >
> >  1. A connection for the login / pass a $_SESSION['login'] 
> before the HTML
> >  tags
> >
> >  2. I need to say hello to the user so I reconnect, run a 
> query to select the
> >  user having the login and echo 'Hello '.$user['login'].'!''
> >
> >  3. I need to show him his friends a bit later, so I have 
> to connect a last
> >  time and re-run a querry because I can't use the data 
> $user that I used in
> >  my upper php code...
> >
> >
> >  Is there a walkthroug to have only one connection for the page?
> >
> >  Thanks
> >
> >  Matthieu

I usually include a db.inc.php file that opens up a connection in the header
of the page and I continue to use the connection throughout till the end.

A basic example is do something like this:

//this will hold each db connection so we'll only create one at a time. like
a singleton.
$GLOBALS['DB_CONNECTIONS'] = array(); 

function connect_to_db_reliability() 
{
if ($GLOBALS['DB_CONNECTIONS']['reliability']) 
return $GLOBALS['DB_CONNECTIONS']['reliability'];

global $global_db_dsn_reliability;

$options = array(
'debug'   => 0,
'persistent'  => FALSE,
'portability' => DB_PORTABILITY_ALL
);

$db_connection =& DB::connect($global_db_dsn_reliability, $options);
if ( PEAR::isError( $db_connection ) )
die( $db_connection->getMessage() );

$GLOBALS['DB_CONNECTIONS']['reliability'] = $db_connection;

$GLOBALS['DB_CONNECTIONS']['reliability']->setFetchMode(DB_FETCHMODE_ASSOC);

return $GLOBALS['DB_CONNECTIONS']['reliability'];
}

Then in all your code you can either do a simple call at the top of your
page:

$db_connection = connect_to_db_reliability();

and later on, you don't have to worry about it because you have already made
a connection.

$db_result =& $db_connection->getAll($sql);

Be aware of scope and such, for example if you're inside a function or
method. But that's easy enough to handle since calling $db_connection =
connect_to_db_reliability(); will return you the same connection anyways, so
it's free to use wherever you are unsure.

This method is a fairly simple "singleton" like methodology that handles
multiple database connections (here at my job, we have NINE databases we
connect to at any given time.

In my other jobs/projects where I only have a single database (which is the
norm), I do this same sort of logic just not in a multi-dimensional array
and I have more wrapper functions that handle the connection if it doesn't
exist and do all sorts of useful things like colorized debug output,
backtraces. Search the PHP list archives for my posts and SQL_QUERY,
SQL_CONNECT, etc in a "db.inc.php" file I shared...

http://daevid.com


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



[PHP] Re: Generating dynamic PDFs

2009-05-05 Thread O. Lavell
Kevin Kaiser wrote:

[..]

> All you have to do is sign up for an API key, upload your document
> templates and POST data to our server. We handle everything else. A
> stream of PDF data is passed back to your application and you can save
> it as a file, prompt the user to download it right then and there or
> push it into a database.

So what else do you do with the documents that get posted to your server, 
and why should anyone trust you?

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



Re: [PHP] How to deal with identical fields in db

2009-05-05 Thread Tom Worster
On 5/5/09 4:42 PM, "Richard S. Crawford"  wrote:

> On Tue, May 5, 2009 at 1:34 PM, PJ  wrote:
>> I'm coming up with a bit of a quandry: how to enter and retrieve an
>> identical book title with different authors.
>> It is rather unbelievable what contortions one finds as authors :-(
>> like editors, associations and then the unknowns and anon y mouses.
>> I suppose one has to get really creative...

don't forget to consider the handling of anthologies :-)


>> Anyone for tea?

yes please, i'd love some.


> What I've done for this sort of project in the past was create
> separate tables for authors, books, and author relationships (e.g.,
> author, translator, editor), then linking tables for each of those.
> You seriously want to do some normalization on this task; otherwise,
> you end up with a giant table of books, with multiple rows duplicating
> the title of the book, leading to a huge "books" table, and nobody
> wants that.

i have a db with 10s of millions of artists, disks, songs etc. i've tried it
both ways. and after 5 years working with it i still can't make up my mind
which way i prefer it. i keep finding pros and cons to each approach that
differ depending on what functionality i'm programming. i will never have a
simple answer.

so i can't help answer the original question other than to say that, for me,
personally, in my opinion, i don't accept the dogma that normal forms are
always good for you. they might be. it depends. it's like being dogmatic
about specific foods without taking the overall diet and lifestyle into
account. despite the simple dogma some may espouse, whether or not a big mac
with fries is bad for you depends on many factors.

in any case, it's amazing what you can do these days with one huge table and
some well chosen indexes. and it's amazing how mind bending it can get when
joining 5 data tables using 3 join tables.

good luck, phil.



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



Re: [PHP] How to deal with identical fields in db

2009-05-05 Thread tedd

At 4:34 PM -0400 5/5/09, PJ wrote:

I'm coming up with a bit of a quandry: how to enter and retrieve an
identical book title with different authors.
It is rather unbelievable what contortions one finds as authors :-(
like editors, associations and then the unknowns and anon y mouses.
I suppose one has to get really creative...
Anyone for tea?


You need to normalize.

Authors should have an unique id in an authors table. The authors 
table has all the specific information about authors, but not the 
books they have written.


Books should have an unique id in a books table. The books table has 
all the specific information about books, but not the contributing 
authors.


Then you connect the two tables with a Book-Author table that has 
only the id's of both -- no real need for any other information.


That way when you want to see all the books an author has written, 
then you pull out all the records that has the author's id and look 
up each book via the book id.


Likewise, when you want to see all the authors who have contributed 
to a book, then you pull out all records that has the book's id and 
look up each author via their author id.


Do you see how it works?

Cheers,

tedd

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

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



Re: [PHP] how to enable ttf support in php 5.2.9

2009-05-05 Thread tedd

At 9:17 PM +0100 5/5/09, Ashley Sheridan wrote:


It's mainly for the benefit of other people, who do use MS programs and
copy and paste things into your web apps and then wonder why things
don't work exactly how they expect


Ash
www.ashleysheridan.co.uk



Ash:

Ain't that the truth.

I have one client who no matter how many times I talk to him about 
gremlins and how he should make sure his entries are plain text, he 
still cuts and paste things directly from M$ Word and then wonders 
"Where did those come from? They weren't there when I added that 
text. What did you do?"


Oh well, we all stand somewhere between the stupid and smart marks on 
the scale of intelligence.


Cheers,

tedd

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

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



Re: [PHP] How to deal with identical fields in db

2009-05-05 Thread Stephen

PJ wrote:

I'm coming up with a bit of a quandry: how to enter and retrieve an
identical book title with different authors.
It is rather unbelievable what contortions one finds as authors :-(
like editors, associations and then the unknowns and anon y mouses.
I suppose one has to get really creative...
Anyone for tea?
  
You should have a title_id field in your titles table, and this field 
should be unique. Probably auto assigned and auto increment.


If you search for a book title, and there are two books with that title, 
you should get two records back!


Stephen

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



Re: [PHP] How to deal with identical fields in db

2009-05-05 Thread Richard S. Crawford
On Tue, May 5, 2009 at 1:34 PM, PJ  wrote:
> I'm coming up with a bit of a quandry: how to enter and retrieve an
> identical book title with different authors.
> It is rather unbelievable what contortions one finds as authors :-(
> like editors, associations and then the unknowns and anon y mouses.
> I suppose one has to get really creative...
> Anyone for tea?

What I've done for this sort of project in the past was create
separate tables for authors, books, and author relationships (e.g.,
author, translator, editor), then linking tables for each of those.
You seriously want to do some normalization on this task; otherwise,
you end up with a giant table of books, with multiple rows duplicating
the title of the book, leading to a huge "books" table, and nobody
wants that.

-- 
Richard S. Crawford (rscrawf...@mossroot.com)
http://www.mossroot.com
Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)

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



[PHP] How to deal with identical fields in db

2009-05-05 Thread PJ
I'm coming up with a bit of a quandry: how to enter and retrieve an
identical book title with different authors.
It is rather unbelievable what contortions one finds as authors :-(
like editors, associations and then the unknowns and anon y mouses.
I suppose one has to get really creative...
Anyone for tea?

-- 
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


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



Re: [PHP] how to enable ttf support in php 5.2.9

2009-05-05 Thread Ashley Sheridan
On Tue, 2009-05-05 at 09:57 -0400, PJ wrote:
> Ashley Sheridan wrote:
> > On Mon, 2009-05-04 at 18:42 -0400, PJ wrote:
> >   
> >> Jim Lucas wrote:
> >> 
> >>> PJ wrote:
> >>>   
>  Is there a module to be activated or what has to be installed to have
>  ttf support in php?
>  My port on FreeBSD does not have an option for ttf support under make
>  config .
>  I'm trying to learn & understand the following:
>  In file1 : 
>  In file2 (button.php)- originally php3 :
>      Header("Content-type: image/gif");
>    if(!isset($s)) $s=11;
>  
> >>> The above should be:
> >>>
> >>> if ( empty($_GET['s']) ) {
> >>> $s = 11;
> >>> } else {
> >>> $s = (int)$_GET['s'];
> >>> }
> >>>
> >>>   
>    $size = imagettfbbox($s,0,"times.ttf",$text);
>  
> >>> and this should be
> >>>
> >>> $text = '';
> >>> if ( !empty($_GET['text']) )
> >>> $text = your_custom_input_cleaner_function($_GET['text']);
> >>>
> >>> $size = imagettfbbox($s,0,"times.ttf",$text);
> >>>
> >>>   
>    $dx = abs($size[2]-$size[0]);
>    $dy = abs($size[5]-$size[3]);
>    $xpad=9;
>    $ypad=9;
>    $im = imagecreate($dx+$xpad,$dy+$ypad);
>    $blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF);
>    $black = ImageColorAllocate($im, 0,0,0);
>    $white = ImageColorAllocate($im, 255,255,255);
>    ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black);
>    ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white);
>    ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black,
>  "times.ttf", $text);
>    ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white,
>  "times.ttf", $text);
>    ImageGif($im);
>    ImageDestroy($im);
>  ?>
>  ONLY the above & nothing else. So far, all I get is a small blue square.
>  Replacing the $text with the text just gives a rectangle a bit wider.
>  gd is installed but ttf is not, so I figure that is the culprit.
>  But how is the text supposed to be assigned to $text from file1?
>  TIA
>  
> >> Thank you for that. Now it works. I see, the $s had to come from
> >> somewhere...
> >> But what's the custom_cleaner_function - I mean, to clean what? & Why?
> >> What if I use some foreign accents, like é or  À ?
> >>
> >> -- 
> >> Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
> >> -
> >> Phil Jourdan --- p...@ptahhotep.com
> >>http://www.ptahhotep.com
> >>http://www.chiccantine.com/andypantry.php
> >>
> >>
> >> 
> > content coming from MS Office clipboard pastes generally contain
> > characters that are encoded wrong, and do not display correctly in web
> > pages unless they have very relaxed doctypes. The function I generally
> > use is:
> >
> > function removeMSCrap($crap)
> > {
> > $find = Array(chr(128), chr(133), chr(8226), chr(145), chr(8217),
> > chr(146), chr(8220), chr(147), chr(8221), chr(148), chr(8226), chr(149),
> > chr(8211), chr(150), chr(8212), chr(151), chr(8282), chr(153), chr(169),
> > chr(174));
> > $replace = Array("€", "…", "″", "'", "'",
> > "'", "'", """, """, """, """, "•",
> > "•", "–", "–", "—", "—", "™", "™",
> > "©", "®");
> > 
> > $roses = str_replace($find, $replace, $crap);
> > return $roses;
> > }
> >
> >
> > Ash
> > www.ashleysheridan.co.uk
> >
> >
> >   
> Uh. Ok. That's cool. Somehow I have managed to never use MS Office for
> anything else than web applications. Generally I open .doc with
> OpenOffice. But, who know's? Thanks, anyway. :-)
> 
> -- 
> Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
> -
> Phil Jourdan --- p...@ptahhotep.com
>http://www.ptahhotep.com
>http://www.chiccantine.com/andypantry.php
> 
> 
It's mainly for the benefit of other people, who do use MS programs and
copy and paste things into your web apps and then wonder why things
don't work exactly how they expect


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] elseif statements

2009-05-05 Thread tedd

At 1:11 PM -0400 5/5/09, Paul M Foster wrote:

I hate to dogpile on Tedd, ...


No problem.

Some days you're the windshield and some days you're the bug.

Hey, I've been wrong before -- I'm used to it.

But in my defense, I've always had major problems understanding long ifelse's.

You see, I'm dyslexic and I can not follow those long constructs 
(i.e., more than two decisions). I've always been able to work around 
the problem.


Sure the way php allows switch(true) is very opportunistic for me, 
but it's legal. I've seen a lot worse, not that my practicing such 
grants me permission to do so. But I don't seriously think that 
anyone who reviews my code would be confused as to what I was doing 
using a switch in such fashion.


Cheers,

tedd

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

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



Re: [PHP] Problems with HTTPS and maybe an .htaccess???

2009-05-05 Thread Alex S Kurilo aka Kamazee
No, adding * after the period had no affect at all. Still goes to the  
live site.


Sorry, I misunderstood you. I'm too lazy to read all the message :)

http and https may be handled by different virtual hosts.
http for http://dev.sitename.com/ seems to be configured properly (Virtual host 
at port 80) but not https://dev.sitename.com/ (vhost at port 443).


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



Re: [PHP] elseif statements

2009-05-05 Thread tedd

At 12:48 PM -0400 5/5/09, Robert Cummings wrote:

I'm not looking for gratification... merely hoping to ensure that
readers of your niche style understand that it is niche, and that it is
not really the best option of all available options. You are welcome to
disagree, your opinion is your own, but as you have argued, we are all
entitled to our opinion. Those opinions with the greatest merit should
have the better supporting arguments (one would hope anyways :)

Cheers,
Rob.


Rob:

Gratification or not -- the point holds true.

On this, you make a better argument than I. While I can't follow, I do concede.

Cheers,

tedd

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

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



Re: [PHP] Problems with HTTPS and maybe an .htaccess???

2009-05-05 Thread Skip Evans

Hey all,

No, adding * after the period had no affect at all. Still goes 
to the live site.


Any other ideas? I'm stumped, desperate and on the verge of 
requiring medication.


Skip

Alex S Kurilo aka Kamazee wrote:

RewriteRule . index.php


Add an asterisk after the dot:
RewriteRule .* index.php





--

Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com

Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut

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



[PHP] Re: speaking of control structures...

2009-05-05 Thread Shawn McKenzie
Tom Worster wrote:
> there's a control structure i wish php had: a simple block that you can
> break out of, e.g.
> 
> block {
> 
>   if ( condition )
> break;
> 
>   blah...
>   blah...
> 
>   if ( another condition )
> break;
> 
>   blah...
>   blah...
> 
>   etc...
> 
> }
> 
> the block is just like a loop except that it is executed once only.
> 
> this would be a handy structure for writing input validation code. the blah
> blah fragments can be used for opening files, talking to the db,
> manipulating strings, processing dates and times, etc., the conditions for
> testing if the input is unacceptable.
> 
> i'm sure many of the programmers here do this kind of thing routinely and
> have their own habits and solutions. i'd be curious what they are. please
> let us know!
> 
> 
> i guess i ought to go first. it's fugly but it works:
> 
> $once = true;
> while ( $once ) {
>   $once = false;
> 
>   stuff using break where needed ...
> 
> }
> 
> tom
> 
> 

>From the PHP manual:

do {
if ($i < 5) {
echo "i is not big enough";
break;
}
$i *= $factor;
if ($i < $minimum_limit) {
break;
}
   echo "i is ok";

/* process i */

} while (0);

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Newbie - Setting Up Some Basic Sendmail Scripts

2009-05-05 Thread Sudheer Satyanarayana



And got this code below going, but I'll bet I need a bit more - like adding
authentication - smtp - port - sending user / pass etc.

Any hints how to get this to the next level?

  

Hi Dave,

As others have said, it is convenient to use a library/framework to send 
mails from your PHP script via SMTP with authentication.


You might also want to check out Zend_Mail component of Zend Framework.

http://framework.zend.com/


--

With warm regards,
Sudheer. S
Business: http://binaryvibes.co.in, Tech stuff: http://techchorus.net, 
Personal: http://sudheer.net


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



Re: [PHP] Problems with HTTPS and maybe an .htaccess???

2009-05-05 Thread Alex S Kurilo aka Kamazee

RewriteRule . index.php


Add an asterisk after the dot:
RewriteRule .* index.php



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



Re: [PHP] Newbie - Setting Up Some Basic Sendmail Scripts

2009-05-05 Thread Tom Worster
On 5/5/09 2:07 PM, "revDAVE"  wrote:

> I'm working with php 5 so is the 1.2.0b1 (beta) safe to use or should I go
> with the older stable 1.1.14?

i don't know if the beta is safe but i always use the most recent stable
release of whatever-it-may-be unless i have a compelling reason to use a
beta or something older.



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



[PHP] Problems with HTTPS and maybe an .htaccess???

2009-05-05 Thread Skip Evans

Hey all,

A while back I asked about forms that take credit card info 
and https. I have always put such forms behind SSL, but a site 
I have been asked to do maintenance work on did not, and after 
responses from the list and at my recommendation they 
installed an SSL and I modified the code to call https when it 
hits that form, so that part is okay.


But now I have a problem implementing this on their 
development site, which is just a duplicate code base inside a 
directory public_html/_dev and a domain name dev.sitename.com, 
instead of sitename.com.


The problem is, and I believe it may be the .htaccess file, 
redirecting the https pages to the live site. In other words, 
I'm trying to test something on the dev site in the shopping 
cart, but when I click a button that takes it to the CC form, 
hence https, although the URL says, 
https://dev.sitename.com/... I can tell it is actually on the 
live site because the code that executes is the old code on 
the live site, not the new code on the development server.


I suspect the .htaccess file, which looks thusly...

AddHandler application/x-httpd-php5 .php
Options +FollowSymLinks
IndexIgnore */*
# Turn on the RewriteEngine
RewriteEngine On
#  Rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

Now I'm no expert at these rewrite rules, and sometimes have 
to take several Valium, a shot of vodka, and weep for hours 
after working with them (okay, that was a bit of hyperbole), 
but it looks like any URL it cannot identify gets routed to 
index.php, and that is because index.php evaluates and 
processes URLs like


sitename.com/shirts/mens/

... and so forth.

Question is, am I on the right track suspecting the rewrite 
rule for redirecting the https pages to the live site, and if 
so, anyone see a fix for this? Again, hyperbole aside, I'm no 
expert at rewrite rules.


Much thanks. Any help, as always, is greatly appreciated.

Skip
--

Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com

Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut

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



[PHP] Re: speaking of control structures...

2009-05-05 Thread Maarten Schalekamp
im not sure if i understand exactly what you want. but from what ive 
gathered, did you try to make use of a FUNCTION?



"Tom Worster"  wrote in message 
news:c625f5f7.a80f%...@thefsb.org...

there's a control structure i wish php had: a simple block that you can
break out of, e.g.

block {

 if ( condition )
   break;

 blah...
 blah...

 if ( another condition )
   break;

 blah...
 blah...

 etc...

}

the block is just like a loop except that it is executed once only.

this would be a handy structure for writing input validation code. the 
blah

blah fragments can be used for opening files, talking to the db,
manipulating strings, processing dates and times, etc., the conditions for
testing if the input is unacceptable.

i'm sure many of the programmers here do this kind of thing routinely and
have their own habits and solutions. i'd be curious what they are. please
let us know!


i guess i ought to go first. it's fugly but it works:

$once = true;
while ( $once ) {
 $once = false;

 stuff using break where needed ...

}

tom



__ Information from ESET Smart Security, version of virus 
signature database 4054 (20090505) __


The message was checked by ESET Smart Security.

http://www.eset.com






__ Information from ESET Smart Security, version of virus signature 
database 4054 (20090505) __

The message was checked by ESET Smart Security.

http://www.eset.com




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



[PHP] Re: Newbie - Setting Up Some Basic Sendmail Scripts

2009-05-05 Thread Maarten Schalekamp

i think you will need to make use of a pear package to be able to do this.
pear package: http://pear.php.net/package/Mail
examples: http://blog.thekimsfamily.com/archives/3
docs: http://pear.php.net/manual/en/package.mail.mail.factory.php
   http://pear.php.net/manual/en/package.mail.mail.send.php

i dont think the built in php mail function can do authentication.
you can only change the settings avaliable in the php.ini


[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
sendmail_from = y...@yourdomain

; For Unix only.  You may supply arguments as well (default: 
"sendmail -t -i").

;sendmail_path =

; Force the addition of the specified parameters to be passed as extra 
parameters

; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =


working for the first time with pear packages can sometimes be tricky to get 
going, but once all is set you wont have any probs.


i think this will push you in the right direction

"revDAVE"  wrote in message 
news:c625c359.397af%c...@hosting4days.com...

[Newbie]

Hi folks,

I'm trying to set up some basic php send mail scripts - and I'm curious of
the best way to go...


I checked these basics out:

http://us.php.net/manual/en/function.mail.php

And got this code below going, but I'll bet I need a bit more - like adding
authentication - smtp - port - sending user / pass etc.

Any hints how to get this to the next level?

Thanks in advance - dave








--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists 09]




__ Information from ESET Smart Security, version of virus signature 
database 4054 (20090505) __


The message was checked by ESET Smart Security.

http://www.eset.com




__ Information from ESET Smart Security, version of virus signature 
database 4054 (20090505) __

The message was checked by ESET Smart Security.

http://www.eset.com




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



Re: [PHP] speaking of control structures...

2009-05-05 Thread Robert Cummings
On Tue, 2009-05-05 at 13:56 -0400, Tom Worster wrote:
> there's a control structure i wish php had: a simple block that you can
> break out of, e.g.
> 
> block {
> 
>   if ( condition )
> break;
> 
>   blah...
>   blah...
> 
>   if ( another condition )
> break;
> 
>   blah...
>   blah...
> 
>   etc...
> 
> }
> 
> the block is just like a loop except that it is executed once only.
> 
> this would be a handy structure for writing input validation code. the blah
> blah fragments can be used for opening files, talking to the db,
> manipulating strings, processing dates and times, etc., the conditions for
> testing if the input is unacceptable.
> 
> i'm sure many of the programmers here do this kind of thing routinely and
> have their own habits and solutions. i'd be curious what they are. please
> let us know!
> 
> 
> i guess i ought to go first. it's fugly but it works:
> 
> $once = true;
> while ( $once ) {
>   $once = false;
> 
>   stuff using break where needed ...
> 
> }

You can do it simpler:



But PHP 5.3 introduces goto:



Sometimes goto can make your code more succinct AND readable-- Dijkstra
be damned on this point-- All hail Knuth!

And no, I'm not saying this particular example is a good example of when
goto is useful... but it does illustrate not having to contort variables
and logic into a nightmare of complexity and unintuitiveness to satisfy
"Structured Programming" paradigms.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Newbie - Setting Up Some Basic Sendmail Scripts

2009-05-05 Thread revDAVE
On 5/5/2009 10:41 AM, "Bastien Koert"  wrote:


Thanks Bastien  - I'll check them out...

> use phpmailer or pear mailer

On 5/5/2009 10:59 AM, "Tom Worster"  wrote:

>> use phpmailer or pear mailer
> 
> agree. php's interface is a bit basic. and if you compile php with openssl
> then you can also use pear mail with smtp over ssl.
> 
> http://pear.php.net/manual/en/package.mail.mail.php

Thanks Tom,

I'm working with php 5 so is the 1.2.0b1 (beta) safe to use or should I go
with the older stable 1.1.14?

- - - - -
From: Mail
Location: http://pear.php.net/package/Mail
- - - - -

Info: 
Current Release» Bug Summary
1.2.0b1 (beta) was released on 2008-07-02 (Changelog)
1.1.14 (stable) was released on 2006-10-11 (Changelog)




--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists 09]




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



Re: [PHP] Newbie - Setting Up Some Basic Sendmail Scripts

2009-05-05 Thread Tom Worster
On 5/5/09 1:41 PM, "Bastien Koert"  wrote:

> On Tue, May 5, 2009 at 1:20 PM, revDAVE  wrote:
> 
>> And got this code below going, but I'll bet I need a bit more - like adding
>> authentication - smtp - port - sending user / pass etc.
>> 
>> Any hints how to get this to the next level?
>> 

> use phpmailer or pear mailer

agree. php's interface is a bit basic. and if you compile php with openssl
then you can also use pear mail with smtp over ssl.

http://pear.php.net/manual/en/package.mail.mail.php



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



[PHP] speaking of control structures...

2009-05-05 Thread Tom Worster
there's a control structure i wish php had: a simple block that you can
break out of, e.g.

block {

  if ( condition )
break;

  blah...
  blah...

  if ( another condition )
break;

  blah...
  blah...

  etc...

}

the block is just like a loop except that it is executed once only.

this would be a handy structure for writing input validation code. the blah
blah fragments can be used for opening files, talking to the db,
manipulating strings, processing dates and times, etc., the conditions for
testing if the input is unacceptable.

i'm sure many of the programmers here do this kind of thing routinely and
have their own habits and solutions. i'd be curious what they are. please
let us know!


i guess i ought to go first. it's fugly but it works:

$once = true;
while ( $once ) {
  $once = false;

  stuff using break where needed ...

}

tom



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



Re: [PHP] Newbie - Setting Up Some Basic Sendmail Scripts

2009-05-05 Thread Bastien Koert
On Tue, May 5, 2009 at 1:20 PM, revDAVE  wrote:

> [Newbie]
>
> Hi folks,
>
> I'm trying to set up some basic php send mail scripts - and I'm curious of
> the best way to go...
>
>
> I checked these basics out:
>
> http://us.php.net/manual/en/function.mail.php
>
> And got this code below going, but I'll bet I need a bit more - like adding
> authentication - smtp - port - sending user / pass etc.
>
> Any hints how to get this to the next level?
>
> Thanks in advance - dave
>
> 
>
>  $to  = 'nob...@example.com';
> $subject = 'the subject';
> $message = 'hello';
> $headers = 'From: webmas...@example.com' . "\r\n" .
> 'Reply-To: webmas...@example.com' . "\r\n";
>
> mail($to, $subject, $message, $headers);
> ?>
>
>
>
>
> --
> Thanks - RevDave
> Cool @ hosting4days . com
> [db-lists 09]
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
use phpmailer or pear mailer

-- 

Bastien

Cat, the other other white meat


[PHP] Newbie - Setting Up Some Basic Sendmail Scripts

2009-05-05 Thread revDAVE
[Newbie]

Hi folks,

I'm trying to set up some basic php send mail scripts - and I'm curious of
the best way to go...


I checked these basics out:

http://us.php.net/manual/en/function.mail.php

And got this code below going, but I'll bet I need a bit more - like adding
authentication - smtp - port - sending user / pass etc.

Any hints how to get this to the next level?

Thanks in advance - dave








--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists 09]




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



Re: [PHP] elseif statements

2009-05-05 Thread Paul M Foster
On Tue, May 05, 2009 at 12:12:33PM -0400, tedd wrote:

> At 11:29 AM -0400 5/5/09, Robert Cummings wrote:
>> On Tue, 2009-05-05 at 11:21 -0400, tedd wrote:
>>  > At 10:13 AM -0400 5/5/09, Robert Cummings wrote:
>>
>>  > >Just so we all know why...
>>>
>>>  Yep -- just so we know why:
>>  >
>>>  
>>  >
>>>  It all depends upon how you use the tools at your command.
>>>
>>>  My preference is still valid and I think the code is more readable. 
>>> YMMV.
>>
>> Extra level of indentation, needing to add a break statement for every
>> case. Yours is more verbose and less clear. Forgetting a break statement
>> would lead to a silent bug. Abuse of the switch statement... switching
>> on a constant is not a switch at all. I consider it obfuscated. The
>> techniques you've used are also non-portable to most other languages
>> with a switch construct. Sorry, your attempt to call this good advice
>> fails.

I hate to dogpile on Tedd, who's probably a better coder than I, but
I'll disagree on two points:

1. I have no problems with the execution or readability of elseif. In
fact, I'm grateful for it, since some languages don't have it.

2. I consider Tedd's use of the switch/case construct an abuse. The list
has seen this debate before, and Tedd's way of doing it is *legal*. But
in my opinion, the variable which switch tests should be the only one
tested, as:

switch ($var) {
case 'alfa':
...
break;
case 'bravo':
...
break;
}

not:

switch (true) {
case $var1 == 'alfa':
...
break;
case $var2 == 'bravo':
...
break;
}

I also appreciate the argument about doing it as it's done in other
languages. Tedd's right, this isn't those other languages. But when you
code in other languages as well as PHP, doing it the same way in all of
them really helps. The lack of semicolon line endings in Python drives
me nuts. Perhaps worse, Python has no switch/case construct. For some
reason van Rossum eschewed this in favor of if/else/elif. Ugh.

Ultimately, it's Tedd's choice, and if the code works, it works. I just
wouldn't do it that way. I agree with Robert-- if I saw code like this I
had to maintain, I'd be slightly miffed.

Paul
-- 
Paul M. Foster

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



Re: [PHP] Re: elseif statements

2009-05-05 Thread Gary
Jan

Thanks for your note.

So your wrote:

$x = (3)*(2) makes no sense.
$x = 3 * 2 works, as
$x = (3 * 2) does, too.
But this is not an error at all.

In the first example($x = (3)*(2) makes no sense.), which is the way I have 
it, works.  So if it works, is there a real compelling reason to change it? 
I understand that "less is more" when it comes to writing code, but does it 
slow things down, does it give erroneus results, or is it developing a poor 
writing habit?

I would enjoy your opinion.

And thank you to everyone that has helped.

I was able to solve the problem by changing = to == AND to call on the 
variable instead of the cookie.

Thanks agian

Gary


""Jan G.B.""  wrote in message 
news:c9a09d00905050811s54d82dfj41b3cb3a0eead...@mail.gmail.com...
2009/5/5 Gary :
> This just keeps getting weirder, the results change sometimes even when 
> the
> same info is entered..
>
> This is the revised code (after some helpful hints from some readers)
>
> Anyone help, I am supposed to show this tomorrow to client.
>


Hi there,

> Gary
>
>  $_SESSION['sale_session']=$_POST['sale'];
> $_SESSION['assess_session']=$_POST['assess'];
> $_SESSION['county_session']=$_POST['county'];
>
> // checks if bot
> if ($_POST['address'] != '' ){
> exit("Changed field");
> }
>
>
> $sale_value=$_POST['sale'];
> $assess_value=$_POST['assess'];
> $county=$_POST['county'];
>
> $chester_ratio=.51;
> $montco_ratio=.53;
> $delco_ratio=.58;
> /*$ratio=.51;
>
>
> /*$correct_assess=($sale_value)*($ratio); this is now the assessment 
> should
> be */
> $chester_correct_assess=($sale_value)*($chester_ratio);
> $montco_correct_assess=($sale_value)*($montco_ratio);
> $delco_correct_assess=($sale_value)*($delco_ratio);
>

$x = (3)*(2) makes no sense.
$x = 3 * 2 works, as
$x = (3 * 2) does, too.
But this is not an error at all.

>
> $chester_assess_difference=($assess_value)-($chester_correct_assess);
> $montco_assess_difference=($assess_value)-($montco_correct_assess);
> $delco_assess_difference=($assess_value)-($delco_correct_assess);
>
> /* $assess_difference=($assess_value)-($sale_value * $ratio);
> $percent_difference=($assess_difference)/($assess_value);*/
> $chester_percent_difference=($chester_assess_difference)/($assess_value);
> $delco_percent_difference=($delco_assess_difference)/($assess_value);
> $montco_percent_difference=($montco_assess_difference)/($assess_value);
>
> $chester_percent_savings=($chester_percent_difference)*100;
> $delco_percent_savings=($delco_percent_difference)*100;
> $montco_percent_savings=($montco_percent_difference)*100;
>
> if($_COOKIE['county_cookie'] ==('Chester County') &&
> ($chester_assess_difference >=5))
>
> {

Same thing here, you could write it like that instead:

if ($_COOKIE['xy'] == 'my string without brackets'
 &&  $chester_assess_difference >= 5) {
   // do something
}


> echo 'Yes, Your property appears to
> qualify!';
> echo "You 1 believe your home would today sell for 
> $".number_format($sale_value)." ";
> echo "Your current tax assessment is
> $".number_format($assess_value)."";
> echo "You live in $county ";
> echo "Your potential savings could be "
> .number_format($chester_percent_savings,0)."%";
> echo "According to preliminary calculations based on the information you
> have entered, you may enjoy a savings of 
> ".number_format($chester_percent_savings,0)."% off a combined total of
> county, school and township real estate taxes. Actual dollar amount 
> savings
> will differ depending on the township that the property is located. Please
> contact my office for a more precise estimate of savings.";
>
> }
>
> elseif($_COOKIE['county_cookie']==('Delaware County') &&
> ($delco_assess_difference >=3)) {
>
>
> echo 'Yes, Your property appears to
> qualify!';
> echo "You 2 believe your home would today sell for 
> $".number_format($sale_value)." ";
> echo "Your current tax assessment is
> $".number_format($assess_value)."";
> echo "You live in $county ";
> echo "Your potential savings could be "
> .number_format($delco_percent_savings,0)."%";
> echo "According to preliminary calculations based on the information you
> have entered, you may enjoy a savings of 
> ".number_format($delco_percent_savings,0)."% off a combined total of
> county, school and township real estate taxes. Actual dollar amount 
> savings
> will differ depending on the township that the property is located. Please
> contact my office for a more precise estimate of savings.";
> }
> elseif($_COOKIE['county_cookie']==('Montgomery County') &&
> ($montco_assess_difference >=5))
>
> {
> echo 'Yes, Your property appears to
> qualify!';
> echo "You 3 believe your home would today sell for 
> $".number_format($sale_value)." ";
> echo "Your current tax assessment is
> $".number_format($assess_value)."";
> echo "You live in $county ";
> echo "Your potential savings could be "
> .number_format($montco_percent_savings,0)."%";
> echo "According to preliminary calculations based on the information you
> 

Re: [PHP] elseif statements

2009-05-05 Thread Tom Worster
On 5/5/09 9:49 AM, "tedd"  wrote:

> In my opinion, whenever your choices exceed two, use switch.

ick!



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



Re: [PHP] elseif statements

2009-05-05 Thread Robert Cummings
On Tue, 2009-05-05 at 12:12 -0400, tedd wrote:
> At 11:29 AM -0400 5/5/09, Robert Cummings wrote:
> >On Tue, 2009-05-05 at 11:21 -0400, tedd wrote:
> >  > At 10:13 AM -0400 5/5/09, Robert Cummings wrote:
> >
> >  > >Just so we all know why...
> >>
> >>  Yep -- just so we know why:
> >  >
> >>  
> >  >
> >>  It all depends upon how you use the tools at your command.
> >>
> >>  My preference is still valid and I think the code is more readable. YMMV.
> >
> >Extra level of indentation, needing to add a break statement for every
> >case. Yours is more verbose and less clear. Forgetting a break statement
> >would lead to a silent bug. Abuse of the switch statement... switching
> >on a constant is not a switch at all. I consider it obfuscated. The
> >techniques you've used are also non-portable to most other languages
> >with a switch construct. Sorry, your attempt to call this good advice
> >fails.
> >
> >Cheers,
> >Rob.
> 
> Rob:
> 
> I agree that the way I use the switch in my example does not port to 
> other languages, but I'm not working in other languages and it's the 
> way I solve my elseif problem in this language. If I was working in a 
> different language, then I would solve it differently. But I have 
> never used an elseif statement, nor do I intend.

It may be true that you are not using different languages, but without a
compelling argument for one form over another, one should generally take
the most general form that is understood and practiced by the majority.
You have not made a compelling argument for subverting usual semantics
to contort the logic into your vision.

> If you will read my original post, I preference each statement with 
> "In my opinion". I can certainly have an opinion about the way I 
> choose to program, can't I? And, what's wrong with voicing that 
> opinion providing that you are stating it as your opinion?

Your opinion is one thing... and this is indeed opinion, but you
entangled it with prescription:

In my opinion, whenever your choices exceed two, use switch.


You are certainly permitted your opinion, as I am too. I am offering my
opinion that your advice is bunk... and I have followed it up with
argument to back my stated views.

> While I see what you are doing and agree that your solution is 
> probably better for the majority than mine, your solution still 
> doesn't work for me. I find it confusing and I find my solution much 
> more readable and understandable. Others may find it so as well. As 
> the say in Perl, there is always more than one way to do anything.

This is certainly true, when you program for yourself, and you will be
the only maintainer of that code. But down the road it is quite likely
someone else will view that code and think to themself... WTF! And that
makes it a poor judgement call. Anyone can write Perl, but how many can
write Perl that a newbie can understand?

> I admit that you are a better php programmer than I, and I usually 
> learn from you, but on this point I can't follow.

I'm not looking for gratification... merely hoping to ensure that
readers of your niche style understand that it is niche, and that it is
not really the best option of all available options. You are welcome to
disagree, your opinion is your own, but as you have argued, we are all
entitled to our opinion. Those opinions with the greatest merit should
have the better supporting arguments (one would hope anyways :)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] elseif statements

2009-05-05 Thread tedd

At 11:29 AM -0400 5/5/09, Robert Cummings wrote:

On Tue, 2009-05-05 at 11:21 -0400, tedd wrote:
 > At 10:13 AM -0400 5/5/09, Robert Cummings wrote:

 > >Just so we all know why...


 Yep -- just so we know why:

 >

 

 >

 It all depends upon how you use the tools at your command.

 My preference is still valid and I think the code is more readable. YMMV.


Extra level of indentation, needing to add a break statement for every
case. Yours is more verbose and less clear. Forgetting a break statement
would lead to a silent bug. Abuse of the switch statement... switching
on a constant is not a switch at all. I consider it obfuscated. The
techniques you've used are also non-portable to most other languages
with a switch construct. Sorry, your attempt to call this good advice
fails.

Cheers,
Rob.


Rob:

I agree that the way I use the switch in my example does not port to 
other languages, but I'm not working in other languages and it's the 
way I solve my elseif problem in this language. If I was working in a 
different language, then I would solve it differently. But I have 
never used an elseif statement, nor do I intend.


If you will read my original post, I preference each statement with 
"In my opinion". I can certainly have an opinion about the way I 
choose to program, can't I? And, what's wrong with voicing that 
opinion providing that you are stating it as your opinion?


While I see what you are doing and agree that your solution is 
probably better for the majority than mine, your solution still 
doesn't work for me. I find it confusing and I find my solution much 
more readable and understandable. Others may find it so as well. As 
the say in Perl, there is always more than one way to do anything.


I admit that you are a better php programmer than I, and I usually 
learn from you, but on this point I can't follow.


Cheers,

tedd

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

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



Re: [PHP] elseif statements

2009-05-05 Thread Jan G.B.
2009/5/5 tedd :
> At 10:13 AM -0400 5/5/09, Robert Cummings wrote:
>>
>> On Tue, 2009-05-05 at 10:05 -0400, Robert Cummings wrote:
>>>
>>>  On Tue, 2009-05-05 at 09:49 -0400, tedd wrote:
>>>  > At 2:57 PM -0400 5/4/09, Gary wrote:
>>>  > >I am trying to get this to work, however it only reads the second if
>>>  > >statement.  I get no error messages, but as I change counties, the %
>>> stays
>>>  > >the same.
>>>  > >
>>>  > >Can someone enlighten me, or should I be looking at switch
>>> statements?
>>>  > >
>>>  > >Thanks for your help.
>>>  > >
>>>  > >Gary
>>>  >
>>>  > In my opinion, never use elseif -- I've never used it. I don't see
>>>  > any reason whatsoever to do so.
>>>  >
>>>  > In my opinion, whenever your choices exceed two, use switch.
>>>
>>>  That's some of the worst advice I've ever seen.
>>
>> Just so we all know why...
>
> Yep -- just so we know why:
>
> 
>
> It all depends upon how you use the tools at your command.
>
> My preference is still valid and I think the code is more readable. YMMV.
>

Elseif statements are not solely used to check *one* variable. So in
some situations you can't even use a switch without implementing
if/else statements inside the switch.


BTW:


EX1:
  if ( $value === '0' )
{
echo 'If/ElseIf:   The string value 0'."";
}

EX3:
   case $value === '' :
  {
  echo 'Switch/Case: The empty string'."";
  break;
  }



Where is the basic difference in readability?
 Ah yes, the case is missing the brackets ..make it kinda hard to read
for me. .-)

Regards
> Cheers,
>
> tedd
> --
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> --
> 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] elseif statements

2009-05-05 Thread Robert Cummings
On Tue, 2009-05-05 at 11:21 -0400, tedd wrote:
> At 10:13 AM -0400 5/5/09, Robert Cummings wrote:
> >On Tue, 2009-05-05 at 10:05 -0400, Robert Cummings wrote:
> >>  On Tue, 2009-05-05 at 09:49 -0400, tedd wrote:
> >>  > At 2:57 PM -0400 5/4/09, Gary wrote:
> >>  > >I am trying to get this to work, however it only reads the second if
> >>  > >statement.  I get no error messages, but as I change counties, 
> >>the % stays
> >>  > >the same.
> >>  > >
> >>  > >Can someone enlighten me, or should I be looking at switch statements?
> >>  > >
> >>  > >Thanks for your help.
> >>  > >
> >>  > >Gary
> >>  >
> >>  > In my opinion, never use elseif -- I've never used it. I don't see
> >>  > any reason whatsoever to do so.
> >>  >
> >>  > In my opinion, whenever your choices exceed two, use switch.
> >>
> >>  That's some of the worst advice I've ever seen.
> >
> >Just so we all know why...
> 
> Yep -- just so we know why:
> 
> 
> 
> It all depends upon how you use the tools at your command.
> 
> My preference is still valid and I think the code is more readable. YMMV.

Extra level of indentation, needing to add a break statement for every
case. Yours is more verbose and less clear. Forgetting a break statement
would lead to a silent bug. Abuse of the switch statement... switching
on a constant is not a switch at all. I consider it obfuscated. The
techniques you've used are also non-portable to most other languages
with a switch construct. Sorry, your attempt to call this good advice
fails.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] elseif statements

2009-05-05 Thread tedd

At 10:13 AM -0400 5/5/09, Robert Cummings wrote:

On Tue, 2009-05-05 at 10:05 -0400, Robert Cummings wrote:

 On Tue, 2009-05-05 at 09:49 -0400, tedd wrote:
 > At 2:57 PM -0400 5/4/09, Gary wrote:
 > >I am trying to get this to work, however it only reads the second if
 > >statement.  I get no error messages, but as I change counties, 
the % stays

 > >the same.
 > >
 > >Can someone enlighten me, or should I be looking at switch statements?
 > >
 > >Thanks for your help.
 > >
 > >Gary
 >
 > In my opinion, never use elseif -- I've never used it. I don't see
 > any reason whatsoever to do so.
 >
 > In my opinion, whenever your choices exceed two, use switch.

 That's some of the worst advice I've ever seen.


Just so we all know why...


Yep -- just so we know why:



It all depends upon how you use the tools at your command.

My preference is still valid and I think the code is more readable. YMMV.

Cheers,

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

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



Re: [PHP] Can this be done?

2009-05-05 Thread Miller, Terion



On 5/5/09 9:52 AM, "Wolf"  wrote:

 "Miller wrote:
>
>
>
> On 5/5/09 9:23 AM, "Wolf"  wrote:
>
>
>
>  "Miller wrote:
> > Ok I have a script that grabs data from a page and puts it in a db, I need
> > to run this script 26 times on 26 different pages on the same site, is there
> > a way to do this without making 26 different scripts load? Should I post the
> > script?
> >
> > Thanks,
> > T.Miller
> >
>
> Sure it can be done...
>
> Change your script so that it has the following:
> 1. array with the page names/urls in it
> 2. foreach loop right after the array to parse it
> 3. in the current place of the file name, but the variable
> 4. Make sure to close the foreach loop
>
> IE:
> 
> $pages=array("page1.php","page2.php",,"page26.php");
> foreach ($pages as $page)
> {
> // do all the grabbing and db throwing
> }
>
> ?>
>
> HTH,
> Wolf
>
>
> Hi this is what I'm working with as of now but still getting the blank page 
> of death...clues please:
>


To find your reasons for blank pages:
1) check the php_error log if you have set it up
2) run the file via the command-line (php $filename) and see what happens, what 
errors you are getting back...
3) add the following to the top of your script after the http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: elseif statements

2009-05-05 Thread Jan G.B.
2009/5/5 Gary :
> This just keeps getting weirder, the results change sometimes even when the
> same info is entered..
>
> This is the revised code (after some helpful hints from some readers)
>
> Anyone help, I am supposed to show this tomorrow to client.
>


Hi there,

> Gary
>
>  $_SESSION['sale_session']=$_POST['sale'];
> $_SESSION['assess_session']=$_POST['assess'];
> $_SESSION['county_session']=$_POST['county'];
>
> // checks if bot
>   if ($_POST['address'] != '' ){
> exit("Changed field");
>    }
>
>
> $sale_value=$_POST['sale'];
> $assess_value=$_POST['assess'];
> $county=$_POST['county'];
>
> $chester_ratio=.51;
> $montco_ratio=.53;
> $delco_ratio=.58;
> /*$ratio=.51;
>
>
> /*$correct_assess=($sale_value)*($ratio); this is now the assessment should
> be */
> $chester_correct_assess=($sale_value)*($chester_ratio);
> $montco_correct_assess=($sale_value)*($montco_ratio);
> $delco_correct_assess=($sale_value)*($delco_ratio);
>

$x = (3)*(2) makes no sense.
$x = 3 * 2 works, as
$x = (3 * 2) does, too.
But this is not an error at all.

>
> $chester_assess_difference=($assess_value)-($chester_correct_assess);
> $montco_assess_difference=($assess_value)-($montco_correct_assess);
> $delco_assess_difference=($assess_value)-($delco_correct_assess);
>
> /*  $assess_difference=($assess_value)-($sale_value * $ratio);
> $percent_difference=($assess_difference)/($assess_value);*/
> $chester_percent_difference=($chester_assess_difference)/($assess_value);
> $delco_percent_difference=($delco_assess_difference)/($assess_value);
> $montco_percent_difference=($montco_assess_difference)/($assess_value);
>
> $chester_percent_savings=($chester_percent_difference)*100;
> $delco_percent_savings=($delco_percent_difference)*100;
> $montco_percent_savings=($montco_percent_difference)*100;
>
> if($_COOKIE['county_cookie'] ==('Chester County') &&
> ($chester_assess_difference >=5))
>
> {

Same thing here, you could write it like that instead:

if ($_COOKIE['xy'] == 'my string without brackets'
 &&  $chester_assess_difference >= 5) {
   // do something
}


> echo 'Yes, Your property appears to
> qualify!';
> echo "You 1 believe your home would today sell for 
> $".number_format($sale_value)." ";
> echo "Your current tax assessment is
> $".number_format($assess_value)."";
> echo "You live in $county ";
> echo "Your potential savings could be "
> .number_format($chester_percent_savings,0)."%";
> echo "According to preliminary calculations based on the information you
> have entered, you may enjoy a savings of  
> ".number_format($chester_percent_savings,0)."% off a combined total of
> county, school and township real estate taxes. Actual dollar amount savings
> will differ depending on the township that the property is located.  Please
> contact my office for a more precise estimate of savings.";
>
> }
>
> elseif($_COOKIE['county_cookie']==('Delaware County') &&
> ($delco_assess_difference >=3)) {
>
>
> echo 'Yes, Your property appears to
> qualify!';
> echo "You 2 believe your home would today sell for 
> $".number_format($sale_value)." ";
> echo "Your current tax assessment is
> $".number_format($assess_value)."";
> echo "You live in $county ";
> echo "Your potential savings could be "
> .number_format($delco_percent_savings,0)."%";
> echo "According to preliminary calculations based on the information you
> have entered, you may enjoy a savings of  
> ".number_format($delco_percent_savings,0)."% off a combined total of
> county, school and township real estate taxes. Actual dollar amount savings
> will differ depending on the township that the property is located.  Please
> contact my office for a more precise estimate of savings.";
> }
> elseif($_COOKIE['county_cookie']==('Montgomery County') &&
> ($montco_assess_difference >=5))
>
> {
> echo 'Yes, Your property appears to
> qualify!';
> echo "You 3 believe your home would today sell for 
> $".number_format($sale_value)." ";
> echo "Your current tax assessment is
> $".number_format($assess_value)."";
> echo "You live in $county ";
> echo "Your potential savings could be "
> .number_format($montco_percent_savings,0)."%";
> echo "According to preliminary calculations based on the information you
> have entered, you may enjoy a savings of  
> ".number_format($montco_percent_savings,0)."% off a combined total of
> county, school and township real estate taxes. Actual dollar amount savings
> will differ depending on the township that the property is located.  Please
> contact my office for a more precise estimate of savings.";
> }
>
> elseif(($chester_assess_difference <=5) &&
> ($chester_assess_difference>=1000)) {
> echo 'While it appears you may enjoy some savings, the
> dollar amount may not reach the threshold required for action. If property
> values in your area continue to decline, you may wish to revisit this issue
> again next year.';
> }
> elseif(($delco_assess_difference <=3) &&
> ($delco_assess_difference>=1000)) {
> echo 'While it appears 

Re: [PHP] Avoid to open mysql querries then times in the page

2009-05-05 Thread tedd

On 5/4/09, Matthieu  wrote:

 Hello,

 I'm a totally newbie to php/Mysql but I'd like to know if it is normal that
 I have to connect 3 times to the db in one page.

 For example, I have

 1. A connection for the login / pass a $_SESSION['login'] before the HTML
 tags

 2. I need to say hello to the user so I reconnect, run a query to select the
 user having the login and echo 'Hello '.$user['login'].'!''

 3. I need to show him his friends a bit later, so I have to connect a last
 time and re-run a querry because I can't use the data $user that I used in
 my upper php code...


 Is there a walkthroug to have only one connection for the page?

 Thanks

 Matthieu



Matthieu:

The way I usually have a user navigate a protected site is to first 
to have them identify themselves via a logon/password script -- and 
then I store their user_id in a SESSION. Note, I do not store all 
their data in a SESSION, just their user_id. The user_id should be an 
unique auto_increment integer primary key from your users' table.


At the start of each protected page, I have:

As such, I check if $user_id > 0 -- if so, then I process the request 
as directed. If not, then I send the user back to login.


As for connecting to the database, I connect as needed to get 
information needed. I do not use SESSIONs to store all the data to be 
passed from page to page, I gather only what's needed for that page.


I also make sure that when I open a connection, I close the 
connection I may have several open/close statements within a page, 
but normally I try to avoid that.


HTH's

tedd

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

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



Re: [PHP] Can this be done?

2009-05-05 Thread Wolf
 "Miller wrote: 
> 
> 
> 
> On 5/5/09 9:23 AM, "Wolf"  wrote:
> 
> 
> 
>  "Miller wrote:
> > Ok I have a script that grabs data from a page and puts it in a db, I need
> > to run this script 26 times on 26 different pages on the same site, is there
> > a way to do this without making 26 different scripts load? Should I post the
> > script?
> >
> > Thanks,
> > T.Miller
> >
> 
> Sure it can be done...
> 
> Change your script so that it has the following:
> 1. array with the page names/urls in it
> 2. foreach loop right after the array to parse it
> 3. in the current place of the file name, but the variable
> 4. Make sure to close the foreach loop
> 
> IE:
>  
> $pages=array("page1.php","page2.php",,"page26.php");
> foreach ($pages as $page)
> {
> // do all the grabbing and db throwing
> }
> 
> ?>
> 
> HTH,
> Wolf
> 
> 
> Hi this is what I'm working with as of now but still getting the blank page 
> of death...clues please:
> 


To find your reasons for blank pages:
1) check the php_error log if you have set it up
2) run the file via the command-line (php $filename) and see what happens, what 
errors you are getting back...
3) add the following to the top of your script after the http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can this be done?

2009-05-05 Thread Miller, Terion



On 5/5/09 9:23 AM, "Wolf"  wrote:



 "Miller wrote:
> Ok I have a script that grabs data from a page and puts it in a db, I need
> to run this script 26 times on 26 different pages on the same site, is there
> a way to do this without making 26 different scripts load? Should I post the
> script?
>
> Thanks,
> T.Miller
>

Sure it can be done...

Change your script so that it has the following:
1. array with the page names/urls in it
2. foreach loop right after the array to parse it
3. in the current place of the file name, but the variable
4. Make sure to close the foreach loop

IE:


HTH,
Wolf


Hi this is what I'm working with as of now but still getting the blank page of 
death...clues please:

http://www.greenecountymo.org/sheriff/warrants.php?search=A";; $targets["b"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=B";; $targets["c"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=C";; $targets["d"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=D";; $targets["e"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=E";; $targets["f"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=F";; $targets["g"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=G";; $targets["h"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=H";; $targets["i"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=I";; $targets["j"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=J";; $targets["k"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=K";; $targets["l"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=L";; foreach 
($targets as $target_url){ $userAgent = 'Googlebot/2.1 
(http://www.googlebot.com/bot.html)'; $ch = curl_init(); curl_setopt($ch, 
CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_URL,$target_url); 
curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, 
CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, 
CURLOPT_TIMEOUT, 300); $html = curl_exec($ch); if (!$html) {echo "cURL error number:" .curl_errno($ch);echo "cURL error:" . 
curl_error($ch);exit; } // Create DOM from URL or file $html = 
file_get_html('$target_url'); <-MAYBE THIS SHOULD BE $TARGETS? // Find 
table foreach($html->find('table') as $table) {foreach($table->find('tr') 
as $tr){ // Grab children   $cells = 
$tr->children();  if($cells[0]->plaintext != "Name")
{for ($i = 0; $i < count($cells); $i++){
  switch ($i){ case 0: // Name  
   $name = $cells[$i]->plaintext; echo 
$cells[$i]->plaintext; break; case 1: // 
Age $age = $cells[$i]->plaintext; 
break; case 2: // Warrant type $warrant = 
$cells[$i]->plaintext; break; case 3: // 
Bond amount $bond = $cells[$i]->plaintext;  
   break; case 4: // Warrant number 
$wnumber = $cells[$i]->plaintext; break; 
case 5: // Offence description $crime = 
$cells[$i]->plaintext; break; Default:  
   echo "Uh-oh"; }
   }   }
// Build your INSERT statement here  $query = "INSERT 
into warrants (wid, name, age, warrant, bond, wnumber, crime) VALUES (";
$query .= " '$wid', '$name', '$age', '$warrant', '$bond', '$wnumber', '$crime' 
)";//$wid = mysql_insert_id();echo $query;  
  // run query mysql_query($query) or die (mysql_error());} 
}} ?>

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



Re: [PHP] Can this be done?

2009-05-05 Thread Wolf

 "Miller wrote: 
> Ok I have a script that grabs data from a page and puts it in a db, I need
> to run this script 26 times on 26 different pages on the same site, is there
> a way to do this without making 26 different scripts load? Should I post the
> script?
> 
> Thanks, 
> T.Miller
> 

Sure it can be done...

Change your script so that it has the following:
1. array with the page names/urls in it
2. foreach loop right after the array to parse it
3. in the current place of the file name, but the variable
4. Make sure to close the foreach loop

IE:


HTH,
Wolf

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



Re: [PHP] elseif statements

2009-05-05 Thread Robert Cummings
On Tue, 2009-05-05 at 10:05 -0400, Robert Cummings wrote:
> On Tue, 2009-05-05 at 09:49 -0400, tedd wrote:
> > At 2:57 PM -0400 5/4/09, Gary wrote:
> > >I am trying to get this to work, however it only reads the second if
> > >statement.  I get no error messages, but as I change counties, the % stays
> > >the same.
> > >
> > >Can someone enlighten me, or should I be looking at switch statements?
> > >
> > >Thanks for your help.
> > >
> > >Gary
> > 
> > In my opinion, never use elseif -- I've never used it. I don't see 
> > any reason whatsoever to do so.
> > 
> > In my opinion, whenever your choices exceed two, use switch.
> 
> That's some of the worst advice I've ever seen.

Just so we all know why...



Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] elseif statements

2009-05-05 Thread Robert Cummings
On Tue, 2009-05-05 at 09:49 -0400, tedd wrote:
> At 2:57 PM -0400 5/4/09, Gary wrote:
> >I am trying to get this to work, however it only reads the second if
> >statement.  I get no error messages, but as I change counties, the % stays
> >the same.
> >
> >Can someone enlighten me, or should I be looking at switch statements?
> >
> >Thanks for your help.
> >
> >Gary
> 
> In my opinion, never use elseif -- I've never used it. I don't see 
> any reason whatsoever to do so.
> 
> In my opinion, whenever your choices exceed two, use switch.

That's some of the worst advice I've ever seen.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] SimpleXML output encoding

2009-05-05 Thread tedd

At 2:40 PM +0200 5/5/09, Ondrej Kulaty wrote:

Hi,
is there any way how to set output encoding for SimpleXML?
It will load XML document in any encoding, but internally, it converts the
document to UTF-8 and outputs it in this encoding.
I would like to have output encoding set to ISO-8859-2, is it possible?
thanks.

--
Ondrej Kulaty


Why?



tedd

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

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



Re: [PHP] Re: Can this be done?

2009-05-05 Thread Miller, Terion



On 5/5/09 8:47 AM, "Maarten Schalekamp"  wrote:

$targets[] = "http://www.greenecountymo.org/sheriff/warrants.php";;
 $targets[] = "http://www.greenecountymo.org/sheriff/page2.php";;
 $targets[] = "http://www.greenecountymo.org/sheriff/page3.php";;
 foreach ($targets as $target_url){

I think this is pointing me in the right direction, I put in a few of the urls, 
but got the blank page of php death.  I changed this part:

  $html =
file_get_html('http://www.greenecountymo.org/sheriff/warrants.php?search=C');

to:
  $html =
file_get_html('$target_url');  maybe this part is not done right?

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



Re: [PHP] how to enable ttf support in php 5.2.9

2009-05-05 Thread PJ
Ashley Sheridan wrote:
> On Mon, 2009-05-04 at 18:42 -0400, PJ wrote:
>   
>> Jim Lucas wrote:
>> 
>>> PJ wrote:
>>>   
 Is there a module to be activated or what has to be installed to have
 ttf support in php?
 My port on FreeBSD does not have an option for ttf support under make
 config .
 I'm trying to learn & understand the following:
 In file1 : 
 In file2 (button.php)- originally php3 :
 >>>   Header("Content-type: image/gif");
   if(!isset($s)) $s=11;
 
>>> The above should be:
>>>
>>> if ( empty($_GET['s']) ) {
>>> $s = 11;
>>> } else {
>>> $s = (int)$_GET['s'];
>>> }
>>>
>>>   
   $size = imagettfbbox($s,0,"times.ttf",$text);
 
>>> and this should be
>>>
>>> $text = '';
>>> if ( !empty($_GET['text']) )
>>> $text = your_custom_input_cleaner_function($_GET['text']);
>>>
>>> $size = imagettfbbox($s,0,"times.ttf",$text);
>>>
>>>   
   $dx = abs($size[2]-$size[0]);
   $dy = abs($size[5]-$size[3]);
   $xpad=9;
   $ypad=9;
   $im = imagecreate($dx+$xpad,$dy+$ypad);
   $blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF);
   $black = ImageColorAllocate($im, 0,0,0);
   $white = ImageColorAllocate($im, 255,255,255);
   ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black);
   ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white);
   ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black,
 "times.ttf", $text);
   ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white,
 "times.ttf", $text);
   ImageGif($im);
   ImageDestroy($im);
 ?>
 ONLY the above & nothing else. So far, all I get is a small blue square.
 Replacing the $text with the text just gives a rectangle a bit wider.
 gd is installed but ttf is not, so I figure that is the culprit.
 But how is the text supposed to be assigned to $text from file1?
 TIA
 
>> Thank you for that. Now it works. I see, the $s had to come from
>> somewhere...
>> But what's the custom_cleaner_function - I mean, to clean what? & Why?
>> What if I use some foreign accents, like é or  À ?
>>
>> -- 
>> Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
>> -
>> Phil Jourdan --- p...@ptahhotep.com
>>http://www.ptahhotep.com
>>http://www.chiccantine.com/andypantry.php
>>
>>
>> 
> content coming from MS Office clipboard pastes generally contain
> characters that are encoded wrong, and do not display correctly in web
> pages unless they have very relaxed doctypes. The function I generally
> use is:
>
> function removeMSCrap($crap)
> {
>   $find = Array(chr(128), chr(133), chr(8226), chr(145), chr(8217),
> chr(146), chr(8220), chr(147), chr(8221), chr(148), chr(8226), chr(149),
> chr(8211), chr(150), chr(8212), chr(151), chr(8282), chr(153), chr(169),
> chr(174));
>   $replace = Array("€", "…", "″", "'", "'",
> "'", "'", """, """, """, """, "•",
> "•", "–", "–", "—", "—", "™", "™",
> "©", "®");
>   
>   $roses = str_replace($find, $replace, $crap);
>   return $roses;
> }
>
>
> Ash
> www.ashleysheridan.co.uk
>
>
>   
Uh. Ok. That's cool. Somehow I have managed to never use MS Office for
anything else than web applications. Generally I open .doc with
OpenOffice. But, who know's? Thanks, anyway. :-)

-- 
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


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



Re: [PHP] Forcing a Post of data

2009-05-05 Thread tedd

At 12:09 AM -0700 5/5/09, Richard Kurth wrote:

How can I force this to be a POST and not a GET
 Add Customer 
or is the only way you can pass data with a POST is from a Form submission.


If you need to pass data in the url, then GET is the only viable option.

When I am confronted with "Hey, I need POST not GET" I rethink what I'm doing.

Cheers,

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

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



Re: [PHP] elseif statements

2009-05-05 Thread tedd

At 2:57 PM -0400 5/4/09, Gary wrote:

I am trying to get this to work, however it only reads the second if
statement.  I get no error messages, but as I change counties, the % stays
the same.

Can someone enlighten me, or should I be looking at switch statements?

Thanks for your help.

Gary


In my opinion, never use elseif -- I've never used it. I don't see 
any reason whatsoever to do so.


In my opinion, whenever your choices exceed two, use switch.

Cheers,

tedd

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

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



Re: [PHP] Re: Can this be done?

2009-05-05 Thread Maarten Schalekamp

can try the foreach, put all the urls in one array

something like this might work:

http://www.greenecountymo.org/sheriff/warrants.php";;
$targets[] = "http://www.greenecountymo.org/sheriff/page2.php";;
$targets[] = "http://www.greenecountymo.org/sheriff/page3.php";;
foreach ($targets as $target_url){
 $userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)';
 $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
 curl_setopt($ch, CURLOPT_URL,$target_url);
 curl_setopt($ch, CURLOPT_FAILONERROR, true);
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
 curl_setopt($ch, CURLOPT_AUTOREFERER, true);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
 curl_setopt($ch, CURLOPT_TIMEOUT, 300);
 $html = curl_exec($ch); if (!$html) {
  echo "cURL error number:" .curl_errno($ch);
  echo "cURL error:" . curl_error($ch);
  exit;
 } // Create DOM from URL or file
 $html = 
file_get_html('http://www.greenecountymo.org/sheriff/warrants.php?search=C'); 
// Find table

 foreach($html->find('table') as $table) {
  foreach($table->find('tr') as $tr){ // Grab 
children

   $cells = $tr->children();
   if($cells[0]->plaintext != "Name") {
for ($i = 0; $i < count($cells); $i++) {
 switch ($i){
  case 0: // Name
   $name = $cells[$i]->plaintext;
   echo $cells[$i]->plaintext;
   break;
  case 1: // Age
   $age = $cells[$i]->plaintext;
   break;
  case 2: // Warrant type
   $warrant = $cells[$i]->plaintext;
   break;
  case 3: // Bond amount
   $bond = $cells[$i]->plaintext;
   break;
  case 4: // Warrant number
   $wnumber = $cells[$i]->plaintext;
   break;
  case 5: // Offence description
   $crime = $cells[$i]->plaintext;
   break;
  Default:
   echo "Uh-oh";
   }   }
   }

   // Build your INSERT statement here
   $query = "INSERT into warrants (wid, name, age, warrant, bond, wnumber, 
crime) VALUES (";
   $query .= " '$wid', '$name', '$age', '$warrant', '$bond', '$wnumber', 
'$crime' )";

   //$wid = mysql_insert_id();
   echo $query;
   // run query
   mysql_query($query) or die (mysql_error());
  }
 }
}
?>


""Miller, Terion""  wrote in message 
news:c625aae1.e9b%kmille...@springfi.gannett.com...




On 5/5/09 8:31 AM, "php news feed"  wrote:

post the script, and example of data

""Miller, Terion""  wrote in message
news:c6259e7b.e91%kmille...@springfi.gannett.com...
Ok I have a script that grabs data from a page and puts it in a db, I need
to run this script 26 times on 26 different pages on the same site, is there
a way to do this without making 26 different scripts load? Should I post the
script?

Thanks,
T.Miller


__ Information from ESET Smart Security, version of virus signature
database 4053 (20090505) __

The message was checked by ESET Smart Security.

http://www.eset.com




__ Information from ESET Smart Security, version of virus signature 
database 4053 (20090505) __


The message was checked by ESET Smart Security.

http://www.eset.com




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

Here is the script:
error_reporting(E_ALL); $TESTING = TRUE; $target_url = 
"http://www.greenecountymo.org/sheriff/warrants.php";; $userAgent = 
'Googlebot/2.1 (http://www.googlebot.com/bot.html)'; $ch = curl_init(); 
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, 
CURLOPT_URL,$target_url); curl_setopt($ch, CURLOPT_FAILONERROR, true); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, 
CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); 
curl_setopt($ch, CURLOPT_TIMEOUT, 300); $html = curl_exec($ch); if (!$html) 
{echo "cURL error number:" .curl_errno($ch);echo "cURL 
error:" . curl_error($ch);exit; } // Create DOM from URL or file $html = 
file_get_html('http://www.greenecountymo.org/sheriff/warrants.php?search=C'); 
// Find table foreach($html->find('table') as $table) { 
foreach($table->find('tr') as $tr){ // Grab children 
$cells = $tr->children();  if($cells[0]->plaintext != 
"Name"){for ($i = 0; $i < count($cells); $i++) 
{  switch ($i){ case 0: // 
Name $name = $cells[$i]->plaintext; 
echo $cells[$i]->plaintext; break; case 
1: // Age $age = $c

Re: [PHP] Re: Can this be done?

2009-05-05 Thread Miller, Terion



On 5/5/09 8:31 AM, "php news feed"  wrote:

post the script, and example of data

""Miller, Terion""  wrote in message
news:c6259e7b.e91%kmille...@springfi.gannett.com...
Ok I have a script that grabs data from a page and puts it in a db, I need
to run this script 26 times on 26 different pages on the same site, is there
a way to do this without making 26 different scripts load? Should I post the
script?

Thanks,
T.Miller


__ Information from ESET Smart Security, version of virus signature
database 4053 (20090505) __

The message was checked by ESET Smart Security.

http://www.eset.com




__ Information from ESET Smart Security, version of virus signature 
database 4053 (20090505) __

The message was checked by ESET Smart Security.

http://www.eset.com




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

Here is the script:
http://www.greenecountymo.org/sheriff/warrants.php";; $userAgent = 
'Googlebot/2.1 (http://www.googlebot.com/bot.html)'; $ch = curl_init(); 
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, 
CURLOPT_URL,$target_url); curl_setopt($ch, CURLOPT_FAILONERROR, true); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, 
CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); 
curl_setopt($ch, CURLOPT_TIMEOUT, 300); $html = curl_exec($ch); if (!$html) {   
 echo "cURL error number:" .curl_errno($ch);echo "cURL error:" 
. curl_error($ch);exit; } // Create DOM from URL or file $html = 
file_get_html('http://www.greenecountymo.org/sheriff/warrants.php?search=C'); 
// Find table foreach($html->find('table') as $table) {
foreach($table->find('tr') as $tr){ // Grab children
   $cells = $tr->children();  if($cells[0]->plaintext != 
"Name"){for ($i = 0; $i < count($cells); $i++)  
  {  switch ($i){ case 0: 
// Name $name = $cells[$i]->plaintext; 
echo $cells[$i]->plaintext; break; case 1: 
// Age $age = $cells[$i]->plaintext; 
break; case 2: // Warrant type $warrant = 
$cells[$i]->plaintext; break; case 3: // 
Bond amount $bond = $cells[$i]->plaintext;  
   break; case 4: // Warrant number 
$wnumber = $cells[$i]->plaintext; break; 
case 5: // Offence description $crime = 
$cells[$i]->plaintext; break; Default:  
   echo "Uh-oh"; }
   }   }
// Build your INSERT statement here  $query = "INSERT 
into warrants (wid, name, age, warrant, bond, wnumber, crime) VALUES (";
$query .= " '$wid', '$name', '$age', '$warrant', '$bond', '$wnumber', '$crime' 
)";//$wid = mysql_insert_id();echo $query;  
  // run query mysql_query($query) or die (mysql_error());  
   }} ?>



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



Re: [PHP] Can this be done?

2009-05-05 Thread Bastien Koert
On Tue, May 5, 2009 at 8:42 AM, Miller, Terion  wrote:

> Ok I have a script that grabs data from a page and puts it in a db, I need
> to run this script 26 times on 26 different pages on the same site, is
> there
> a way to do this without making 26 different scripts load? Should I post
> the
> script?
>
> Thanks,
> T.Miller
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Is the data all the same? If so, what about using AJAX to push the data to
the server into one page?

-- 

Bastien

Cat, the other other white meat


[PHP] Re: Can this be done?

2009-05-05 Thread php news feed

post the script, and example of data

""Miller, Terion""  wrote in message 
news:c6259e7b.e91%kmille...@springfi.gannett.com...

Ok I have a script that grabs data from a page and puts it in a db, I need
to run this script 26 times on 26 different pages on the same site, is there
a way to do this without making 26 different scripts load? Should I post the
script?

Thanks,
T.Miller


__ Information from ESET Smart Security, version of virus signature 
database 4053 (20090505) __


The message was checked by ESET Smart Security.

http://www.eset.com




__ Information from ESET Smart Security, version of virus signature 
database 4053 (20090505) __

The message was checked by ESET Smart Security.

http://www.eset.com




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



Re: [PHP] Re: graphical integrated development environment recommendations?

2009-05-05 Thread Bastien Koert
On Tue, May 5, 2009 at 4:36 AM, Peter Ford  wrote:

> Adam Williams wrote:
> > With the wide range of users on the list, I'm sure there are plenty of
> > opinions on what are good graphical IDE's and which ones to avoid.  I'd
> > like to get away from using notepad.exe to code with due to its
> > limitations.  Something that supports syntax/code highlighting and has
> > browser previews would be nice features.  I'm looking at Aptana
> > (www.aptana.com) but it seems like it is more complicated to use then it
> > should be.  Either Linux or Windows IDE (i run both OSes)
> > recommendations would be fine.
> >
>
> Netbeans: works on Windows or Linux (or OSX, if you're that way inclined),
> and
> it's free.
>
> --
> Peter Ford  phone: 01580 89
> Developer   fax:   01580 893399
> Justcroft International Ltd., Staplehurst, Kent
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Komodo Edit, the light version is also nice

http://www.activestate.com/komodo_edit/

-- 

Bastien

Cat, the other other white meat


Re: [PHP] Forcing a Post of data

2009-05-05 Thread Michael A. Peters

Ashley Sheridan wrote:

On Tue, 2009-05-05 at 00:09 -0700, Richard Kurth wrote:

How can I force this to be a POST and not a GET
 Add Customer 
or is the only way you can pass data with a POST is from a Form submission.


The only way you can send post data is either through the form or using
an AJAX call.


You can also do it via curl from the server, though I don't know that is 
what the OP is looking for since he's trying to do it from a link as 
opposed to just sending post data to a url that just eats it.


This is a private function from one of my classes that needs to do it - 
should show how it is done for those curious.


It sends an xml report as post to a uri that eats the post.

I think there is another way that involves raw http requests but it 
looked rather ugly to try and do correctly to me (IE I couldn't figure 
it out :p)


private function httpPostReport() {
  $rui = $this->csp['report-uri'];
  $report = $this->triggerDOM->saveXML();
  $handle = curl_init();
  curl_setopt($handle, CURLOPT_URL,$rui);
  curl_setopt($handle, CURLOPT_POST, 1);
  curl_setopt($handle, CURLOPT_POSTFIELDS,$report);
  curl_setopt($handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
  curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 5);
  $result = curl_exec ($handle);
  curl_close ($handle);
  }




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



[PHP] Can this be done?

2009-05-05 Thread Miller, Terion
Ok I have a script that grabs data from a page and puts it in a db, I need
to run this script 26 times on 26 different pages on the same site, is there
a way to do this without making 26 different scripts load? Should I post the
script?

Thanks, 
T.Miller


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



[PHP] SimpleXML output encoding

2009-05-05 Thread Ondrej Kulaty
Hi,
is there any way how to set output encoding for SimpleXML?
It will load XML document in any encoding, but internally, it converts the 
document to UTF-8 and outputs it in this encoding.
I would like to have output encoding set to ISO-8859-2, is it possible? 
thanks.

-- 
Ondrej Kulaty 



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



Re: [PHP] Re: Query stopping after 2 records?

2009-05-05 Thread Miller, Terion
Miller: She already posted this was solved.


On 5/4/09 5:27 PM, "Martin Zvarík"  wrote:

If the query stopped after getting 2 entries then this has nothing to do
with max_execution_time.

But stupid topic anyway, I don't know why are we even trying to figure
what Miller meant, he most probably solved it already...


Andrew Hucks napsal(a):
> When you say die, does it just stop, or do you get an error message?
> Depending on how long it's taking to perform the action, the script
> will stop just because it's taking a while. (by default, I think it's
> 30 seconds.)
>
> If so, use: ini_set("max_execution_time", "time in seconds");
>
> On Mon, May 4, 2009 at 3:43 PM, Martin Zvarík  wrote:
>
>> Miller, Terion napsal(a):
>>
>>> I need help/advice figuring out why my query dies after 2 records.  Here
>>> is
>>> the query:
>>>
>>> // Build your INSERT statement here
>>>
>>>  $query = "INSERT into `warrants` (wid, name, age, warrant, bond, wnumber,
>>> crime) VALUES (";
>>>$query .= " '$wid', '$name', '$age', '$warrant',
>>> '$bond', '$wnumber', '$crime' )";
>>>$wid = mysql_insert_id();
>>>
>>> // run query
>>> mysql_query($query) or die ("GRRR");
>>>
>>>
>>>  echo $query;
>>>
>>> It inserts two records and dies half way thru the 3rd?
>>> Thanks in advance for clues to fix this.
>>> T.Miller
>>>
>>>
>> Should be:
>> --
>>
>> $sql = ...
>>
>> $query = mysql_query($sql) or die(...
>>
>> while ($r = mysql_fetch_array($query)) { 
>>
>> --
>>
>> Notice that you need to assign the mysql_query to a $query variable!
>>
>>
>> If you understand this, then there's most probably a mistake in your SQL
>> statement.
>>
>>
>> Martin
>>
>> --
>> 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] ZipArchive doesnt work for large files

2009-05-05 Thread Darren Karstens
Hi,
I am having problems using any of the ZipArchive functions for files
above a certain size. For example creating a new zip and adding 1 file
works fine for files that are only a few kb, but when I tried a
slightly large one (about 60k) the zip became corrupt. Here is the
code im using:

$zip = new ZipArchive();
$zip->open('c:/uploads/test.zip',ZipArchive::CREATE);
$zip->addFile('c:/uploads/uk_natural.shp','uk_natural.shp');
$zip->close();

This creates the zip archive but when I try and extract the file I get
the error: "C:\uploads\test.zip: CRC failed in uk_natural.shp. The
file is corrupt". Does anyone know why this is being corrupted?

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



[PHP] Re: graphical integrated development environment recommendations?

2009-05-05 Thread Peter Ford
Adam Williams wrote:
> With the wide range of users on the list, I'm sure there are plenty of
> opinions on what are good graphical IDE's and which ones to avoid.  I'd
> like to get away from using notepad.exe to code with due to its
> limitations.  Something that supports syntax/code highlighting and has
> browser previews would be nice features.  I'm looking at Aptana
> (www.aptana.com) but it seems like it is more complicated to use then it
> should be.  Either Linux or Windows IDE (i run both OSes)
> recommendations would be fine.
> 

Netbeans: works on Windows or Linux (or OSX, if you're that way inclined), and
it's free.

-- 
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Forcing a Post of data

2009-05-05 Thread Ashley Sheridan
On Tue, 2009-05-05 at 00:22 -0700, Richard Kurth wrote:
> Ashley Sheridan wrote:
> > On Tue, 2009-05-05 at 00:09 -0700, Richard Kurth wrote:
> >   
> >> How can I force this to be a POST and not a GET
> >>  Add Customer 
> >> or is the only way you can pass data with a POST is from a Form submission.
> >>
> >> 
> > The only way you can send post data is either through the form or using
> > an AJAX call. In theory, you could have an onclick handler for this link
> > which calls the AJAX, which then alters the page when it gets the return
> > value. I wouldn't recommend it though, as the link would stop
> > functioning as a link. Why do you want to send the data through POST
> > anyway?
> >
> >
> > Ash
> > www.ashleysheridan.co.uk
> >
> >
> >   
> Because some of the links get a lot of data in them and I would like to 
> pass the info so it can't be seen. The example was small so no big deal.
> It was Just a thought.

If some of the links have a lot of data in, have you thought about
trimming that down to what is necessary, and leaving the data that won't
change in a session?


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Forcing a Post of data

2009-05-05 Thread Ashley Sheridan
On Tue, 2009-05-05 at 12:58 +0530, Bipin Upadhyay wrote:
> You could use auto form submission using javascript.
> A quick search should help.
> 
> --Bipin Upadhyay.
> http://projectbee.org/
> 
> Richard Kurth wrote:
> > How can I force this to be a POST and not a GET
> >  Add Customer 
> > or is the only way you can pass data with a POST is from a Form 
> > submission.
> >
> 
> 
That would break for any UA without Javascript support or those without
it enabled.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Forcing a Post of data

2009-05-05 Thread Richard Kurth

Ashley Sheridan wrote:

On Tue, 2009-05-05 at 00:22 -0700, Richard Kurth wrote:
  

Ashley Sheridan wrote:


On Tue, 2009-05-05 at 00:09 -0700, Richard Kurth wrote:
  
  

How can I force this to be a POST and not a GET
 Add Customer 
or is the only way you can pass data with a POST is from a Form submission.




The only way you can send post data is either through the form or using
an AJAX call. In theory, you could have an onclick handler for this link
which calls the AJAX, which then alters the page when it gets the return
value. I wouldn't recommend it though, as the link would stop
functioning as a link. Why do you want to send the data through POST
anyway?


Ash
www.ashleysheridan.co.uk


  
  
Because some of the links get a lot of data in them and I would like to 
pass the info so it can't be seen. The example was small so no big deal.

It was Just a thought.



If some of the links have a lot of data in, have you thought about
trimming that down to what is necessary, and leaving the data that won't
change in a session?

  



Yes I could just pass a session number and the gather all the data out of the 
session. I might just look at that
  


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



Re: [PHP] Forcing a Post of data

2009-05-05 Thread Ashley Sheridan
On Tue, 2009-05-05 at 00:09 -0700, Richard Kurth wrote:
> How can I force this to be a POST and not a GET
>  Add Customer 
> or is the only way you can pass data with a POST is from a Form submission.
> 
The only way you can send post data is either through the form or using
an AJAX call. In theory, you could have an onclick handler for this link
which calls the AJAX, which then alters the page when it gets the return
value. I wouldn't recommend it though, as the link would stop
functioning as a link. Why do you want to send the data through POST
anyway?


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Forcing a Post of data

2009-05-05 Thread Bipin Upadhyay

You could use auto form submission using javascript.
A quick search should help.

--Bipin Upadhyay.
http://projectbee.org/

Richard Kurth wrote:

How can I force this to be a POST and not a GET
 Add Customer 
or is the only way you can pass data with a POST is from a Form 
submission.





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



[PHP] Forcing a Post of data

2009-05-05 Thread Richard Kurth

How can I force this to be a POST and not a GET
 Add Customer 
or is the only way you can pass data with a POST is from a Form submission.

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