|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general-digest-help
lists.php.net
Date: Wed May 23 2007 - 13:40:05 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 23 May 2007 18:40:05 -0000 Issue 4807
Topics (messages 255368 through 255451):
SOLVED Re: [PHP] problem with composing URL with GET Variables
255368 by: Angelo Zanetti
Re: convert numerical day of week
255369 by: Robin Vickery
255370 by: Stut
255395 by: Robert Cummings
255397 by: Greg Donald
255403 by: Robert Cummings
System wide variable
255371 by: Darren Whitlen
255372 by: Stut
255373 by: Darren Whitlen
255374 by: John Comerford
255375 by: Stut
255376 by: Darren Whitlen
255377 by: Sancar Saran
255381 by: Kostas Papadimitriou
255386 by: Jochem Maas
255413 by: Al
Re: PHP Data Mining/Data Scraping
255378 by: Shannon Whitty
255379 by: Shannon Whitty
255380 by: Shannon Whitty
255382 by: Shannon Whitty
255383 by: Shannon Whitty
Creating process and do actions with signals
255384 by: lists.dwsasia.com
php upload files
255385 by: kats Ant
255387 by: itoctopus
How to eject cd-rom with php code?
255388 by: Chetan Graham
255389 by: Jim Moseby
255390 by: Jim Moseby
255391 by: Andrew Brampton
255392 by: Zoltán Németh
255393 by: Edward Kay
255394 by: Chris Boget
255451 by: Colin Guthrie
Embedded Image from Database
255396 by: Bagus Nugroho
255402 by: Greg Donald
Include???
255398 by: Dan Shirah
255399 by: Greg Donald
255400 by: Richard Davey
255401 by: Darren Whitlen
255404 by: Daniel Brown
255406 by: Alister Bulman
255415 by: Jim Lucas
255417 by: Daniel Brown
255429 by: Jim Lucas
255430 by: Tijnema
255433 by: Greg Donald
255439 by: Daniel Brown
255449 by: Dan Shirah
Form Validation Issues
255405 by: kvigor
255407 by: Robert Cummings
255409 by: Zoltán Németh
255410 by: Daniel Brown
255411 by: Greg Donald
255412 by: kvigor
255414 by: Robert Cummings
255416 by: Robert Cummings
255418 by: Greg Donald
255419 by: Jim Lucas
255420 by: Robert Cummings
255421 by: Jared Farrish
255422 by: Greg Donald
255423 by: Greg Donald
255424 by: Robert Cummings
255425 by: Jared Farrish
255426 by: Jim Lucas
255427 by: Jim Lucas
255432 by: Greg Donald
zend framework
255408 by: Greg Donald
255440 by: Aaron Gould
Form Processing Question - Empty Fields
255428 by: Stephen
255431 by: Tijnema
255444 by: Greg Donald
problems in WHERE statment
255434 by: Mike Ryan
255437 by: Greg Donald
255442 by: Davi
255446 by: Eric Butera
255447 by: Daniel Brown
255448 by: Jared Farrish
format date field
255435 by: Mike Ryan
255438 by: Greg Donald
255445 by: Kevin Murphy
date format from a database date field
255436 by: Mike Ryan
255441 by: Daniel Brown
255450 by: Johan Holst Nielsen
Swinging Hammers (was Re: Form Validation Issues)
255443 by: Robert Cummings
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
SOLVED..... seems that something else was causing the script not to work.
Thanks anyway
Angelo Zanetti wrote:
> Dear all.
>
> I have a script that is called by an AJAX popup. Now I use an image
> file to get the path of an image for an <img> tag
>
> eg:
>
> <img border="0" id="middleImage" name="middleImage" src="<? echo
> $getImageURL; ?>" >
>
> the $getImageURL is composed as follows:
>
> $getImageURL = "getImage.php?imageid=".
> $imageID."&height=275&width=375&quality=65";
>
> However when I look at the URL that gets sent its as follows:
>
> getImage.php?imageid=10&height=275&width=375&quality=65
>
> Which is obviously incorrect.
>
> So I tried:
>
> $getImageURL = html_entity_decode("getImage.php?imageid=".
> $imageID."&height=275&width=375&quality=65");
>
> But that doesn't seem to be working. . . As the html_entity_decode
> should the & sign to the & sign?
>
> Am I going in the right direction or can anyone else let me know if
> there is something I am missing or should be doing?
>
> Thanks in advance.
>
attached mail follows:
On 22/05/07, Robert Cummings <robert
interjinn.com> wrote:
> On Tue, 2007-05-22 at 13:47 -0500, Greg Donald wrote:
> > On 5/22/07, Robert Cummings <robert
interjinn.com> wrote:
> > > Nothing said it was important, but why implement a half-assed solution
> > > when you can implement a superior solution in as much time?
> >
> > Your solution contains overhead you don't even know you need. Coding
> > for locales is an edge case since most PHP installs will find the
> > server settings sufficient.
> >
> > http://en.wikipedia.org/wiki/YAGNI
> >
> > > I'll accept ignorance and sloppiness as reasons... albeit not good
> > > reasons.
> >
> > You assume too much and your solution is bloated. Accept that.
>
> No, your solution is bloated. Mine may run a tad slower, but it consumes
> less memory since it uses the weekday names already defined in the
> locale. Yours redefines the strings thus requiring that much extra
> storage. Yours is redundant with information already available in the
> locale. The YAGNI claim is irrelevant here since I'm producing the
> requested functionality that the poster obviously needs. Whether I use
> your method or my method is irrelevant to YAGNI.
they're all bloated:
print jddayofweek($day_number, 1);
-robin
attached mail follows:
itoctopus wrote:
> I think what you need is simply something like this:
>
> function get_day($int_day){
> $arr_day_of_week = array('1'=>'Sunday', '2'=>'Monday', '3'=>'Tuesday',
> '4'=>'Wednesday', '5'=>'Thurdsay', '6'=>'Friday', '7'=>'Saturday');
> }
>
> echo(get_day(1)); //will print Sunday
Hmm, not so much. Methinks your function should return something to get
the desired effect.
-Stut
attached mail follows:
On Wed, 2007-05-23 at 10:31 +0300, Robin Vickery wrote:
> On 22/05/07, Robert Cummings <robert
interjinn.com> wrote:
> > On Tue, 2007-05-22 at 13:47 -0500, Greg Donald wrote:
> > > On 5/22/07, Robert Cummings <robert
interjinn.com> wrote:
> > > > Nothing said it was important, but why implement a half-assed solution
> > > > when you can implement a superior solution in as much time?
> > >
> > > Your solution contains overhead you don't even know you need. Coding
> > > for locales is an edge case since most PHP installs will find the
> > > server settings sufficient.
> > >
> > > http://en.wikipedia.org/wiki/YAGNI
> > >
> > > > I'll accept ignorance and sloppiness as reasons... albeit not good
> > > > reasons.
> > >
> > > You assume too much and your solution is bloated. Accept that.
> >
> > No, your solution is bloated. Mine may run a tad slower, but it consumes
> > less memory since it uses the weekday names already defined in the
> > locale. Yours redefines the strings thus requiring that much extra
> > storage. Yours is redundant with information already available in the
> > locale. The YAGNI claim is irrelevant here since I'm producing the
> > requested functionality that the poster obviously needs. Whether I use
> > your method or my method is irrelevant to YAGNI.
>
> they're all bloated:
>
> print jddayofweek($day_number, 1);
Very nice, and it's based off the locale. I wasn't aware of these
functions... Looks like I've learnt something :)
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
On 5/23/07, Robin Vickery <robinv
gmail.com> wrote:
> they're all bloated:
>
> print jddayofweek($day_number, 1);
Must go --enable-calendar now :)
--
Greg Donald
http://destiney.com/
attached mail follows:
On Wed, 2007-05-23 at 09:23 -0500, Greg Donald wrote:
> On 5/23/07, Robin Vickery <robinv
gmail.com> wrote:
> > they're all bloated:
> >
> > print jddayofweek($day_number, 1);
>
> Must go --enable-calendar now :)
Awww, I didn't notice it's a compile flag... hmmm, not so portable that
way. Something tells me then that Greg still wins on memory footprint.
It's quite likely Greg's hash lookup still beats calling an internal
function for speed also.
But I still don't like Greg's method :D
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
Hi,
I have a PHP script that reads and updates either a small file or a
mysql database. This script is called from several places every .5 seconds.
I would like to move this file to a variable for extra speed as the file
is causing a few problems being accessed so many times.
Is it possible to have a writeable variable that has the scope of EVERY
script that is run through the parser?
Thanks,
Darren
attached mail follows:
Darren Whitlen wrote:
> I have a PHP script that reads and updates either a small file or a
> mysql database. This script is called from several places every .5 seconds.
>
> I would like to move this file to a variable for extra speed as the file
> is causing a few problems being accessed so many times.
> Is it possible to have a writeable variable that has the scope of EVERY
> script that is run through the parser?
Not really. Your options are basically 1) use the database instead of
the file, or 2) try memcached (Google for it).
-Stut
attached mail follows:
Stut wrote:
> Darren Whitlen wrote:
>> I have a PHP script that reads and updates either a small file or a
>> mysql database. This script is called from several places every .5
>> seconds.
>>
>> I would like to move this file to a variable for extra speed as the
>> file is causing a few problems being accessed so many times.
>> Is it possible to have a writeable variable that has the scope of
>> EVERY script that is run through the parser?
>
> Not really. Your options are basically 1) use the database instead of
> the file, or 2) try memcached (Google for it).
>
> -Stut
Hmmm caching really isnt an option here as the data is always changing.
Just a wild idea here.. would it cause major overhead if a script was to
start a session, update some session vars, then switch to a common
session_id that each script can access? Then use that session to store
to my info.
Would that cause any obvious problems?
Darren
attached mail follows:
How about a table using the mysql memory engine ?
Darren Whitlen wrote:
> Hi,
> I have a PHP script that reads and updates either a small file or a
> mysql database. This script is called from several places every .5
> seconds.
>
> I would like to move this file to a variable for extra speed as the
> file is causing a few problems being accessed so many times.
> Is it possible to have a writeable variable that has the scope of
> EVERY script that is run through the parser?
>
> Thanks,
> Darren
>
attached mail follows:
Darren Whitlen wrote:
> Stut wrote:
>> Darren Whitlen wrote:
>>> I have a PHP script that reads and updates either a small file or a
>>> mysql database. This script is called from several places every .5
>>> seconds.
>>>
>>> I would like to move this file to a variable for extra speed as the
>>> file is causing a few problems being accessed so many times.
>>> Is it possible to have a writeable variable that has the scope of
>>> EVERY script that is run through the parser?
>>
>> Not really. Your options are basically 1) use the database instead of
>> the file, or 2) try memcached (Google for it).
>>
>> -Stut
>
> Hmmm caching really isnt an option here as the data is always changing.
> Just a wild idea here.. would it cause major overhead if a script was to
> start a session, update some session vars, then switch to a common
> session_id that each script can access? Then use that session to store
> to my info.
> Would that cause any obvious problems?
Yes, it would. Depending on the session implementation you are using,
PHP locks the session data for the duration of the request. So doing as
you suggest would mean the server could only process one request at a time.
The best option is to use a database, as this is the sort of thing they
are designed to do.
Also note that I was suggesting memcached not for it's caching
abilities, but the fact that it provides controlled access to shared
data. On reflection it's probably a bad idea because if it's always
changing then performance will suck.
-Stut
attached mail follows:
John Comerford wrote:
> How about a table using the mysql memory engine ?
>
> Darren Whitlen wrote:
>> Hi,
>> I have a PHP script that reads and updates either a small file or a
>> mysql database. This script is called from several places every .5
>> seconds.
>>
>> I would like to move this file to a variable for extra speed as the
>> file is causing a few problems being accessed so many times.
>> Is it possible to have a writeable variable that has the scope of
>> EVERY script that is run through the parser?
>>
>> Thanks,
>> Darren
>>
> From - Wed
Not thought about the memory engine actually. Will give that a try and
see how it turns out.
Think I'll leave the session_id idea then, if it locks it down
per-script, the performance will pretty much die.
Thanks!
attached mail follows:
On Wednesday 23 May 2007 11:52:27 Darren Whitlen wrote:
> Hi,
> I have a PHP script that reads and updates either a small file or a
> mysql database. This script is called from several places every .5 seconds.
>
> I would like to move this file to a variable for extra speed as the file
> is causing a few problems being accessed so many times.
> Is it possible to have a writeable variable that has the scope of EVERY
> script that is run through the parser?
>
> Thanks,
> Darren
Hi,
You should use memcached.
Regards
Sancar
attached mail follows:
Darren Whitlen wrote:
> Hi,
> I have a PHP script that reads and updates either a small file or a
> mysql database. This script is called from several places every .5 seconds.
>
> I would like to move this file to a variable for extra speed as the file
> is causing a few problems being accessed so many times.
> Is it possible to have a writeable variable that has the scope of EVERY
> script that is run through the parser?
>
> Thanks,
> Darren
check this
http://pecl.php.net/package/memcache
also if the scripts are associated with each other you could check out
using a singleton pattern
(http://www.google.com/search?q=php5+singleton&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a)
attached mail follows:
Darren Whitlen wrote:
> Hi,
> I have a PHP script that reads and updates either a small file or a
> mysql database. This script is called from several places every .5 seconds.
assuming your using a real OS ....
whilst your figuring out an even better way to do it you might consider sticking
the small file in question in /dev/shm (again assuming that your OS has tmpfs)
so that your file is actually stored in RAM rather than on disk.
a cron job every so often can ensure you have a reasonably up2date copy of the
file lying around in case you need it.
>
> I would like to move this file to a variable for extra speed as the file
> is causing a few problems being accessed so many times.
> Is it possible to have a writeable variable that has the scope of EVERY
> script that is run through the parser?
>
> Thanks,
> Darren
>
attached mail follows:
Take a look at SQLite
Darren Whitlen wrote:
> Hi,
> I have a PHP script that reads and updates either a small file or a
> mysql database. This script is called from several places every .5 seconds.
>
> I would like to move this file to a variable for extra speed as the file
> is causing a few problems being accessed so many times.
> Is it possible to have a writeable variable that has the scope of EVERY
> script that is run through the parser?
>
> Thanks,
> Darren
attached mail follows:
We are planning to eventually develop a web service and communicate in this
fashion but i want to get something up quiclly that is operational while we
spec the project in full.
Thanks
Shannon
""itoctopus"" <newsgroup
itoctopus.com> wrote in message
news:B5.7E.32102.5D240564
pb1.pair.com...
> In case you have no control on the other URL, then CURL is probably your
> best solution.
> Otherwise, a better way to do it is probably to interact with a web
> service installed on the other website.
>
> --
> itoctopus - http://www.itoctopus.com
> ""Shannon Whitty"" <shannonw
bigpond.com> wrote in message
> news:C2.10.08662.8DEBF464
pb1.pair.com...
>> Hi,
>>
>> I'm looking for a piece of software or coding that will let me post a
>> form to another URL, accept the response, search it for a specific
>> "success" string and then let me continue processing the rest of my
>> program.
>>
>> I want to accept queries on behalf of my supplier, forward it to them
>> behind the scenes, accept their response and display it within my
>> website.
>>
>> Has anyone had any experience with this? Is there a simple, basic
>> utility to let me do this?
>>
>> I was kind of hoping I could avoid developing it myself.
>>
>> Thanks
>> Shannon
attached mail follows:
THanks,
I will have far to much data to append to a GET request so a POST is the
best option I think.
"Myron Turner" <turnermm02
shaw.ca> wrote in message
news:4653133E.3000201
shaw.ca...
>
>> On Sat, May 19, 2007 10:22 pm, Shannon Whitty wrote:
>>
>>> I'm looking for a piece of software or coding that will let me post a
>>> form
>>> to another URL, accept the response, search it for a specific
>>> "success"
>>> string and then let me continue processing the rest of my program.
>>>
>>
>> http://php.net/curl
>>
>>
>>> I want to accept queries on behalf of my supplier, forward it to them
>>> behind
>>> the scenes, accept their response and display it within my website.
>>>
>>> Has anyone had any experience with this? Is there a simple, basic
>>> utility
>>> to let me do this?
>>>
>>> I was kind of hoping I could avoid developing it myself.
>>>
> As I understand this, you want to create a web page of your own which
> accepts requests for customers who are going to order products from your
> supplier. You want to have a form on your page which accepts their
> requests, then forward the form data on to your supplier's web site, where
> presumably it will be processed. Then you want to retrieve the response
> from your supplier's page, and display the result on your own web page.
> You suggest that the response string for "success" is relatively stable
> and that this string is this what you want to search for in the response.
>
> This doesn't sound like a very complicated problem. You can do this
> either using Ajax or not. The basic solution is the same. You have a
> script on the server which accepts the form data from your page and
> re-sends it to the supplier's site. If your supplier's site accepts form
> data using GET, then you can simply create a url with the form data
> attached in a query string:
>
> http://my.supplier.com?fdata_1=data1&fdata_2=data2
>
> Send this url to your suppler using file_get_contents:
>
> $return_string =
> file_get_contents("http://my.supplier.com?fdata_1=data1&fdata_2=data2");
>
> This will return the html file as a string which you can then parse with
> preg_match() for the 'success' string.
> The problem is more involved if your supplier doesn't accept GET but only
> accepts POST. Then you have to use either curl or fsockopen to post your
> data. I've tested the following fockopen script and it worked for me:
>
> <?php
> $fp = fsockopen("my.supplier.com", 80, $errno, $errstr, 30);
> if (!$fp) {
> echo "$errstr ($errno)<br />\n";
> } else {
> $out = "POST http://my.supplier.com/form_page.html / HTTP/1.1\r\n";
> $out .= "Host: my.supplier.com\r\n";
>
> $post = "form_data_1=data_1&formdata_2=data_2";
> $len = strlen($post);
> $post .= "\r\n";
> $out .="Content-Length: $len\r\n"; $out .= "Connection:
> Close\r\n\r\n";
>
> $out .= $post;
>
> fwrite($fp, $out);
> $result= "";
> while (!feof($fp)) {
> $result .= fgets($fp, 128);
> }
> fclose($fp);
> echo $result;
>
>
> }
> ?>
>
> You have to adhere to the above sequence. The posted data comes last and
> it is preceded by a content-length header which tells the receiving server
> how long the posted data is. The returned result is the html page
> returned from your posted request.
>
> --
>
> _____________________
> Myron Turner
> http://www.room535.org
> http://www.bstatzero.org
> http://www.mturner.org/XML_PullParser/
attached mail follows:
THanks,
I will have far to much data to append to a GET request so a POST is the
best option I think.
"Myron Turner" <turnermm02
shaw.ca> wrote in message
news:4653133E.3000201
shaw.ca...
>
>> On Sat, May 19, 2007 10:22 pm, Shannon Whitty wrote:
>>
>>> I'm looking for a piece of software or coding that will let me post a
>>> form
>>> to another URL, accept the response, search it for a specific
>>> "success"
>>> string and then let me continue processing the rest of my program.
>>>
>>
>> http://php.net/curl
>>
>>
>>> I want to accept queries on behalf of my supplier, forward it to them
>>> behind
>>> the scenes, accept their response and display it within my website.
>>>
>>> Has anyone had any experience with this? Is there a simple, basic
>>> utility
>>> to let me do this?
>>>
>>> I was kind of hoping I could avoid developing it myself.
>>>
> As I understand this, you want to create a web page of your own which
> accepts requests for customers who are going to order products from your
> supplier. You want to have a form on your page which accepts their
> requests, then forward the form data on to your supplier's web site, where
> presumably it will be processed. Then you want to retrieve the response
> from your supplier's page, and display the result on your own web page.
> You suggest that the response string for "success" is relatively stable
> and that this string is this what you want to search for in the response.
>
> This doesn't sound like a very complicated problem. You can do this
> either using Ajax or not. The basic solution is the same. You have a
> script on the server which accepts the form data from your page and
> re-sends it to the supplier's site. If your supplier's site accepts form
> data using GET, then you can simply create a url with the form data
> attached in a query string:
>
> http://my.supplier.com?fdata_1=data1&fdata_2=data2
>
> Send this url to your suppler using file_get_contents:
>
> $return_string =
> file_get_contents("http://my.supplier.com?fdata_1=data1&fdata_2=data2");
>
> This will return the html file as a string which you can then parse with
> preg_match() for the 'success' string.
> The problem is more involved if your supplier doesn't accept GET but only
> accepts POST. Then you have to use either curl or fsockopen to post your
> data. I've tested the following fockopen script and it worked for me:
>
> <?php
> $fp = fsockopen("my.supplier.com", 80, $errno, $errstr, 30);
> if (!$fp) {
> echo "$errstr ($errno)<br />\n";
> } else {
> $out = "POST http://my.supplier.com/form_page.html / HTTP/1.1\r\n";
> $out .= "Host: my.supplier.com\r\n";
>
> $post = "form_data_1=data_1&formdata_2=data_2";
> $len = strlen($post);
> $post .= "\r\n";
> $out .="Content-Length: $len\r\n"; $out .= "Connection:
> Close\r\n\r\n";
>
> $out .= $post;
>
> fwrite($fp, $out);
> $result= "";
> while (!feof($fp)) {
> $result .= fgets($fp, 128);
> }
> fclose($fp);
> echo $result;
>
>
> }
> ?>
>
> You have to adhere to the above sequence. The posted data comes last and
> it is preceded by a content-length header which tells the receiving server
> how long the posted data is. The returned result is the html page
> returned from your posted request.
>
> --
>
> _____________________
> Myron Turner
> http://www.room535.org
> http://www.bstatzero.org
> http://www.mturner.org/XML_PullParser/
attached mail follows:
THanks,
I will have far to much data to append to a GET request so a POST is the
best option I think.
"Myron Turner" <turnermm02
shaw.ca> wrote in message
news:4653133E.3000201
shaw.ca...
>
>> On Sat, May 19, 2007 10:22 pm, Shannon Whitty wrote:
>>
>>> I'm looking for a piece of software or coding that will let me post a
>>> form
>>> to another URL, accept the response, search it for a specific
>>> "success"
>>> string and then let me continue processing the rest of my program.
>>>
>>
>> http://php.net/curl
>>
>>
>>> I want to accept queries on behalf of my supplier, forward it to them
>>> behind
>>> the scenes, accept their response and display it within my website.
>>>
>>> Has anyone had any experience with this? Is there a simple, basic
>>> utility
>>> to let me do this?
>>>
>>> I was kind of hoping I could avoid developing it myself.
>>>
> As I understand this, you want to create a web page of your own which
> accepts requests for customers who are going to order products from your
> supplier. You want to have a form on your page which accepts their
> requests, then forward the form data on to your supplier's web site, where
> presumably it will be processed. Then you want to retrieve the response
> from your supplier's page, and display the result on your own web page.
> You suggest that the response string for "success" is relatively stable
> and that this string is this what you want to search for in the response.
>
> This doesn't sound like a very complicated problem. You can do this
> either using Ajax or not. The basic solution is the same. You have a
> script on the server which accepts the form data from your page and
> re-sends it to the supplier's site. If your supplier's site accepts form
> data using GET, then you can simply create a url with the form data
> attached in a query string:
>
> http://my.supplier.com?fdata_1=data1&fdata_2=data2
>
> Send this url to your suppler using file_get_contents:
>
> $return_string =
> file_get_contents("http://my.supplier.com?fdata_1=data1&fdata_2=data2");
>
> This will return the html file as a string which you can then parse with
> preg_match() for the 'success' string.
> The problem is more involved if your supplier doesn't accept GET but only
> accepts POST. Then you have to use either curl or fsockopen to post your
> data. I've tested the following fockopen script and it worked for me:
>
> <?php
> $fp = fsockopen("my.supplier.com", 80, $errno, $errstr, 30);
> if (!$fp) {
> echo "$errstr ($errno)<br />\n";
> } else {
> $out = "POST http://my.supplier.com/form_page.html / HTTP/1.1\r\n";
> $out .= "Host: my.supplier.com\r\n";
>
> $post = "form_data_1=data_1&formdata_2=data_2";
> $len = strlen($post);
> $post .= "\r\n";
> $out .="Content-Length: $len\r\n"; $out .= "Connection:
> Close\r\n\r\n";
>
> $out .= $post;
>
> fwrite($fp, $out);
> $result= "";
> while (!feof($fp)) {
> $result .= fgets($fp, 128);
> }
> fclose($fp);
> echo $result;
>
>
> }
> ?>
>
> You have to adhere to the above sequence. The posted data comes last and
> it is preceded by a content-length header which tells the receiving server
> how long the posted data is. The returned result is the html page
> returned from your posted request.
>
> --
>
> _____________________
> Myron Turner
> http://www.room535.org
> http://www.bstatzero.org
> http://www.mturner.org/XML_PullParser/
attached mail follows:
THanks,
That's what I thought...
I really only need to check for one value = "success" - anything else should
redirect back to the form entry page and display whatever result has been
returned from the remote site.
cUrl should be able to differentiate between a connection and an application
failure shouldn't it?
The way I see it:
1: If I can connect to port80 THEN continue ELSE goto:6
2: If I get a response THEN continue ELSE goto:6
3: If response contains "result tags" THEN continue ELSE goto:6
4: If "result tags" contains "success" THEN goto:5 ELSE goto:7
5: Display "success" and finish
6: Display connection error and resort to email and finish
7: Reload form and display error returned within "result tags"
thanks
Shannon
""Richard Lynch"" <ceo
l-i-e.com> wrote in message
news:56262.216.230.84.67.1179795266.squirrel
www.l-i-e.com...
> On Sat, May 19, 2007 10:22 pm, Shannon Whitty wrote:
>> I'm looking for a piece of software or coding that will let me post a
>> form
>> to another URL, accept the response, search it for a specific
>> "success"
>> string and then let me continue processing the rest of my program.
>
> http://php.net/curl
>
>> I want to accept queries on behalf of my supplier, forward it to them
>> behind
>> the scenes, accept their response and display it within my website.
>>
>> Has anyone had any experience with this? Is there a simple, basic
>> utility
>> to let me do this?
>>
>> I was kind of hoping I could avoid developing it myself.
>
> Search for PHP curl examples online, and you should find the code
> simple enough to copy/paste and alter to taste...
>
> It won't be quite as easy as "install forum X" but it shouldn't kill
> you either...
>
> The tricky bit is to figure out what to do when your result from the
> supplier is not "success" nor "failure" but their site has gone down
> and you've got some weird answer you've never seen before...
>
> Or when they alter their web application and then yours breaks because
> of it...
>
> You'll end up taking a simple 5-line program and adding about 50 lines
> of "what if" error handling if you do this right... Or leave it at 5
> lines and pray nothing goes wrong :-)
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/browse/from/lynch
> Yeah, I get a buck. So?
attached mail follows:
Hi,
I have this script testing.php that I run on a Linux machine thru the
command line. In the end of the file you see two cases. One where it
is just having a while(true) loop doing nothing, and the other calling
an other script that is doing nothing but doesn't exit. When I send
SIGTERM for the first case it does what it is supposed to do, but when
sending SIGTERM to the other case it doesn't work.
Might it be so that the signals cannot be handled if the script is
busy creating its own process or similar? Because when executing it
with case two doesn't leave the exec() part until the other script
exits, and it will never exits.
I try to send the signal with:
# kill -s SIGTERM 24574
The "ps -ef | grep testing.php | grep -v grep" looks like this as example:
500 24574 1 0 13:50 ? 00:00:00 /usr/bin/php ./testing.php
Best regards,
Peter Lauri
Code:
+++++++++++++++++++++++++++++++++++++++++++++++++++++
#!/usr/bin/php
<?php
declare(ticks = 1);
$pid = pcntl_fork();
if ($pid == -1) {
die("could not fork");
} else if ($pid) {
exit(); // we are the parent
} else {
// we are the child
}
// detatch from the controlling terminal
if (!posix_setsid()) {
die("could not detach from terminal");
}
function sig_handle($signo) {
switch($signo) {
case SIGTERM:
echo "I got the SIGTERM signal:".$signo."\n";
break;
case SIGCHLD:
echo "I got the SIGCHLD signal:".$signo."\n";
break;
case SIGINT:
echo "I got the SIGINT signal:".$signo."\n";
break;
}
}
pcntl_signal(SIGTERM, "sig_handle");
pcntl_signal(SIGCHLD, "sig_handle");
pcntl_signal(SIGINT, "sig_handle");
//Case 1 with just a while loop is working
//while(true) {
//
//}
//Case 2 when executing the script testing2.php that also do a
//infinite while loop does not work
//exec("./testing2.php");
?>
attached mail follows:
Hi all a i am running a windows 2003 server with IIS. I have created a php script that uploads a file to a server.
in the server i have users and a user1 has permission to folder1, user2 has permissions to folder2. I want an administrator to run the script and upload a file to these foldes. how can the script access the folders that only various users have access?
_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE
attached mail follows:
As far as I remember, IIS used to have a reserved user that it ran all its
actions under.
All you have to do is to give this user the necessary permissions (I
remember the username started with I).
Here's a link that might help : http://support.microsoft.com/kb/812614
--
itoctopus - http://www.itoctopus.com
"kats Ant" <katsikad
hotmail.com> wrote in message
news:BAY110-W2DF00E72483FEF5AF9375C5350
phx.gbl...
Hi all a i am running a windows 2003 server with IIS. I have created a php
script that uploads a file to a server.
in the server i have users and a user1 has permission to folder1, user2 has
permissions to folder2. I want an administrator to run the script and upload
a file to these foldes. how can the script access the folders that only
various users have access?
_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?qwonders+world&mkt-US&form=QBRE
attached mail follows:
Hi all,
I am writing a script and need to eject the cd-rom drive at some point.
Does anyone have an idea how to do this?
This is a simple command isn't it?
I greatly appreciate your help
Blessings,
Chetanji
attached mail follows:
> Hi all,
> I am writing a script and need to eject the cd-rom drive at
> some point.
> Does anyone have an idea how to do this?
> This is a simple command isn't it?
> I greatly appreciate your help
> Blessings,
> Chetanji
Found this little snippet on the php.net site. (
http://us2.php.net/manual/en/ref.com.php)
Might work for you:
Using the Windows Media Player OCX and the latest snap of PHP 5.1 i was able
to eject a CD-ROM drive
<?php
//create an instance of Windows Media Player
$mp = new COM("WMPlayer.OCX");
//ejects the first cd-rom on the drive list
$mp->cdromcollection->item(0)->eject();
?>
HTH
JM
attached mail follows:
> > Hi all,
> > I am writing a script and need to eject the cd-rom drive at
> > some point.
> > Does anyone have an idea how to do this?
> > This is a simple command isn't it?
> > I greatly appreciate your help
> > Blessings,
> > Chetanji
>
> Found this little snippet on the php.net site. (
> http://us2.php.net/manual/en/ref.com.php)
>
> Might work for you:
>
> Using the Windows Media Player OCX and the latest snap of PHP
> 5.1 i was able
> to eject a CD-ROM drive
>
> <?php
> //create an instance of Windows Media Player
> $mp = new COM("WMPlayer.OCX");
> //ejects the first cd-rom on the drive list
> $mp->cdromcollection->item(0)->eject();
>
> ?>
>
> HTH
>
> JM
>
I should amend this to say that this will eject the cdrom drive on the
WINDOWS server that PHP is running on. If you're looking to eject the CD on
the CLIENT, you're out of luck. To eject a CD on a linux based server,
maybe a simple 'exec('eject')' will work.
JM
attached mail follows:
If you are on linux just shell out the linux eject command (which should
eject the drive for you).
If you are on windows (or another OS), then I'm sure you can still find a
similar commnad line app that will do the same task.
There isn't a built in way in PHP.
Andrew
----- Original Message -----
From: "Chetan Graham" <chetan_graham
amritatech.com>
To: <php-general
lists.php.net>
Sent: Wednesday, May 23, 2007 12:23 PM
Subject: [PHP] How to eject cd-rom with php code?
> Hi all,
> I am writing a script and need to eject the cd-rom drive at some point.
> Does anyone have an idea how to do this?
> This is a simple command isn't it?
> I greatly appreciate your help
> Blessings,
> Chetanji
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
exec("eject");
on linux/unix
greets
Zoltán Németh
2007. 05. 23, szerda keltezéssel 14.23-kor Chetan Graham ezt Ãrta:
> Hi all,
> I am writing a script and need to eject the cd-rom drive at some point.
> Does anyone have an idea how to do this?
> This is a simple command isn't it?
> I greatly appreciate your help
> Blessings,
> Chetanji
>
attached mail follows:
> -----Original Message-----
> From: Chetan Graham [mailto:chetan_graham
amritatech.com]
> Sent: 23 May 2007 12:23
> To: php-general
lists.php.net
> Subject: [PHP] How to eject cd-rom with php code?
>
>
> Hi all,
> I am writing a script and need to eject the cd-rom drive at some point.
> Does anyone have an idea how to do this?
> This is a simple command isn't it?
> I greatly appreciate your help
> Blessings,
> Chetanji
>
Pass the appropriate system (i.e. command prompt) command to exec():
http://uk.php.net/exec
Edward
attached mail follows:
> I am writing a script and need to eject the cd-rom drive at some point.
> Does anyone have an idea how to do this?
> This is a simple command isn't it?
> I greatly appreciate your help
<?php
system( 'eject [-dfnpq] [device | nickname]' );
?>
http://us.php.net/manual/en/function.system.php
http://bama.ua.edu/cgi-bin/man-cgi?eject+1
thnx,
Chris
attached mail follows:
Chetan Graham wrote:
> Hi all,
> I am writing a script and need to eject the cd-rom drive at some point.
> Does anyone have an idea how to do this?
> This is a simple command isn't it?
> I greatly appreciate your help
Seeing as everyone is telling you to use "exec('eject')" to eject your
disk I'll follow up and say that if you are creating a fancy backup
script that combines mechano/lego to put a new blank CDR in the drive
you may want to inject it later..... to do that you do "eject -t" ;)
Pointless reply #2348834
Col
attached mail follows:
I was trying to put embedded image on HTML Mail using PHP Mailer, my problem is my image does not located on filesystem but located within MySQL Server.
How I can put image from database into HTML Mail.
Thanks in advance, bgs
attached mail follows:
On 5/23/07, Bagus Nugroho <bnugroho
aitemail.com> wrote:
> I was trying to put embedded image on HTML Mail using PHP Mailer, my problem is my
> image does not located on filesystem but located within MySQL Server.
>
> How I can put image from database into HTML Mail.
How do you view the images now? That same image URL should work in an email.
--
Greg Donald
http://destiney.com/
attached mail follows:
Okay, I think I'm doing everything right, but for whatever reason my include
isn't working.
<?php
echo $_POST['status_code'];
if ($_POST['status_code'] = "C") {
include ('complete_save.php');
}
?>
The echo of my status_code retruns the correct value so the if should
trigger.
This is my include page:
<?php
echo "test";
?>
VERY simple, but for some reason is not working????
attached mail follows:
On 5/23/07, Dan Shirah <mrsquash2
gmail.com> wrote:
> Okay, I think I'm doing everything right, but for whatever reason my include
> isn't working.
>
> <?php
> echo $_POST['status_code'];
> if ($_POST['status_code'] = "C") {
== not =
--
Greg Donald
http://destiney.com/
attached mail follows:
Hi Dan,
Wednesday, May 23, 2007, 3:24:11 PM, you wrote:
> Okay, I think I'm doing everything right, but for whatever reason my include
> isn't working.
> <?php
> echo $_POST['status_code'];
> if ($_POST['status_code'] = "C") {
> include ('complete_save.php');
> }
?>>
> The echo of my status_code retruns the correct value so the if should
> trigger.
if ($_POST['status_code'] == 'C')
^^
Read-up on the if/else structure and comparison operators. You'd never
use a single equals sign in this example.
Cheers,
Rich
--
Zend Certified Engineer
http://www.corephp.co.uk
"Never trust a computer you can't throw out of a window"
attached mail follows:
Dan Shirah wrote:
> Okay, I think I'm doing everything right, but for whatever reason my
> include
> isn't working.
>
> <?php
> echo $_POST['status_code'];
> if ($_POST['status_code'] = "C") {
> include ('complete_save.php');
> }
> ?>
>
> The echo of my status_code retruns the correct value so the if should
> trigger.
>
> This is my include page:
>
> <?php
>
> echo "test";
>
> ?>
>
> VERY simple, but for some reason is not working????
>
change this line:
if ($_POST['status_code'] = "C") {
to this:
if ($_POST['status_code'] == "C") {
You need 2 equal signs when comparing.
Darren
attached mail follows:
On 5/23/07, Greg Donald <gdonald
gmail.com> wrote:
>
> On 5/23/07, Dan Shirah <mrsquash2
gmail.com> wrote:
> > Okay, I think I'm doing everything right, but for whatever reason my
> include
> > isn't working.
> >
> > <?php
> > echo $_POST['status_code'];
> > if ($_POST['status_code'] = "C") {
>
> == not =
>
>
> --
> Greg Donald
> http://destiney.com/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Greg is absolutely correct, Dan. When using an equal operand in an if()
clause, you have to use double equal signs ( == ). The single equal signs
are for setting variables, not evaluating a statement.
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107
attached mail follows:
On 23/05/07, Dan Shirah <mrsquash2
gmail.com> wrote:
> Okay, I think I'm doing everything right, but for whatever reason my include
> isn't working.
> if ($_POST['status_code'] = "C") {
It's a pretty classic error, Not one that I make very often though -
because I will generally write:
if ('C' = $_POST['status_code']) {
If I wrote that, it would fail instantly - because you can't assign to
a constant, so you use double - or triple, as appropriate - equals.
if ('C' == $_POST['status_code'])
Alister
attached mail follows:
Dan Shirah wrote:
> Okay, I think I'm doing everything right, but for whatever reason my
> include
> isn't working.
>
> <?php
> echo $_POST['status_code'];
> if ($_POST['status_code'] = "C") {
> include ('complete_save.php');
> }
> ?>
>
> The echo of my status_code retruns the correct value so the if should
> trigger.
>
> This is my include page:
>
> <?php
>
> echo "test";
>
> ?>
>
> VERY simple, but for some reason is not working????
>
I think to this point most have missed the actual problem.
imho, it has nothing to do with the following line.
if ( $_POST['status_code'] = "C")
my reason for saying this is this. The preceding condition will always return true.
<?php
$a = 'a';
if ( $a = "C" ) {
echo '$a test success';
}
$c = 'C';
if ( $c == "C" ) {
echo '$c test success';
}
?>
This snippet should prove my point.
so, I would have to say that the problem is not with the condition, but rather the include file itself.
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Unknown
attached mail follows:
On 5/23/07, Jim Lucas <lists
cmsws.com> wrote:
>
> Dan Shirah wrote:
> > Okay, I think I'm doing everything right, but for whatever reason my
> > include
> > isn't working.
> >
> > <?php
> > echo $_POST['status_code'];
> > if ($_POST['status_code'] = "C") {
> > include ('complete_save.php');
> > }
> > ?>
> >
> > The echo of my status_code retruns the correct value so the if should
> > trigger.
> >
> > This is my include page:
> >
> > <?php
> >
> > echo "test";
> >
> > ?>
> >
> > VERY simple, but for some reason is not working????
> >
> I think to this point most have missed the actual problem.
>
> imho, it has nothing to do with the following line.
>
> if ( $_POST['status_code'] = "C")
>
> my reason for saying this is this. The preceding condition will always
> return true.
>
> <?php
>
> $a = 'a';
> if ( $a = "C" ) {
> echo '$a test success';
> }
>
> $c = 'C';
> if ( $c == "C" ) {
> echo '$c test success';
> }
>
> ?>
>
> This snippet should prove my point.
>
> so, I would have to say that the problem is not with the condition, but
> rather the include file itself.
>
> --
> Jim Lucas
>
> "Some men are born to greatness, some achieve greatness,
> and some have greatness thrust upon them."
>
> Unknown
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
That's true as well, Jim.... but the OP included the include file code
at the foot of the message, and it's valid (a simple echo statement).
Dan, try adding this to the top of your code:
ini_set('error_reporting',E_ALL);
If it outputs any errors for you, then you'll know what's up. Also, you
don't need a space in your include command. Just type it out as if it were
a function: include('complete_save.php');
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107
attached mail follows:
Daniel Brown wrote:
> On 5/23/07, Jim Lucas <lists
cmsws.com> wrote:
>>
>> Dan Shirah wrote:
>> > Okay, I think I'm doing everything right, but for whatever reason my
>> > include
>> > isn't working.
>> >
>> > <?php
>> > echo $_POST['status_code'];
>> > if ($_POST['status_code'] = "C") {
>> > include ('complete_save.php');
>> > }
>> > ?>
>> >
>> > The echo of my status_code retruns the correct value so the if should
>> > trigger.
>> >
>> > This is my include page:
>> >
>> > <?php
>> >
>> > echo "test";
>> >
>> > ?>
>> >
>> > VERY simple, but for some reason is not working????
>> >
>> I think to this point most have missed the actual problem.
>>
>> imho, it has nothing to do with the following line.
>>
>> if ( $_POST['status_code'] = "C")
>>
>> my reason for saying this is this. The preceding condition will always
>> return true.
>>
>> <?php
>>
>> $a = 'a';
>> if ( $a = "C" ) {
>> echo '$a test success';
>> }
>>
>> $c = 'C';
>> if ( $c == "C" ) {
>> echo '$c test success';
>> }
>>
>> ?>
>>
>> This snippet should prove my point.
>>
>> so, I would have to say that the problem is not with the condition, but
>> rather the include file itself.
>>
>> --
>> Jim Lucas
>>
>> "Some men are born to greatness, some achieve greatness,
>> and some have greatness thrust upon them."
>>
>> Unknown
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> That's true as well, Jim.... but the OP included the include file code
> at the foot of the message, and it's valid (a simple echo statement).
>
> Dan, try adding this to the top of your code:
> ini_set('error_reporting',E_ALL);
>
> If it outputs any errors for you, then you'll know what's up. Also, you
> don't need a space in your include command. Just type it out as if it were
> a function: include('complete_save.php');
>
but include is not a function. it is a Control Structure
http://us2.php.net/manual/en/language.control-structures.php
imo, the op should not use parentheses when calling it
Look here
http://us2.php.net/manual/en/function.include.php
out of all the examples, only one of them shows include being called with parentheses.
The one that does use the parentheses is an example of when not to use parentheses.
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Unknown
attached mail follows:
On 5/23/07, Daniel Brown <parasane
gmail.com> wrote:
> On 5/23/07, Jim Lucas <lists
cmsws.com> wrote:
> >
> > Dan Shirah wrote:
> > > Okay, I think I'm doing everything right, but for whatever reason my
> > > include
> > > isn't working.
> > >
> > > <?php
> > > echo $_POST['status_code'];
> > > if ($_POST['status_code'] = "C") {
> > > include ('complete_save.php');
> > > }
> > > ?>
> > >
> > > The echo of my status_code retruns the correct value so the if should
> > > trigger.
> > >
> > > This is my include page:
> > >
> > > <?php
> > >
> > > echo "test";
> > >
> > > ?>
> > >
> > > VERY simple, but for some reason is not working????
> > >
> > I think to this point most have missed the actual problem.
> >
> > imho, it has nothing to do with the following line.
> >
> > if ( $_POST['status_code'] = "C")
> >
> > my reason for saying this is this. The preceding condition will always
> > return true.
> >
> > <?php
> >
> > $a = 'a';
> > if ( $a = "C" ) {
> > echo '$a test success';
> > }
> >
> > $c = 'C';
> > if ( $c == "C" ) {
> > echo '$c test success';
> > }
> >
> > ?>
> >
> > This snippet should prove my point.
> >
> > so, I would have to say that the problem is not with the condition, but
> > rather the include file itself.
> >
> > --
> > Jim Lucas
> >
> > "Some men are born to greatness, some achieve greatness,
> > and some have greatness thrust upon them."
> >
> > Unknown
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> That's true as well, Jim.... but the OP included the include file code
> at the foot of the message, and it's valid (a simple echo statement).
>
> Dan, try adding this to the top of your code:
> ini_set('error_reporting',E_ALL);
>
> If it outputs any errors for you, then you'll know what's up. Also, you
> don't need a space in your include command. Just type it out as if it were
> a function: include('complete_save.php');
include is a control structure, I believe it isn't required, but
preferred to use the include without (), like this:
include "complete_save.php";
And of course, you could use the return value of the include function
to check if the include was successful.
Tijnema
attached mail follows:
On 5/23/07, Tijnema <tijnema
gmail.com> wrote:
> include is a control structure, I believe it isn't required, but
> preferred to use the include without (), like this:
> include "complete_save.php";
What variable or escape sequence are you interpolating in that double
quoted string?
include 'complete_save.php';
--
Greg Donald
http://destiney.com/
attached mail follows:
On 5/23/07, Greg Donald <gdonald
gmail.com> wrote:
>
> On 5/23/07, Tijnema <tijnema
gmail.com> wrote:
> > include is a control structure, I believe it isn't required, but
> > preferred to use the include without (), like this:
> > include "complete_save.php";
>
> What variable or escape sequence are you interpolating in that double
> quoted string?
>
> include 'complete_save.php';
>
>
>
> --
> Greg Donald
> http://destiney.com/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I'm aware that it's not a function, I simply said to structure it as
such on the line. And I believe that it's a matter of preference as to
whether or not one should use the parentheses. As far as I know, it doesn't
insinuate anything differently by enclosing the include file, such as C does
when going between "#include <stdio.h>" and #include "src/myheader.h"
I could be wrong though.... good time to re-acquaint myself with and
brush up on my fundamentals.
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107
attached mail follows:
Thank you for all of the quick responses. I guess jumping between
ColdFusion, PHP and Informix all day long got the better of me.
Thanks again!
Dan
On 5/23/07, Daniel Brown <parasane
gmail.com> wrote:
>
> On 5/23/07, Greg Donald <gdonald
gmail.com> wrote:
> >
> > On 5/23/07, Tijnema <tijnema
gmail.com> wrote:
> > > include is a control structure, I believe it isn't required, but
> > > preferred to use the include without (), like this:
> > > include "complete_save.php";
> >
> > What variable or escape sequence are you interpolating in that double
> > quoted string?
> >
> > include 'complete_save.php';
> >
> >
> >
> > --
> > Greg Donald
> > http://destiney.com/
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> I'm aware that it's not a function, I simply said to structure it as
> such on the line. And I believe that it's a matter of preference as to
> whether or not one should use the parentheses. As far as I know, it
> doesn't
> insinuate anything differently by enclosing the include file, such as C
> does
> when going between "#include <stdio.h>" and #include "src/myheader.h"
>
> I could be wrong though.... good time to re-acquaint myself with and
> brush up on my fundamentals.
>
> --
> Daniel P. Brown
> [office] (570-) 587-7080 Ext. 272
> [mobile] (570-) 766-8107
>
attached mail follows:
Hi,
I have an issue with a particular if statement when I check 3 form fields
for their value. The problem is no matter what input is entered in the
fields the output is the same. I only added the 3 fields in question of the
form to reduce heartache for the readers of this post.
Output always reads:
Please correct the following "State" fields. Example: Enter state as
Illinois or IL not ILLINOIS.
Consumer State
School State
Store State
The code is:
<?php
$label_array = array ("conName" => "Consumer Name",
"conAddress" => "Consumer Address",
"conCity" => "Consumer City",
"conState" => "Consumer State",
"conZip" => "Consumer Zip Code",
"conPhone" => "Consumer Phone",
"schName" => "School Name",
"schAddress" => "School Address",
"schCity" => "School City",
"schState" => "School State",
"schZip" => "School Zip Code",
"strName" => "Store Name",
"strCity" => "Store City",
"strState" => "Store State");
//check data fields for correct data
foreach($_POST as $field => $value)
{
if($field == "conState" || $field == "schState" || $field == "strState")
//if these 3 fields are entered
{
if($value != 'Alabama' || $value!= 'AL' || $value != 'Alaska' || $value!=
'AK' || $value != 'Arizona' || $value!= 'AZ' || $value != 'Arkansas' ||
$value!= 'AR' || $value != 'California' || $value!= 'CA' || $value !=
'Colorado' || $value!= 'CO' || $value != 'Conneticut' || $value!= 'CT' ||
$value != 'Delaware' || $value!= 'DE' || $value != 'Florida' || $value!=
'FL' || $value != 'Georgia' || $value!= 'GA' || $value != 'Hawaii' ||
$value!= 'HI' || $value != 'Idaho' || $value!= 'ID' || $value !=
'Illinois' || $value!= 'IL' || $value != 'Inidiana' || $value!= 'IN' ||
$value != 'Iowa' || $value!= 'IA' || $value != 'Kansas' || $value!= 'KS' ||
$value != 'Kentucky' || $value!= 'KY' || $value != 'Louisiana' || $value!=
'LA' || $value != 'Maine' || $value!= 'ME' || $value != 'Maryland' ||
$value!= 'MD' || $value != 'Massachusetts' || $value!= 'MA' || $value !=
'Michigan' || $value!= 'MI' || $value != 'Minnesota' || $value!= 'MN' ||
$value != 'Mississippi' || $value!= 'MS' || $value != 'Missouri' || $value!=
'MO' || $value != 'Montana' || $value!= 'MT' || $value != 'Nebraska' ||
$value!= 'NE' || $value != 'Nevada' || $value!= 'NV' || $value != 'New
Hampshire' || $value!= 'NH' || $value != 'New Jersey' || $value!= 'NJ' ||
$value != 'New Mexico' || $value!= 'NM' || $value != 'New York' || $value!=
'NY' || $value != 'North Carolina' || $value!= 'NC' || $value != 'North
Dakota' || $value!= 'ND' || $value != 'Ohio' || $value!= 'OH' || $value !=
'Oklahoma' || $value!= 'OK' || $value != 'Oregon' || $value!= 'OR' || $value
!= 'Pennsylvania' || $value!= 'PA' || $value != 'Rhode Island' || $value!=
'RI' || $value != 'South Carolina' || $value!= 'SC' || $value != 'South
Dakota' || $value!= 'SD' || $value != 'Tennesee' || $value!= 'TN' || $value
!= 'Texas' || $value!= 'TX' || $value != 'Utah' || $value!= 'UT' || $value
!= 'Vermont' || $value!= 'VT' || $value != 'Virginia' || $value!= 'VA' ||
$value != 'Washington' || $value!= 'WA' || $value != 'West Virginia'
||$value!= 'WV' || $value != 'Wisconsin' || $value!= 'WI' || $value !=
'Wyoming' || $value!= 'WY') //if they don't the match these
{
$state[$field] = "badstate"; //then
}
}//end check
}
if(
sizeof($state) > 0) //check size of array and display error message
{
echo "<div class='ermess1'><br />Please correct the following \"State\"
fields. Example: Enter state as Illinois or IL not
ILLINOIS.</div>";
foreach($state as $field => $value) // display the fields where input is
incorrect
{
echo " <div>{$label_array[$field]}</div>";
}
}
echo " <link href='css/SOS.css' rel='stylesheet' type='text/css' />
<form id='process' method='post' action='form.php'>
<label for='conState' class='stateLabel'> *State:</label>
<input name='conState' type='text' class='state' id='textfield'
value='{$_POST['conState']}' />
<label for='schState' class='stateLabel'>*State:</label>
<input name='schState' type='text' class='state' id='textfield'
value='{$_POST['schState']}'/>
<label for='strStat' class='stateLabel'>*State:</label>
<input name='strState' type='text' class='state' id='textfield'
value='{$_POST['strState']}' />
<br />
<br />
<br />
<label for='Reset'></label>
<input type='reset' name='reset' value='Reset' id='Submit'/>
<label for='Sumbit'></label>
<input type='submit' name='submit' value='Submit' id='Reset'/>
</form>"; ?>
attached mail follows:
On Wed, 2007-05-23 at 07:41 -0500, kvigor wrote:
>
> if($field == "conState" || $field == "schState" || $field == "strState")
> //if these 3 fields are entered
> {
> if($value != 'Alabama' || $value!= 'AL' || $value != 'Alaska' || $value!=
> 'AK' || $value != 'Arizona' || $value!= 'AZ' || $value != 'Arkansas' ||
> $value!= 'AR' || $value != 'California' || $value!= 'CA' || $value !=
> 'Colorado' || $value!= 'CO' || $value != 'Conneticut' || $value!= 'CT' ||
> $value != 'Delaware' || $value!= 'DE' || $value != 'Florida' || $value!=
> 'FL' || $value != 'Georgia' || $value!= 'GA' || $value != 'Hawaii' ||
> $value!= 'HI' || $value != 'Idaho' || $value!= 'ID' || $value !=
> 'Illinois' || $value!= 'IL' || $value != 'Inidiana' || $value!= 'IN' ||
> $value != 'Iowa' || $value!= 'IA' || $value != 'Kansas' || $value!= 'KS' ||
> $value != 'Kentucky' || $value!= 'KY' || $value != 'Louisiana' || $value!=
> 'LA' || $value != 'Maine' || $value!= 'ME' || $value != 'Maryland' ||
> $value!= 'MD' || $value != 'Massachusetts' || $value!= 'MA' || $value !=
> 'Michigan' || $value!= 'MI' || $value != 'Minnesota' || $value!= 'MN' ||
> $value != 'Mississippi' || $value!= 'MS' || $value != 'Missouri' || $value!=
> 'MO' || $value != 'Montana' || $value!= 'MT' || $value != 'Nebraska' ||
> $value!= 'NE' || $value != 'Nevada' || $value!= 'NV' || $value != 'New
> Hampshire' || $value!= 'NH' || $value != 'New Jersey' || $value!= 'NJ' ||
> $value != 'New Mexico' || $value!= 'NM' || $value != 'New York' || $value!=
> 'NY' || $value != 'North Carolina' || $value!= 'NC' || $value != 'North
> Dakota' || $value!= 'ND' || $value != 'Ohio' || $value!= 'OH' || $value !=
> 'Oklahoma' || $value!= 'OK' || $value != 'Oregon' || $value!= 'OR' || $value
> != 'Pennsylvania' || $value!= 'PA' || $value != 'Rhode Island' || $value!=
> 'RI' || $value != 'South Carolina' || $value!= 'SC' || $value != 'South
> Dakota' || $value!= 'SD' || $value != 'Tennesee' || $value!= 'TN' || $value
> != 'Texas' || $value!= 'TX' || $value != 'Utah' || $value!= 'UT' || $value
> != 'Vermont' || $value!= 'VT' || $value != 'Virginia' || $value!= 'VA' ||
> $value != 'Washington' || $value!= 'WA' || $value != 'West Virginia'
> ||$value!= 'WV' || $value != 'Wisconsin' || $value!= 'WI' || $value !=
> 'Wyoming' || $value!= 'WY') //if they don't the match these
I'm going to vomit after seeing your if statement's condition. Anyways,
you want && between all those and NOT ||.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
2007. 05. 23, szerda keltezéssel 07.41-kor kvigor ezt Ãrta:
> Hi,
>
> I have an issue with a particular if statement when I check 3 form fields
> for their value. The problem is no matter what input is entered in the
> fields the output is the same. I only added the 3 fields in question of the
> form to reduce heartache for the readers of this post.
>
> Output always reads:
> Please correct the following "State" fields. Example: Enter state as
> Illinois or IL not ILLINOIS.
> Consumer State
>
> School State
>
> Store State
>
> The code is:
> <?php
> $label_array = array ("conName" => "Consumer Name",
> "conAddress" => "Consumer Address",
> "conCity" => "Consumer City",
> "conState" => "Consumer State",
> "conZip" => "Consumer Zip Code",
> "conPhone" => "Consumer Phone",
> "schName" => "School Name",
> "schAddress" => "School Address",
> "schCity" => "School City",
> "schState" => "School State",
> "schZip" => "School Zip Code",
> "strName" => "Store Name",
> "strCity" => "Store City",
> "strState" => "Store State");
>
> //check data fields for correct data
> foreach($_POST as $field => $value)
> {
> if($field == "conState" || $field == "schState" || $field == "strState")
> //if these 3 fields are entered
> {
> if($value != 'Alabama' || $value!= 'AL' || $value != 'Alaska' || $value!=
> 'AK' || $value != 'Arizona' || $value!= 'AZ' || $value != 'Arkansas' ||
> $value!= 'AR' || $value != 'California' || $value!= 'CA' || $value !=
> 'Colorado' || $value!= 'CO' || $value != 'Conneticut' || $value!= 'CT' ||
> $value != 'Delaware' || $value!= 'DE' || $value != 'Florida' || $value!=
> 'FL' || $value != 'Georgia' || $value!= 'GA' || $value != 'Hawaii' ||
> $value!= 'HI' || $value != 'Idaho' || $value!= 'ID' || $value !=
> 'Illinois' || $value!= 'IL' || $value != 'Inidiana' || $value!= 'IN' ||
> $value != 'Iowa' || $value!= 'IA' || $value != 'Kansas' || $value!= 'KS' ||
> $value != 'Kentucky' || $value!= 'KY' || $value != 'Louisiana' || $value!=
> 'LA' || $value != 'Maine' || $value!= 'ME' || $value != 'Maryland' ||
> $value!= 'MD' || $value != 'Massachusetts' || $value!= 'MA' || $value !=
> 'Michigan' || $value!= 'MI' || $value != 'Minnesota' || $value!= 'MN' ||
> $value != 'Mississippi' || $value!= 'MS' || $value != 'Missouri' || $value!=
> 'MO' || $value != 'Montana' || $value!= 'MT' || $value != 'Nebraska' ||
> $value!= 'NE' || $value != 'Nevada' || $value!= 'NV' || $value != 'New
> Hampshire' || $value!= 'NH' || $value != 'New Jersey' || $value!= 'NJ' ||
> $value != 'New Mexico' || $value!= 'NM' || $value != 'New York' || $value!=
> 'NY' || $value != 'North Carolina' || $value!= 'NC' || $value != 'North
> Dakota' || $value!= 'ND' || $value != 'Ohio' || $value!= 'OH' || $value !=
> 'Oklahoma' || $value!= 'OK' || $value != 'Oregon' || $value!= 'OR' || $value
> != 'Pennsylvania' || $value!= 'PA' || $value != 'Rhode Island' || $value!=
> 'RI' || $value != 'South Carolina' || $value!= 'SC' || $value != 'South
> Dakota' || $value!= 'SD' || $value != 'Tennesee' || $value!= 'TN' || $value
> != 'Texas' || $value!= 'TX' || $value != 'Utah' || $value!= 'UT' || $value
> != 'Vermont' || $value!= 'VT' || $value != 'Virginia' || $value!= 'VA' ||
> $value != 'Washington' || $value!= 'WA' || $value != 'West Virginia'
> ||$value!= 'WV' || $value != 'Wisconsin' || $value!= 'WI' || $value !=
> 'Wyoming' || $value!= 'WY') //if they don't the match these
you should replace all those || -s above with && -s since you want to be
sure it does not match any of the states
greets
Zoltán Németh
>
> {
> $state[$field] = "badstate"; //then
> }
> }//end check
> }
>
> if(
sizeof($state) > 0) //check size of array and display error message
> {
> echo "<div class='ermess1'><br />Please correct the following \"State\"
> fields. Example: Enter state as Illi