Re: [PHP] Help with php server and sockets

2007-05-23 Thread Robert Cummings
On Wed, 2007-05-23 at 16:24 -0700, Adz07 wrote:
 i want to set up a php server that can communicate with a client (CLI PHP
 Script). I can setup the server socket fine. What i need to know is whether
 it is possible for the client to call a function in the servers php code and
 the server return the data ready for the client to process??
 
 To start, if anyone could tell me how to use a socket connection from a CLI
 client to a CLI server to retreive an array (it'll do for now :)  if its
 even possible that is!
 
 Sorry if thats not the best explanation!

You just need some sort of agreed upon protocol. For instance the server
might treat any input from the client that is terminated by a newline as
a command. So for instance the client might send:

get array

Then the server would parse the request and realize that the client
wants an array. Then it would echo the data in some manner understood by
the client (XML, SOAP, PHP serialized data, JSON, etc). The server would
also send some kind of terminator indicating the end of the data (which
could be as simple as closing the connection). Then the client just
needs to parse what it received.

Hope that helps.

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

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



[PHP] ftp_put() problem??

2007-05-23 Thread Al

Can anyone help with this.  On a Linux/Apache server.

I want to simply copy a file with ftp_put() from one dir to another.

To make certain I'm pointing to the correct dirs, I'm using this:
print_r(ftp_nlist($conn_id, FTP_EP_DIR)); //It is the correct dir
print_r(ftp_nlist($conn_id, $rpdir));   //It is the correct dir

Then I'm:
ftp_put($conn_id, FTP_EP_DIR .'/' . $file, $rpdir. '/' . $file, FTP_ASCII);

Error msg:
Warning: ftp_put(/home/x/public_html/test/EditPageIndexer.php) [function.ftp-put]: failed to open stream: No such 
file or directory in /home/x/public_html/EditPage/ep_functions.inc on line 227


And the files are not copied.

Owner and permissions are correct.  I can make a new dir [mkdir()] in the 
destination dir without a problem.

Manual is confusing when it calls the files remote and local.

Thanks

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



[PHP] help with multi dimensional arrays

2007-05-23 Thread James Lockie

I get a syntax error on strlen.


   $newTypes = array();
   $newTypes[0] = array();
   $newTypes[0][0] = Starting with
   $newTypes[0][1] = strlen( $newTypes[0][0] );

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



Re: [PHP] help with multi dimensional arrays

2007-05-23 Thread Micky Hulse

Looks like you are missing a comma on line 3.

James Lockie wrote:

I get a syntax error on strlen.


   $newTypes = array();
   $newTypes[0] = array();
   $newTypes[0][0] = Starting with
   $newTypes[0][1] = strlen( $newTypes[0][0] );





--
Wishlists: http://snipurl.com/1gqpj
   Switch: http://browsehappy.com/
 BCC?: http://snipurl.com/w6f8
   My: http://del.icio.us/mhulse

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



Re: [PHP] help with multi dimensional arrays

2007-05-23 Thread Paul Novitski



Looks like you are missing a comma on line 3.

James Lockie wrote:

I get a syntax error on strlen.

   $newTypes = array();
   $newTypes[0] = array();
   $newTypes[0][0] = Starting with
   $newTypes[0][1] = strlen( $newTypes[0][0] );



Missing semicolon;

Paul 


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



Re: [PHP] Cannot access file on Network Drive (Windows 2003)

2007-05-23 Thread Jim Lucas

Rahul Sitaram Johari wrote:

Didn't help. Tried X:\\Transfer\\test.dbf
Still can't access the file.


On 5/23/07 3:11 PM, Tijnema [EMAIL PROTECTED] wrote:


The \ is an escape token, and you should use \\ instead.

Try X:\\Transfer\\test.dbf instead.

Tijnema

ps. Please don't top post.



Try a single forward slash

X:/Transfer/test.dbf

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



Re: [PHP] help with multi dimensional arrays

2007-05-23 Thread James Lockie

Paul Novitski wrote:



Looks like you are missing a comma on line 3.

James Lockie wrote:

I get a syntax error on strlen.

   $newTypes = array();
   $newTypes[0] = array();
   $newTypes[0][0] = Starting with
   $newTypes[0][1] = strlen( $newTypes[0][0] );



Missing semicolon;

Paul

Argh, that is the worst error. :-(
The error messages in PHP suck.

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



Re: [PHP] Cannot access file on Network Drive (Windows 2003)

2007-05-23 Thread Jim Lucas

Rahul Sitaram Johari wrote:

Ave,

Apache 2.2, PHP5  mySQL 5 on Windows 2003.
I have some files sitting on a Network Drive accessible on the Windows 2003
Server. But my php script is not able to open the files.

Let¹s say there¹s a database on X:\Transfer\test.dbf
If I use:

$db = dbase_open(³X:\Transfer\test.dbf², 0);


echo gettype($db);

what does this return?



It is not able to open the database. The X: Drive is a network drive.
Any clues on how to make this happen?

Thanks.


~~~
Rahul Sitaram Johari
CEO, Twenty Four Seventy Nine Inc.

W: http://www.rahulsjohari.com
E: [EMAIL PROTECTED]

³I morti non sono piu soli ... The dead are no longer lonely²





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



Re: [PHP] help with multi dimensional arrays

2007-05-23 Thread Greg Donald

On 5/23/07, James Lockie [EMAIL PROTECTED] wrote:

Argh, that is the worst error. :-(
The error messages in PHP suck.


When I run your code it says:

Parse error: syntax error, unexpected T_VARIABLE in
/opt/local/apache2/htdocs/missing.php on line 5

If you did not get a similar error you may need to increase your error
reporting level and ensure your ability to actually see the errors as
well.  This is what I use in development:

error_reporting( E_ALL );
ini_set( 'display_errors', 1 );
ini_set( 'log_errors', 1 );


--
Greg Donald
http://destiney.com/

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



[PHP] Database error: Invalid SQL:

2007-05-23 Thread wisuttorn

I have a problem  please help me
when i loged in to egroup this show 
Database error: Invalid SQL: SELECT DISTINCT
egw_cal_repeats.*,egw_cal.*,cal_start,cal_end,cal_recur_date FROM egw_cal
JOIN egw_cal_dates ON egw_cal.cal_id=egw_cal_dates.cal_id JOIN egw_cal_user
ON egw_cal.cal_id=egw_cal_user.cal_id LEFT JOIN egw_cal_repeats ON
egw_cal.cal_id=egw_cal_repeats.cal_id WHERE (cal_user_type='u' AND
cal_user_id IN (6,-1)) AND cal_status != 'R' AND 1179939600  cal_end AND
cal_start  1180025999 AND (recur_type IS NULL AND cal_recur_date=0 OR
cal_recur_date=cal_start) ORDER BY cal_start
mysql Error: 1064 (You have an error in your SQL syntax near 'ON
egw_cal.cal_id=egw_cal_dates.cal_id JOIN egw_cal_user ON
egw_cal.cal_id=egw_c' at line 1)

File:
/home/lecturer/account/wisuttorn/public_html/work/calendar/inc/class.socal.inc.php
Line: 372
Function: egw_db::select / socal::search / bocal::search / uiviews::day /
uiviews::index / execmethod(calendar.uiviews.index)

Session halted.

How can i fix this problem? 
Thank you

 

-- 
View this message in context: 
http://www.nabble.com/Database-error%3A-Invalid-SQL%3A-tf3807948.html#a10777304
Sent from the PHP - General mailing list archive at Nabble.com.

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



Re: [PHP] help with multi dimensional arrays

2007-05-23 Thread Steve Finkelstein
Might I suggest using an IDE to develop your code in. It would be able
to spot simple oversights such as syntax errors. I personally use Zend
Studio, however if you aren't looking to invest in a license, there are
plenty of open source solutions out there.

Cheers,

- sf

James Lockie wrote:
 Paul Novitski wrote:

 Looks like you are missing a comma on line 3.

 James Lockie wrote:
 I get a syntax error on strlen.

$newTypes = array();
$newTypes[0] = array();
$newTypes[0][0] = Starting with
$newTypes[0][1] = strlen( $newTypes[0][0] );


 Missing semicolon;

 Paul
 Argh, that is the worst error. :-(
 The error messages in PHP suck.
 

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



Re: [PHP] Database error: Invalid SQL:

2007-05-23 Thread Chris

wisuttorn wrote:

I have a problem  please help me
when i loged in to egroup this show 
Database error: Invalid SQL: SELECT DISTINCT
egw_cal_repeats.*,egw_cal.*,cal_start,cal_end,cal_recur_date FROM egw_cal
JOIN egw_cal_dates ON egw_cal.cal_id=egw_cal_dates.cal_id JOIN egw_cal_user
ON egw_cal.cal_id=egw_cal_user.cal_id LEFT JOIN egw_cal_repeats ON
egw_cal.cal_id=egw_cal_repeats.cal_id WHERE (cal_user_type='u' AND
cal_user_id IN (6,-1)) AND cal_status != 'R' AND 1179939600  cal_end AND
cal_start  1180025999 AND (recur_type IS NULL AND cal_recur_date=0 OR
cal_recur_date=cal_start) ORDER BY cal_start
mysql Error: 1064 (You have an error in your SQL syntax near 'ON
egw_cal.cal_id=egw_cal_dates.cal_id JOIN egw_cal_user ON
egw_cal.cal_id=egw_c' at line 1)


I guess that whatever database you are using doesn't allow 'JOIN' as a 
join type.


Usually you need to specify the type: inner join, left join, right join, 
straight join etc.


Ask your specific database list about it.

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

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



[PHP] problem with composing URL with GET Variables

2007-05-23 Thread Angelo Zanetti

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=275width=375quality=65;


However when I look at the URL that gets sent its as follows:

getImage.php?imageid=10amp;height=275amp;width=375amp;quality=65

Which is obviously incorrect.

So I tried:

$getImageURL = html_entity_decode(getImage.php?imageid=. 
$imageID.height=275width=375quality=65);


But that doesn't seem to be working. .  . As the html_entity_decode 
should the amp 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.

--

Angelo Zanetti
Systems developer


*Telephone:* +27 (021) 469 1052
*Mobile:*   +27 (0) 72 441 3355
*Fax:*+27 (0) 86 681 5885
*
Web:* http://www.zlogic.co.za
*E-Mail:* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]

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



[PHP] SOLVED Re: [PHP] problem with composing URL with GET Variables

2007-05-23 Thread Angelo Zanetti

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=275width=375quality=65;


However when I look at the URL that gets sent its as follows:

getImage.php?imageid=10amp;height=275amp;width=375amp;quality=65

Which is obviously incorrect.

So I tried:

$getImageURL = html_entity_decode(getImage.php?imageid=. 
$imageID.height=275width=375quality=65);


But that doesn't seem to be working. .  . As the html_entity_decode 
should the amp 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.



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



Re: [PHP] convert numerical day of week

2007-05-23 Thread Robin Vickery

On 22/05/07, Robert Cummings [EMAIL PROTECTED] wrote:

On Tue, 2007-05-22 at 13:47 -0500, Greg Donald wrote:
 On 5/22/07, Robert Cummings [EMAIL PROTECTED] 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

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



Re: [PHP] Re: convert numerical day of week

2007-05-23 Thread Stut

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

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



[PHP] System wide variable

2007-05-23 Thread Darren Whitlen

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

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



Re: [PHP] System wide variable

2007-05-23 Thread Stut

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

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



Re: [PHP] System wide variable

2007-05-23 Thread Darren Whitlen

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

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



Re: [PHP] System wide variable

2007-05-23 Thread John Comerford

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



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



Re: [PHP] System wide variable

2007-05-23 Thread Stut

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

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



Re: [PHP] System wide variable

2007-05-23 Thread Darren Whitlen

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!

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



Re: [PHP] System wide variable

2007-05-23 Thread Sancar Saran
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

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



[PHP] Re: PHP Data Mining/Data Scraping

2007-05-23 Thread Shannon Whitty
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 [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 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 [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
 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 

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



Re: [PHP] PHP Data Mining/Data Scraping

2007-05-23 Thread Shannon Whitty
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 [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 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=data1fdata_2=data2

 Send this url to your suppler using file_get_contents:

  $return_string = 
 file_get_contents(http://my.supplier.com?fdata_1=data1fdata_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_1formdata_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/ 

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



Re: [PHP] PHP Data Mining/Data Scraping

2007-05-23 Thread Shannon Whitty
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 [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 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=data1fdata_2=data2

 Send this url to your suppler using file_get_contents:

  $return_string =
 file_get_contents(http://my.supplier.com?fdata_1=data1fdata_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_1formdata_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/

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



[PHP] Re: System wide variable

2007-05-23 Thread Kostas Papadimitriou

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+singletonie=utf-8oe=utf-8aq=trls=org.mozilla:en-US:officialclient=firefox-a)


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



Re: [PHP] PHP Data Mining/Data Scraping

2007-05-23 Thread Shannon Whitty
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 [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 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=data1fdata_2=data2

 Send this url to your suppler using file_get_contents:

  $return_string =
 file_get_contents(http://my.supplier.com?fdata_1=data1fdata_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_1formdata_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/

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



Re: [PHP] PHP Data Mining/Data Scraping

2007-05-23 Thread Shannon Whitty
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 [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 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? 

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



[PHP] Creating process and do actions with signals

2007-05-23 Thread lists

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

?

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



[PHP] php upload files

2007-05-23 Thread kats Ant
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+worldmkt=en-USform=QBRE

Re: [PHP] System wide variable

2007-05-23 Thread Jochem Maas
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
 

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



[PHP] Re: php upload files

2007-05-23 Thread itoctopus
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 [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
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+worldmkt=en-USform=QBRE 

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



[PHP] How to eject cd-rom with php code?

2007-05-23 Thread Chetan Graham
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



RE: [PHP] How to eject cd-rom with php code?

2007-05-23 Thread Jim Moseby
 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

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



RE: [PHP] How to eject cd-rom with php code?

2007-05-23 Thread Jim Moseby
  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

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



Re: [PHP] How to eject cd-rom with php code?

2007-05-23 Thread Andrew Brampton
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 [EMAIL PROTECTED]

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




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



Re: [PHP] How to eject cd-rom with php code?

2007-05-23 Thread Zoltán Németh
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
 

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



RE: [PHP] How to eject cd-rom with php code?

2007-05-23 Thread Edward Kay


 -Original Message-
 From: Chetan Graham [mailto:[EMAIL PROTECTED]
 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

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



Re: [PHP] How to eject cd-rom with php code?

2007-05-23 Thread Chris Boget

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

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



Re: [PHP] convert numerical day of week

2007-05-23 Thread Robert Cummings
On Wed, 2007-05-23 at 10:31 +0300, Robin Vickery wrote:
 On 22/05/07, Robert Cummings [EMAIL PROTECTED] wrote:
  On Tue, 2007-05-22 at 13:47 -0500, Greg Donald wrote:
   On 5/22/07, Robert Cummings [EMAIL PROTECTED] 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.  |
`'

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



[PHP] Embedded Image from Database

2007-05-23 Thread Bagus Nugroho
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

 



Re: [PHP] convert numerical day of week

2007-05-23 Thread Greg Donald

On 5/23/07, Robin Vickery [EMAIL PROTECTED] wrote:

they're all bloated:

print jddayofweek($day_number, 1);


Must go --enable-calendar now  :)



--
Greg Donald
http://destiney.com/

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



[PHP] Include???

2007-05-23 Thread Dan Shirah

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


[PHP] Re: Include???

2007-05-23 Thread Darren Whitlen

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

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



Re: [PHP] convert numerical day of week

2007-05-23 Thread Robert Cummings
On Wed, 2007-05-23 at 09:23 -0500, Greg Donald wrote:
 On 5/23/07, Robin Vickery [EMAIL PROTECTED] 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.  |
`'

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



Re: [PHP] Include???

2007-05-23 Thread Daniel Brown

On 5/23/07, Greg Donald [EMAIL PROTECTED] wrote:


On 5/23/07, Dan Shirah [EMAIL PROTECTED] 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


Re: [PHP] Form Validation Issues

2007-05-23 Thread Robert Cummings
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.  |
`'

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



[PHP] zend framework

2007-05-23 Thread Greg Donald

Has anyone looked at the Zend Framework lately?

http://framework.zend.com/manual

I've been playing with a few parts of it off and on the past couple of
days.  It seems really heavy overall and there is no Javascript
integration anywhere.  Nothing on the roadmap about Javascript either:

http://framework.zend.com/roadmap

It might be worth using if it actually did something better than my
current toolset.  Right now it really doesn't.


--
Greg Donald
http://destiney.com/

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



Re: [PHP] Form Validation Issues

2007-05-23 Thread Zoltán Németh
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.nbsp;nbsp;Example: Enter state as Illinois or IL not 
 ILLINOIS./div;
 
   foreach($state as $field = $value) // display the fields where input is 
 incorrect
   {
echo nbsp;nbsp;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; ?
 

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



Re: [PHP] Form Validation Issues

2007-05-23 Thread Greg Donald

On 5/23/07, kvigor [EMAIL PROTECTED] wrote:

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 really look into learning in_array() for stuff like this.

Your logic seems weird to me, using != with a bunch of ||'s, is it
possible you need to  those together?


 {
   $state[$field] = badstate; //then
 }
  }//end check
}

 if(@sizeof($state)  0)  //check size of array and display error message


I can't think of a good reason to suppress an error coming from
sizeof().  It will return zero for anything that is unset.  You might
switch to count(), it's one character less to type than sizeof() and
much more common in other programming languages.


 echo div class='ermess1'br /Please correct the following \State\
fields.nbsp;nbsp;Example: Enter state as Illinois or IL not
ILLINOIS./div;

  foreach($state as $field = $value) // display the fields where input is
incorrect
  {
   echo nbsp;nbsp;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; ?



Looks like you just need to do some logic debugging to get things
wired up how you want.

Try adding this to the top of your script so the post action shows you
more info:

if( isset( $_POST['submit'] ) )
{
 echo 'pre';
 print_r( $_POST );
 echo '/pre';
}


--
Greg Donald
http://destiney.com/

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



Re: [PHP] Form Validation Issues

2007-05-23 Thread kvigor
Thanks Dan,

Work like a dream.  I solute you.

Daniel Brown [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On 5/23/07, kvigor [EMAIL PROTECTED] wrote:

 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.nbsp;nbsp;Example: Enter state as Illinois or IL not
 ILLINOIS./div;

   foreach($state as $field = $value) // display the fields where input 
 is
 incorrect
   {
echo nbsp;nbsp;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; ?

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



You're doing all OR statements.  This means if it's not this or it's
 not this or it's not this or it's not this

Replace 

Re: [PHP] Form Validation Issues

2007-05-23 Thread Robert Cummings
On Wed, 2007-05-23 at 10:17 -0500, kvigor wrote:
 Thanks Dan,
 
 Work like a dream.  I solute you.

Don't look now Dan... but you're dissolving!!!  *hehe*

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

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



Re: [PHP] Include???

2007-05-23 Thread Jim Lucas

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



Re: [PHP] Form Validation Issues

2007-05-23 Thread Robert Cummings
On Wed, 2007-05-23 at 10:10 -0500, Greg Donald wrote:
 On 5/23/07, kvigor [EMAIL PROTECTED] wrote:
  [-- SNIPPITY SNIP SNIP --]
  != '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 really look into learning in_array() for stuff like this.

Wouldn't that slow things down and increase the memory footprint? ;)

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

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



Re: [PHP] Include???

2007-05-23 Thread Daniel Brown

On 5/23/07, Jim Lucas [EMAIL PROTECTED] 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


Re: [PHP] Form Validation Issues

2007-05-23 Thread Greg Donald

On 5/23/07, Robert Cummings [EMAIL PROTECTED] wrote:

 You should really look into learning in_array() for stuff like this.

Wouldn't that slow things down and increase the memory footprint? ;)


It'd be interesting to see a benchmark.


--
Greg Donald
http://destiney.com/

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



Re: [PHP] Form Validation Issues

2007-05-23 Thread Jim Lucas

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



Ok, here is something that might help you.

$states['AL'] = 'Alabama';
$states['AK'] = 'Alaska';
$states['AZ'] = 'Arizona';
$states['AR'] = 'Arkansas';
$states['CA'] = 'California';
$states['CO'] = 'Colorado';
$states['CT'] = 'Conneticut';
$states['DE'] = 'Delaware';
$states['FL'] = 'Florida';
$states['GA'] = 'Georgia';
$states['HI'] = 'Hawaii';
$states['ID'] = 'Idaho';
$states['IL'] = 'Illinois';
$states['IN'] = 'Inidiana';
$states['IA'] = 'Iowa';
$states['KS'] = 'Kansas';
$states['KY'] = 'Kentucky';
$states['LA'] = 'Louisiana';
$states['ME'] = 'Maine';
$states['MD'] = 'Maryland';
$states['MA'] = 'Massachusetts';
$states['MI'] = 'Michigan';
$states['MN'] = 'Minnesota';
$states['MS'] = 'Mississippi';
$states['MO'] = 'Missouri';
$states['MT'] = 'Montana';
$states['NE'] = 'Nebraska';
$states['NV'] = 'Nevada';
$states['NH'] = 'New Hampshire';
$states['NJ'] = 'New Jersey';
$states['NM'] = 'New Mexico';
$states['NY'] = 'New York';
$states['NC'] = 'North Carolina';
$states['ND'] = 'North Dakota';
$states['OH'] = 'Ohio';
$states['OK'] = 'Oklahoma';
$states['OR'] = 'Oregon';
$states['PA'] = 'Pennsylvania';
$states['RI'] = 'Rhode Island';
$states['SC'] = 'South Carolina';
$states['SD'] = 'South Dakota';
$states['TN'] = 'Tennesee';
$states['TX'] = 'Texas';
$states['UT'] = 'Utah';
$states['VT'] = 'Vermont';
$states['VA'] = 'Virginia';
$states['WA'] = 'Washington';
$states['WV'] = 'West Virginia';
$states['WI'] = 'Wisconsin';
$states['WY'] = 'Wyoming';

now use this like this

if ( !isset($states[$value])  !in_array($value, $states) ) {
// do something because I can't find the state
}

use something like this so your logical errors will be reduced

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



Re: [PHP] Form Validation Issues

2007-05-23 Thread Robert Cummings
On Wed, 2007-05-23 at 10:55 -0500, Greg Donald wrote:
 On 5/23/07, Robert Cummings [EMAIL PROTECTED] wrote:
   You should really look into learning in_array() for stuff like this.
 
  Wouldn't that slow things down and increase the memory footprint? ;)
 
 It'd be interesting to see a benchmark.

You're good at those... but I'll pull off the top of my head that the
array overhead ought to require more memory due to the need for indexes
(maybe) but at least for internal tree structure. The speed ought to
slow down since the array will need to be created and built. Then using
in_array() I'm guessing is a linear search since values aren't sorted
(at least I can't image the values being sorted). You could probably
overcome the speed issue using an array with the values as indexes
instead of the values and using isset() to check for membership of the
value :)

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

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



[PHP] Re: Form Validation Issues

2007-05-23 Thread Jared Farrish

Having a giant conditional statement such as the one you have posted is a
real problem for many different reasons. Below is a simple states class that
allows you to test for a state using a couple of different checks (such as
making both comparables lower or upper case). One major issue with the code
block you posted (which may or may not be a problem on your end, it could be
the email software), but these two are not comparable:

code
$v = New Hampshire;
$x = New
Hampshire;
if ($v === $x) {
   echo(pre$v is exactly equal to $x/pre);
} elseif ($v == $x) {
   echo(pre$v is loosely equal to $x/pre);
} else {
   echo(pre$v is not exactly equal to $x/pre);
}
/code
This will produce: New Hampshire is not exactly equal to New
Hampshire

A better way to test a conditional (whether complex and/or lengthy) is to
wrap it in either a function, or a class method, like so:

code
?php
class States {
   var $suggest = null;
   var $states = Array(
   'alabama'=true,'al'=true,
   'alaska'=true,'ak'=true,
   'arizona'=true,'az'=true,
   'arkansas'=true,'ar'=true,
   'california'=true,'ca'=true,
   'colorado'=true,'co'=true,
   'connecticut'=true,'ct'=true,
   'delaware'=true,'de'=true,
   'florida'=true,'fl'=true,
   'georgia'=true,'ga'=true,
   'hawaii'=true,'hi'=true,
   'idaho'=true,'id'=true,
   'illinois'=true,'il'=true,
   'indiana'=true,'in'=true,
   'iowa'=true,'ia'=true,
   'kansas'=true,'ks'=true,
   'kentucky'=true,'ky'=true,
   'louisiana'=true,'la'=true,
   'maine'=true,'me'=true,
   'maryland'=true,'md'=true,
   'massachusetts'=true,'ma'=true,
   'michigan'=true,'mi'=true,
   'minnesota'=true,'mn'=true,
   'mississippi'=true,'ms'=true,
   'missouri'=true,'mo'=true,
   'montana'=true,'mt'=true,
   'nebraska'=true,'ne'=true,
   'nevada'=true,'nv'=true,
   'new hampshire'=true,'nh'=true,
   'new jersey'=true,'nj'=true,
   'new mexico'=true,'nm'=true,
   'new york'=true,'ny'=true,
   'north carolina'=true,'nc'=true,
   'north dakota'=true,'nd'=true,
   'ohio'=true,'oh'=true,
   'oklahoma'=true,'ok'=true,
   'oregon'=true,'or'=true,
   'pennsylvania'=true,'pa'=true,
   'rhode island'=true,'ri'=true,
   'south carolina'=true,'sc'=true,
   'south dakota'=true,'sd'=true,
   'tennesee'=true,'tn'=true,
   'texas'=true,'tx'=true,
   'utah'=true,'ut'=true,
   'vermont'=true,'vt'=true,
   'virginia'=true,'va'=true,
   'washington'=true,'wa'=true,
   'west virginia'=true,'wv'=true,
   'wisconsin'=true,'wi'=true,
   'wyoming'=true,'wy'=true
   );
   function States() {
   }
   function isValid($str,$suggest) {
   if ($this-states[strtolower($str)] === true) {
   $this-suggest = null;
   return true;
   } elseif ($suggest === true  strlen($str)  3) {
   $this-doSuggest($str);
   return false;
   } else {
   $this-suggest = null;
   return false;
   }
   }
   function doSuggest($str) {
   foreach ($this-states as $state = $val) {
   similar_text(strtolower($state),strtolower($str),$result);
   if ($result  85) {
   $this-suggest = $state;
   }
   }
   if (empty($this-suggest)) {
   $this-suggest = null;
   }
   }
   function isSuggested() {
   return $this-suggest;
   }
}
$states = new States();
$state = 'Hawii';
if ($states-isValid($state,true) === true) {
   echo(p$state is a state./p);
} elseif ($suggest = $states-isSuggested()) {
   echo(pMay we suggest $suggest?/p);
} else {
   echo(pState not found./p);
}
?
/code
--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: If the only tool you have is a hammer, you tend to see
every problem as a nail. $$


Re: [PHP] Form Validation Issues

2007-05-23 Thread Greg Donald

On 5/23/07, Jim Lucas [EMAIL PROTECTED] wrote:

$states['TN'] = 'Tennesee';


:%s/Tennesee/Tennessee/


--
Greg Donald
http://destiney.com/

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



Re: [PHP] Form Validation Issues

2007-05-23 Thread Greg Donald

On 5/23/07, Jim Lucas [EMAIL PROTECTED] wrote:

Ok, here is something that might help you.

$states['AL'] = 'Alabama';
$states['AK'] = 'Alaska';


And a little something for you as well:

:%s/=/=/g


--
Greg Donald
http://destiney.com/

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



Re: [PHP] Re: Form Validation Issues

2007-05-23 Thread Robert Cummings
On Wed, 2007-05-23 at 11:16 -0500, Jared Farrish wrote:

 Abraham Maslow: If the only tool you have is a hammer, you tend to see
 every problem as a nail. $$

Robert Cummings:

if every problem can be described as a nail, then all you
 need is a hammer.

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

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



[PHP] Re: Form Validation Issues

2007-05-23 Thread Jared Farrish

Also, Indiana and Connecticut were misspelled.

--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: If the only tool you have is a hammer, you tend to see
every problem as a nail. $$


Re: [PHP] Form Validation Issues

2007-05-23 Thread Jim Lucas

Greg Donald wrote:

On 5/23/07, Jim Lucas [EMAIL PROTECTED] wrote:

Ok, here is something that might help you.

$states['AL'] = 'Alabama';
$states['AK'] = 'Alaska';


And a little something for you as well:

:%s/=/=/g



oops, did over look that one

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



Re: [PHP] Form Validation Issues

2007-05-23 Thread Jim Lucas

Greg Donald wrote:

On 5/23/07, Jim Lucas [EMAIL PROTECTED] wrote:

$states['TN'] = 'Tennesee';


:%s/Tennesee/Tennessee/



Not my typo, this was the ops list just reformatted.

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



[PHP] Form Processing Question - Empty Fields

2007-05-23 Thread Stephen
I have a script to process the post from a form.
   
  The form is used to upload photos and has fields for the filename, alt text, 
caption and a checkbox to indicate if this photo is the main page image 
rotation.
   
  I wanted to build a general routine to build the form to allow for a varying 
number of photos to upload.
   
  I use main_image[] for the various checkboxes for each photo.
   
  I see that the checkbox is *not* set, I get nothing back, and if the second 
photo is checked (and the first not checked), I get main_image[0] = 'on'.
   
  And I see this happens for the caption[] array as well.
   
  This seems to me to be pretty ugly.
   
  Am I understanding this properly?
   
  Do I really have to use main_image1, main_image2
   
  Thanks
  Stephen


Re: [PHP] Include???

2007-05-23 Thread Jim Lucas

Daniel Brown wrote:

On 5/23/07, Jim Lucas [EMAIL PROTECTED] 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

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



Re: [PHP] Include???

2007-05-23 Thread Tijnema

On 5/23/07, Daniel Brown [EMAIL PROTECTED] wrote:

On 5/23/07, Jim Lucas [EMAIL PROTECTED] 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

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



Re: [PHP] Form Processing Question - Empty Fields

2007-05-23 Thread Tijnema

On 5/23/07, Stephen [EMAIL PROTECTED] wrote:

I have a script to process the post from a form.

 The form is used to upload photos and has fields for the filename, alt text, 
caption and a checkbox to indicate if this photo is the main page image 
rotation.

 I wanted to build a general routine to build the form to allow for a varying 
number of photos to upload.

 I use main_image[] for the various checkboxes for each photo.

 I see that the checkbox is *not* set, I get nothing back, and if the second 
photo is checked (and the first not checked), I get main_image[0] = 'on'.

 And I see this happens for the caption[] array as well.

 This seems to me to be pretty ugly.

 Am I understanding this properly?

 Do I really have to use main_image1, main_image2

 Thanks
 Stephen



No, you don't need to, it's the way you write your HTML form.

Again, this is Off topic, as this has nothing to do with PHP, but
well, we are here to help people in general.

As you didn't provided your code, I'm giving a general example which
worked for my photo site, and should work for your example too. You
should replace foto_id_here with the ID of the photo you want to be
checked.

input type='checkbox' name='photos[]' value=photo_id_here/

And now $_POST['photos'] will be an array with the values being the
IDs of the checked photos.

Tijnema

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



Re: [PHP] Re: Form Validation Issues

2007-05-23 Thread Greg Donald

On 5/23/07, Robert Cummings [EMAIL PROTECTED] wrote:

Robert Cummings:

if every problem can be described as a nail, then all you
 need is a hammer.


Don't you ever get the urge to swing a different hammer?  I sure do.

As I watch PHP de-evolve into Java, I find myself wanting something
lighter weight and with a smaller syntax.  PHP seems fine for most web
development projects, but if PHP's SPL and the Zend Framework are a
sign of things to come from the core PHP developers, my interest in
using other hammers is only going to increase.  Possibly to the point
of putting my PHP hammer down.


--
Greg Donald
http://destiney.com/

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



Re: [PHP] Include???

2007-05-23 Thread Greg Donald

On 5/23/07, Tijnema [EMAIL PROTECTED] 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



[PHP] problems in WHERE statment

2007-05-23 Thread Mike Ryan
I am a newbie so please bear with me.

I get this error message when I try to run a query

Connected successfullyCould not successfully run query () from DB: Unknown
column '$today' in 'where clause'

this is the query command
 $query = 'SELECT *
FROM `job listing`
WHERE open =$today
LIMIT 0 , 30 ';

I have assigned $today this way $today=date(Y-m-d);

Can you tell me what I did wrong??

thanks for your help.

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



[PHP] format date field

2007-05-23 Thread Mike Ryan
I am reading in a date field from a mysql database the field on the screen
shows up as 2007-05-01  on the screen I would like the field to show
05-01-2007  currently I am issueing the following command  print
$row['open']; how can I format this field???

while I am at it how can I accept the date field as 05-01-2007;

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



[PHP] date format from a database date field

2007-05-23 Thread Mike Ryan
Sorry I am a bit of a newbie with php and hope this has not been aswered a
million times, but here it goes

I have a date base with a couple of date fields when I pull up and display
the fields it show 2007-05-21. the question I have is how to convert the
field to 05-21-2007?

Currently the command I have is

print $row['open'];

any help would be apreciative.

thanks

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



Re: [PHP] problems in WHERE statment

2007-05-23 Thread Greg Donald

On 5/21/07, Mike Ryan [EMAIL PROTECTED] wrote:

I am a newbie so please bear with me.

I get this error message when I try to run a query

Connected successfullyCould not successfully run query () from DB: Unknown
column '$today' in 'where clause'

this is the query command
 $query = 'SELECT *
FROM `job listing`
WHERE open =$today


'$today' not $today



--
Greg Donald
http://destiney.com/

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



Re: [PHP] format date field

2007-05-23 Thread Greg Donald

On 5/23/07, Mike Ryan [EMAIL PROTECTED] wrote:

I am reading in a date field from a mysql database the field on the screen
shows up as 2007-05-01  on the screen I would like the field to show
05-01-2007  currently I am issueing the following command  print
$row['open']; how can I format this field???

while I am at it how can I accept the date field as 05-01-2007;



Look at MySQL's DATE_FORMAT() function.


--
Greg Donald
http://destiney.com/

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



Re: [PHP] Include???

2007-05-23 Thread Daniel Brown

On 5/23/07, Greg Donald [EMAIL PROTECTED] wrote:


On 5/23/07, Tijnema [EMAIL PROTECTED] 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


Re: [PHP] zend framework

2007-05-23 Thread Aaron Gould
I've been experimenting with it for a new site revision at the company I 
work at.  I have to agree, it's feels heavy, almost bloated.  Mind you, 
I've only used a small fraction of the framework -- namely the Zend_Db, 
Zend_Config and Zend_Controller portions.  The lack of Javascript seems 
like a curious omission, but perhaps that's not the point of ZF.


I've been using CakePHP for another site, and it feels very efficient 
and easy to use. Javascript/AJAX helpers are all integrated too. Perhaps 
this is contributing to my somewhat negative view on ZF?


I still intend to try out ZF a bit more to give it a fair shot, but 
after using CakePHP, I'm not so sure for how long...

--
Aaron Gould


Greg Donald wrote:

Has anyone looked at the Zend Framework lately?

http://framework.zend.com/manual

I've been playing with a few parts of it off and on the past couple of
days.  It seems really heavy overall and there is no Javascript
integration anywhere.  Nothing on the roadmap about Javascript either:

http://framework.zend.com/roadmap

It might be worth using if it actually did something better than my
current toolset.  Right now it really doesn't.


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



Re: [PHP] date format from a database date field

2007-05-23 Thread Daniel Brown

On 5/21/07, Mike Ryan [EMAIL PROTECTED] wrote:


Sorry I am a bit of a newbie with php and hope this has not been aswered a
million times, but here it goes

I have a date base with a couple of date fields when I pull up and display
the fields it show 2007-05-21. the question I have is how to convert the
field to 05-21-2007?

Currently the command I have is

print $row['open'];

any help would be apreciative.

thanks

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




   For starters, try to keep all similar requests in one single email
otherwise you look like your spamming the hell out of the list.

--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107


Re: [PHP] problems in WHERE statment

2007-05-23 Thread Davi
Em Segunda 21 Maio 2007 16:46, Mike Ryan escreveu:
 I get this error message when I try to run a query

 Connected successfullyCould not successfully run query () from DB: Unknown
 column '$today' in 'where clause'

 this is the query command
  $query = 'SELECT *
 FROM `job listing`
 WHERE open =$today
 LIMIT 0 , 30 ';

 I have assigned $today this way $today=date(Y-m-d);

 Can you tell me what I did wrong??


Sure! =)

You must scape your PHP variables in any SQL query...

Try this:

$query=SELECT *
FROM `joblisting`
WHERE open = '$today'
LIMIT 0,30;

HTH
-- 
Davi Vidal
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--
Religion, ideology, resources, land,
spite, love or just because...
No matter how pathetic the reason,
it's enough to start a war. 


pgpBld9Ikeqgh.pgp
Description: PGP signature


[PHP] Swinging Hammers (was Re: Form Validation Issues)

2007-05-23 Thread Robert Cummings
On Wed, 2007-05-23 at 11:51 -0500, Greg Donald wrote: 
 On 5/23/07, Robert Cummings [EMAIL PROTECTED] wrote:
  Robert Cummings:
 
  if every problem can be described as a nail, then all you
   need is a hammer.
 
 Don't you ever get the urge to swing a different hammer?

 I sure do.

I swing other hammers, but don't always have time to muck around with
the latest hammer in the store. At any rate, we're still talking
hammers ;) The point of my comment is that there's a gray area between
approaching a problem as a nail and using another tool. Sometimes being
able to fit a problem into an existing paradigm makes it that much
simpler to solve since you already have the tool and experience at hand.

 As I watch PHP de-evolve into Java, I find myself wanting something
 lighter weight and with a smaller syntax.  PHP seems fine for most web
 development projects, but if PHP's SPL and the Zend Framework are a
 sign of things to come from the core PHP developers, my interest in
 using other hammers is only going to increase.  Possibly to the point
 of putting my PHP hammer down.

I think for me it will depend. I found PHP4's feature set to be almost
perfect for any web work I needed to do. I only lament that PHP4 doesn't
have PHP5's object assignment semantics and destructor support. The rest
of the OOP features really don't get me going. The question is how much
those extra features cost a lightweight script that doesn't use them. In
the past I consistently benched PHP4 as faster for my framework... but
I've yet to test against 5.2.2.

It will be interesting to see if indeed no more bug/security fixes will
be released for PHP4 at the end of this year when it reaches it's
decided end-of-life. More interesting will be if it still has the
greater market share over PHP5 when they declare it dead *lol*.

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

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



Re: [PHP] Form Processing Question - Empty Fields

2007-05-23 Thread Greg Donald

On 5/23/07, Tijnema [EMAIL PROTECTED] wrote:

Again, this is Off topic,


/me rolls eyes

Do you even know what P-H-P stands for?  HTML questions are not off
topic, especially form related ones.


--
Greg Donald
http://destiney.com/

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



Re: [PHP] format date field

2007-05-23 Thread Kevin Murphy
Leave the date as is, its a MySQL thing. To format it on your page,  
use the date function:


$formattedDate = date(m-d-Y,strtotime($row[open]));

http://us2.php.net/manual/en/function.date.php

--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326


On May 23, 2007, at 9:45 AM, Mike Ryan wrote:

I am reading in a date field from a mysql database the field on the  
screen

shows up as 2007-05-01  on the screen I would like the field to show
05-01-2007  currently I am issueing the following command  print
$row['open']; how can I format this field???

while I am at it how can I accept the date field as 05-01-2007;

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





Re: [PHP] problems in WHERE statment

2007-05-23 Thread Eric Butera

On 5/21/07, Mike Ryan [EMAIL PROTECTED] wrote:

I am a newbie so please bear with me.

I get this error message when I try to run a query

Connected successfullyCould not successfully run query () from DB: Unknown
column '$today' in 'where clause'

this is the query command
 $query = 'SELECT *
FROM `job listing`
WHERE open =$today
LIMIT 0 , 30 ';

I have assigned $today this way $today=date(Y-m-d);

Can you tell me what I did wrong??

thanks for your help.

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




Single quotes in PHP do not evaluate their contents.  Double quotes
do.  So $today is literally $today instead of the value you set in it.

$hi = Hi;

echo '$hi';
output: $hi

echo $hi;
output: Hi

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



Re: [PHP] problems in WHERE statment

2007-05-23 Thread Daniel Brown

On 5/23/07, Greg Donald [EMAIL PROTECTED] wrote:


On 5/21/07, Mike Ryan [EMAIL PROTECTED] wrote:
 I am a newbie so please bear with me.

 I get this error message when I try to run a query

 Connected successfullyCould not successfully run query () from DB:
Unknown
 column '$today' in 'where clause'

 this is the query command
  $query = 'SELECT *
 FROM `job listing`
 WHERE open =$today

'$today' not $today



--
Greg Donald
http://destiney.com/

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




   You're also single-quoting your SQL query.  When including a variable in
there, you should double-quote around the query string, and single-quote the
values you're seeking.

   Example:

$query = SELECT * FROM `job listing` WHERE open = '$today' LIMIT 0,30;

   It looks like your PHP code was generated by phpMyAdmin I know it
outputs data like you supplied.  Also, as a postscript, you should try not
to use table names that include a space.  If at all possible, convert `job
listing` to `job_listing` with an underscore.

--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107


[PHP] Re: problems in WHERE statment

2007-05-23 Thread Jared Farrish

Change the single quote to a double quote:

code
$query = SELECT * FROM `job listing` WHERE open = '$today' LIMIT 0 , 30
;
/code

This tells the PHP string parser to replace all declared, in-scope variables
that are detected in a string with the value of the variable (as a
toString() method, so a reference would not pass in the actual data, it
would print something like Resource id #3).

When you use single-quotes, you are telling the parser to keep it's hands
off the string, and use as-is.

Example:
code
var $a = 'test';
var $b = 'test2';
var $c = '$a$b';
var $d = $a$b;
var $e = $a.$b;
/code

$e is equivalent to $d, where c would print literally $a$b, since you told
the parser using the single quotes to leave the string alone.

Likewise, var $f = $a.-$b$c-.'$e'; would print test-test2$a$b-$e;

--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: If the only tool you have is a hammer, you tend to see
every problem as a nail. $$


Re: [PHP] Include???

2007-05-23 Thread Dan Shirah

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 [EMAIL PROTECTED] wrote:


On 5/23/07, Greg Donald [EMAIL PROTECTED] wrote:

 On 5/23/07, Tijnema [EMAIL PROTECTED] 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



[PHP] Re: date format from a database date field

2007-05-23 Thread Johan Holst Nielsen

Mike Ryan wrote:

Sorry I am a bit of a newbie with php and hope this has not been aswered a
million times, but here it goes

I have a date base with a couple of date fields when I pull up and display
the fields it show 2007-05-21. the question I have is how to convert the
field to 05-21-2007?

Currently the command I have is

print $row['open'];


Well the easiest thing is to let MySQL do the work

use following SELECT

SELECT DATE_FORMAT(your_date_field,'%m-%d-%Y') as date_field FROM yourtable

That should do the work...

--
Johan Holst Nielsen
Freelance PHP Developer - http://phpgeek.dk

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



[PHP] Re: How to eject cd-rom with php code?

2007-05-23 Thread Colin Guthrie
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

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



[PHP] Cannot access file on Network Drive (Windows 2003)

2007-05-23 Thread Rahul Sitaram Johari

Ave,

Apache 2.2, PHP5  mySQL 5 on Windows 2003.
I have some files sitting on a Network Drive accessible on the Windows 2003
Server. But my php script is not able to open the files.

Let¹s say there¹s a database on X:\Transfer\test.dbf
If I use:

$db = dbase_open(³X:\Transfer\test.dbf², 0);

It is not able to open the database. The X: Drive is a network drive.
Any clues on how to make this happen?

Thanks.


~~~
Rahul Sitaram Johari
CEO, Twenty Four Seventy Nine Inc.

W: http://www.rahulsjohari.com
E: [EMAIL PROTECTED]

³I morti non sono piu soli ... The dead are no longer lonely²



RE: [PHP] Cannot access file on Network Drive (Windows 2003)

2007-05-23 Thread Jay Blanchard
[snip]
Let¹s say there¹s a database on X:\Transfer\test.dbf
If I use:

$db = dbase_open(³X:\Transfer\test.dbf², 0);

It is not able to open the database. The X: Drive is a network drive.
Any clues on how to make this happen?
[/snip]

Have you checked the permissions?

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



Re: [PHP] Cannot access file on Network Drive (Windows 2003)

2007-05-23 Thread Rahul Sitaram Johari

Well, Full Permissions (Full Control, including read  write) have been
given to the Machine on which the Apache Web Server is setup. Not sure if
anything else needs to be done!


On 5/23/07 3:02 PM, Jay Blanchard [EMAIL PROTECTED] wrote:

 [snip]
 Let¹s say there¹s a database on X:\Transfer\test.dbf
 If I use:
 
 $db = dbase_open(³X:\Transfer\test.dbf², 0);
 
 It is not able to open the database. The X: Drive is a network drive.
 Any clues on how to make this happen?
 [/snip]
 
 Have you checked the permissions?
 
 --
 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] Cannot access file on Network Drive (Windows 2003)

2007-05-23 Thread Tijnema

On 5/23/07, Rahul Sitaram Johari [EMAIL PROTECTED] wrote:


Well, Full Permissions (Full Control, including read  write) have been
given to the Machine on which the Apache Web Server is setup. Not sure if
anything else needs to be done!


The \ is an escape token, and you should use \\ instead.

Try X:\\Transfer\\test.dbf instead.

Tijnema

ps. Please don't top post.



On 5/23/07 3:02 PM, Jay Blanchard [EMAIL PROTECTED] wrote:

 [snip]
 Let¹s say there¹s a database on X:\Transfer\test.dbf
 If I use:

 $db = dbase_open(³X:\Transfer\test.dbf², 0);

 It is not able to open the database. The X: Drive is a network drive.
 Any clues on how to make this happen?
 [/snip]

 Have you checked the permissions?

 --
 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] RE: Cannot access file on Network Drive (Windows 2003)

2007-05-23 Thread Jared Farrish

Other than permissions, you might be referencing the folder by the local
network mapping drive initial, instead of the actual path:

X:\\offsite\db\test.dbf == \\compname-x\offsite\db\test.dbf

Generally, I like using the computer name and not a mapping. I find this
name-based address through the 'My Network Places' folder.

I'm not much of a windows networking person, but this might be the problem.
Results may vary, but in windows, I think the mappings are by machine only,
as mappings (I assume) are local aliases, and must be set or shared among
groups of machines to be known.

It's probably a permissions thing, though.

FWIW

--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: If the only tool you have is a hammer, you tend to see
every problem as a nail. $$


[PHP] Re: Cannot access file on Network Drive (Windows 2003)

2007-05-23 Thread Jared Farrish

Oh yeah, and tijnema has a good point:

\\compname-x\\offsite\\db\\test.dbf

Btw, what does top post mean?

On 5/23/07, Jared Farrish [EMAIL PROTECTED] wrote:


Other than permissions, you might be referencing the folder by the local
network mapping drive initial, instead of the actual path:

X:\\offsite\db\test.dbf == \\compname-x\offsite\db\test.dbf

Generally, I like using the computer name and not a mapping. I find this
name-based address through the 'My Network Places' folder.

I'm not much of a windows networking person, but this might be the
problem. Results may vary, but in windows, I think the mappings are by
machine only, as mappings (I assume) are local aliases, and must be set or
shared among groups of machines to be known.

It's probably a permissions thing, though.

FWIW

--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: If the only tool you have is a hammer, you tend to see
every problem as a nail. $$





--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: If the only tool you have is a hammer, you tend to see
every problem as a nail. $$


Re: [PHP] Cannot access file on Network Drive (Windows 2003)

2007-05-23 Thread Rahul Sitaram Johari

Didn't help. Tried X:\\Transfer\\test.dbf
Still can't access the file.


On 5/23/07 3:11 PM, Tijnema [EMAIL PROTECTED] wrote:

 The \ is an escape token, and you should use \\ instead.
 
 Try X:\\Transfer\\test.dbf instead.
 
 Tijnema
 
 ps. Please don't top post.

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



Re: [PHP] RE: Cannot access file on Network Drive (Windows 2003)

2007-05-23 Thread Rahul Sitaram Johari

Tried that too. Used

\\Servername\sharename\test.dbf

Also used additional backslashes for the escape issue:

Servername\\sharename\\test.dbf

Still doesn't work!
I'm not getting a permissions related issue and I'm doubting it is a
permissions issue. I have Full Control given to the system all this is on.

On 5/23/07 3:16 PM, Jared Farrish [EMAIL PROTECTED] wrote:

 Other than permissions, you might be referencing the folder by the local
 network mapping drive initial, instead of the actual path:
 
 X:\\offsite\db\test.dbf == \\compname-x\offsite\db\test.dbf
 
 Generally, I like using the computer name and not a mapping. I find this
 name-based address through the 'My Network Places' folder.
 
 I'm not much of a windows networking person, but this might be the problem.
 Results may vary, but in windows, I think the mappings are by machine only,
 as mappings (I assume) are local aliases, and must be set or shared among
 groups of machines to be known.
 
 It's probably a permissions thing, though.
 
 FWIW

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



Re: [PHP] RE: Cannot access file on Network Drive (Windows 2003)

2007-05-23 Thread Jared Farrish

Try to simply include() and var_dump() or something. Start from just
checking you can access the file first (I'd even start with a
test.txtfile), before you inflate the db...

Let us know what the error is exactly, as well. What happens? Error?
Warning? Blank page? What tells you the script doesn't work?

On 5/23/07, Rahul Sitaram Johari [EMAIL PROTECTED] wrote:



Tried that too. Used

\\Servername\sharename\test.dbf

Also used additional backslashes for the escape issue:

Servername\\sharename\\test.dbf

Still doesn't work!
I'm not getting a permissions related issue and I'm doubting it is a
permissions issue. I have Full Control given to the system all this is on.



--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: If the only tool you have is a hammer, you tend to see
every problem as a nail. $$


Re: [PHP] Re: Form Validation Issues

2007-05-23 Thread Crayon Shin Chan
On Thursday 24 May 2007 00:51, Greg Donald wrote:

 As I watch PHP de-evolve into Java, I find myself wanting something
 lighter weight and with a smaller syntax. 

PHP has long since spawned into something uncontrollable. Compare the 
number of functions (and its aliases) to eg Ruby. The string functions in 
particular are absolutely bloated, eg ltrim, trim  rtrim - WTF. Why not 
just have trim() and have the option of specifying whether 
left/right/both? The same goes for the case-sensitive and 
case-insensitive versions of functions.

-- 
Crayon

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



  1   2   >