php-general Digest 24 Feb 2010 16:14:58 -0000 Issue 6607

2010-02-24 Thread php-general-digest-help

php-general Digest 24 Feb 2010 16:14:58 - Issue 6607

Topics (messages 302330 through 302349):

PHP or SQL to do this?
302330 by: Rob Gould
302332 by: Jim Lucas
302342 by: Ian

Re: PHP / mySQL Project... Real men use 'cat'
302331 by: Jim Lucas
302336 by: shiplu
302337 by: Pete Ford
302338 by: Ashley Sheridan
302345 by: Andrew Ballard
302346 by: Ashley Sheridan
302347 by: Ashley Sheridan

Re: How to get the 'return type' of a function?
302333 by: Dasn
302334 by: Jochem Maas

Re: $_POST vs $_REQUEST
302335 by: Jochem Maas
302339 by: Ashley Sheridan
302340 by: Rene Veerman
302341 by: Ashley Sheridan

obj in array?
302343 by: Kim Madsen
302344 by: Kim Madsen

Re: Fun with Streams
302348 by: Matt Neimeyer

HipHop and other PHP compiler performance evaluation
302349 by: Manuel Lemos

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
I'm not sure if I need to write a PHP for-loop to do this, or if it can all be 
done in one SQL statement?

Basically, I want to copy all the barcodes from one table and put them into 
another table, but only if the barcode in the first table  0, and only if the 
wineid's match from table to table.


Steps individually are something like this:

1)  First, I get all the records from the wine table that have barcodes, like 
this:

SELECT *  FROM `wine` WHERE barcode2  0

The fields I need are barcode2, and wineid


2)  Next, I need to match all the wineid's from this wine table with the wine 
id's from the usersdata table.  Both fields in both tables are called 
wineid.

3)  Then, if the wineid's match, I need to copy the barcode2 value from the 
wine table and put it into the field custombarcode in the usersdata table.


I'm tempted to write a PHP script which does a while-loop through all the 
records returned from the wine table and do the matching with the usersdata 
table, but I wouldn't be surprised if there's some sort of table-join-type 
query that can do all this in one step.
---End Message---
---BeginMessage---

Rob Gould wrote:

I'm not sure if I need to write a PHP for-loop to do this, or if it can all be 
done in one SQL statement?

Basically, I want to copy all the barcodes from one table and put them into 
another table, but only if the barcode in the first table  0, and only if the 
wineid's match from table to table.


Steps individually are something like this:

1)  First, I get all the records from the wine table that have barcodes, like 
this:

SELECT *  FROM `wine` WHERE barcode2  0

The fields I need are barcode2, and wineid


2)  Next, I need to match all the wineid's from this wine table with the wine id's from the 
usersdata table.  Both fields in both tables are called wineid.

3)  Then, if the wineid's match, I need to copy the barcode2 value from the wine table and put it 
into the field custombarcode in the usersdata table.


I'm tempted to write a PHP script which does a while-loop through all the 
records returned from the wine table and do the matching with the usersdata 
table, but I wouldn't be surprised if there's some sort of table-join-type 
query that can do all this in one step.



Looks like you should be able to do this in the SQL.  Creating a dummy DB and testing, the following 
seems to do the trick.


UPDATE usersdata SET
custombarcode = (
SELECT  barcode2
FROMwine
WHERE   usersdata.wineid = wine.wineid
AND wine.barcode2  0
)

Here is the DB schema and data that I used for the test

CREATE TABLE IF NOT EXISTS `usersdata` (
  `id` int(11) NOT NULL auto_increment,
  `wineid` int(11) NOT NULL,
  `custombarcode` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_bin AUTO_INCREMENT=7 ;

INSERT INTO `usersdata` (`id`, `wineid`, `custombarcode`) VALUES
(1, 1, 0),
(2, 2, 0),
(3, 3, 0),
(4, 4, 0),
(5, 1, 0),
(6, 1, 0);

CREATE TABLE IF NOT EXISTS `wine` (
  `wineid` int(11) NOT NULL auto_increment,
  `barcode2` int(11) NOT NULL,
  PRIMARY KEY  (`wineid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_bin AUTO_INCREMENT=4 ;

INSERT INTO `wine` (`wineid`, `barcode2`) VALUES
(1, 5),
(2, -5),
(3, 10);


--
Jim Lucas

A: Maybe because some people are too annoyed by top-posting.
Q: Why do I not get an answer to my question(s)?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
---End Message---
---BeginMessage---
On 24/02/2010 05:46, Rob Gould wrote:
 I'm not sure if I need to 

Re: [PHP] $_POST vs $_REQUEST

2010-02-24 Thread Rene Veerman
sry i gotta disagree.

a function that queries $_POST/$_GET first and then $_COOKIE seems
much wiser to me.
it consolidates all logic in the script, and making that logic obvious
by syntax, rather than relying on functionality being determined by
php.ini, which could well cause a new developer to lose heaps of time
if he/she has to work on it..

On Wed, Feb 24, 2010 at 11:18 AM, Ashley Sheridan
a...@ashleysheridan.co.uk wrote:
 On Wed, 2010-02-24 at 07:55 +, Jochem Maas wrote:

 Op 2/22/10 10:49 PM, John Black schreef:
  On 02/22/2010 11:42 PM, Michael Shadle wrote:
  The difference here is you can at least have some control over the data
  and expect it in a certain fashion. Also the behavior of cookies vs. get
  vs. post are different (cookies have length and expiration limits, get
  has length limits, post has server confgured limits)
 
  The cookie and post/get part is all mixed up now :)
 
  I use $_COOKIE when I want cookie information but I know that the data
  is not to be trusted and is easily fabricated.
 
  When reading get or post I just use $_REQUEST nowadays because I don't
  have to care how the submitting form is written. This makes my form
  handling data more portable.

 a. if your updating/inserting/storing data for the user you should require
 POST in order to mitigate CSRF et al - not to mention using a nonce in your 
 forms.

 b. when you use $_REQUEST like you do you assume it's either GET or POST 
 data, but
 it might be COOKIE data ... which will overwrite what is sent via GET or 
 POST in the
 $_REQUEST array .. which creates a potential for a denial-of-service attack 
 on the
 users of a site:

 imagine an 'id' parameter for displaying articles, then imagine a
 user was tricked into loading a cookie onto his machine for your domain with 
 the
 name of 'id' and a value of 1 ... said user would only ever be able to see 
 the
 article referred to be id=1 if you wrote code that took the 'id' parameter 
 from the
 $_REQUEST var.

 ... I advocate not trusting any data *and* being explicit about the input 
 vectors
 on which any particular piece of data is accepted in a given context. (GET, 
 POST and COOKIE
 are 3 different vectors)





 Which becomes a moot point if you use the request_order ini setting to
 specify the ordering of the overriding of variables in $_REQUEST.

 I do see what you're getting at, and yes there are concerns to be had
 with one global array overriding another if you don't know to look out
 for such a caveat. The thing is, there are many times where $_REQUEST is
 just perfect. Imagine a stylesheet picker, that remembers the visitors
 choice in a cookie. You can utilise $_REQUEST to handle the whole thing
 very easily, and in a way that makes sense.

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk




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



[PHP] obj in array?

2010-02-24 Thread Kim Madsen

Hi folks

I'm hacking on a SOAP2 solution towards Magento and have retrieved the 
catalog in an array, but i'm having trouble accessing the values of the 
array cause there's an object in it. This is a var_dump of $my_array:


array(14) {
  [0]=
  object(stdClass)#2 (2) {
[set_id]=
int(44)
[name]=
string(7) Cameras
  }
  [1]=
  object(stdClass)#3 (2) {
[set_id]=
int(38)
[name]=
string(11) Cell Phones
  }

how do I access for instance set_id in $my_array[0]? I tried declaring 
an instance of $my_array[0] but that fails too: Fatal error: Cannot use 
object of type stdClass as array 


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] obj in array?

2010-02-24 Thread Kim Madsen

Kim Madsen wrote on 24/02/2010 14:02:

how do I access for instance set_id in $my_array[0]? I tried declaring 
an instance of $my_array[0] but that fails too: Fatal error: Cannot use 
object of type stdClass as array 


$my_array[0]-set_id; did the trick


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] PHP / mySQL Project... Real men use 'cat'

2010-02-24 Thread Andrew Ballard
On Wed, Feb 24, 2010 at 5:12 AM, Ashley Sheridan
a...@ashleysheridan.co.uk wrote:
 On Wed, 2010-02-24 at 09:18 +, Pete Ford wrote:
 sudo ln -s /bin/cat /bin/dog
 sudo ln -s /bin/cat /bin/rabbit
 sudo ln -s /bin/cat /bin/rat

 Sorted...



 But now they're in /bin, surely at some point you'll want to execute
 these poor pets? Haven't they been through enough already?!

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk


If you have a cat, dog, rabbit and rat together in a bin, you probably
won't have to execute them. At least not all of them.  :-P

Andrew

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



Re: [PHP] PHP / mySQL Project... Real men use 'cat'

2010-02-24 Thread Ashley Sheridan
On Wed, 2010-02-24 at 09:22 -0500, Andrew Ballard wrote:

 On Wed, Feb 24, 2010 at 5:12 AM, Ashley Sheridan
 a...@ashleysheridan.co.uk wrote:
  On Wed, 2010-02-24 at 09:18 +, Pete Ford wrote:
  sudo ln -s /bin/cat /bin/dog
  sudo ln -s /bin/cat /bin/rabbit
  sudo ln -s /bin/cat /bin/rat
 
  Sorted...
 
 
 
  But now they're in /bin, surely at some point you'll want to execute
  these poor pets? Haven't they been through enough already?!
 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
 If you have a cat, dog, rabbit and rat together in a bin, you probably
 won't have to execute them. At least not all of them.  :-P
 
 Andrew
 


Reminds me of Eddie Izzards Noah's Ark sketch:

http://www.youtube.com/watch?v=CFdmG-TRxzE

The bit I'm thinking of is about 6 minutes in ;)

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] PHP / mySQL Project... Real men use 'cat'

2010-02-24 Thread Ashley Sheridan
On Wed, 2010-02-24 at 14:24 +, Ashley Sheridan wrote:

 On Wed, 2010-02-24 at 09:22 -0500, Andrew Ballard wrote:
 
  On Wed, Feb 24, 2010 at 5:12 AM, Ashley Sheridan
  a...@ashleysheridan.co.uk wrote:
   On Wed, 2010-02-24 at 09:18 +, Pete Ford wrote:
   sudo ln -s /bin/cat /bin/dog
   sudo ln -s /bin/cat /bin/rabbit
   sudo ln -s /bin/cat /bin/rat
  
   Sorted...
  
  
  
   But now they're in /bin, surely at some point you'll want to execute
   these poor pets? Haven't they been through enough already?!
  
   Thanks,
   Ash
   http://www.ashleysheridan.co.uk
  
  
  If you have a cat, dog, rabbit and rat together in a bin, you probably
  won't have to execute them. At least not all of them.  :-P
  
  Andrew
  
 
 
 Reminds me of Eddie Izzards Noah's Ark sketch:
 
 http://www.youtube.com/watch?v=CFdmG-TRxzE
 
 The bit I'm thinking of is about 6 minutes in ;)
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 
 

Actually, this clip is a bit better:

http://www.youtube.com/watch?v=GrP8ey8VheU

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Fun with Streams

2010-02-24 Thread Matt Neimeyer
Basically... I built the stream encapsulation to do two things for me:

1. Keep track of the row I was on.
2. Keep track of the columns by name. So if I wrote columns Foo, Bar,
Baz one time and Foo, Baz the next it would automatically keep the Baz
in column three the second time.

In other words, it makes it simple to just dump row after row of data
into it for exports and simple reports.

Matt

On Mon, Feb 22, 2010 at 4:14 AM, Rene Veerman rene7...@gmail.com wrote:
 just curious, why did you choose to use it from behind a stream wrapper?

 On Sun, Feb 21, 2010 at 11:03 PM, Matt Neimeyer m...@neimeyer.org wrote:
 I created a stream wrapper around the php_writeexcel library found at
 http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/

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



[PHP] HipHop and other PHP compiler performance evaluation

2010-02-24 Thread Manuel Lemos
FYI

http://digg.com/programming/PHP_compiler_performance

-- 

Regards,
Manuel Lemos

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

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

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



Re: [PHP] HipHop and other PHP compiler performance evaluation

2010-02-24 Thread Adam Richardson
Really nice article, Manuel.  Thanks for writing and sharing the link.

Adam

On Wed, Feb 24, 2010 at 11:14 AM, Manuel Lemos mle...@acm.org wrote:

 FYI

 http://digg.com/programming/PHP_compiler_performance

 --

 Regards,
 Manuel Lemos

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

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

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




-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


Re: [PHP] HipHop and other PHP compiler performance evaluation

2010-02-24 Thread Manuel Lemos
Hello Adam,

on 02/24/2010 01:37 PM Adam Richardson said the following:
 Really nice article, Manuel.  Thanks for writing and sharing the link.

You're welcome! ;-)


 Adam
 
 On Wed, Feb 24, 2010 at 11:14 AM, Manuel Lemos mle...@acm.org
 mailto:mle...@acm.org wrote:
 
 FYI
 
 http://digg.com/programming/PHP_compiler_performance



-- 

Regards,
Manuel Lemos

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

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

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



Re: [PHP] Linux ERD software

2010-02-24 Thread haliphax
Dia is also a superb diagramming software, though I don't think it generates
any SQL for you when it's said and done. There are versions for several
operating systems (including Linux AND Windows).


// Todd


Re: [PHP] Linux ERD software

2010-02-24 Thread Ashley Sheridan
On Wed, 2010-02-24 at 11:28 -0600, haliphax wrote:

 Dia is also a superb diagramming software, though I don't think it generates
 any SQL for you when it's said and done. There are versions for several
 operating systems (including Linux AND Windows).
 
 
 // Todd


Cool thanks all. I had a look at dia, and it seemed more geared to
electronic diagrams than database ones (although I didn't play with it
for too long).

I just drew them in the end in OOo, but I'm going to take a look at
MySQL Workbench when I get some time, but this project is already in
danger of falling behind schedule :(

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Linux ERD software

2010-02-24 Thread O. Lavell
haliphax wrote:

 Dia is also a superb diagramming software, though I don't think it
 generates any SQL for you when it's said and done.

Dia can be scripted and there is some interesting looking stuff here:

http://projects.gnome.org/dia/links.html

(I never tried)

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



Re: [PHP] Linux ERD software

2010-02-24 Thread Shawn McKenzie
Ashley Sheridan wrote:
 On Wed, 2010-02-24 at 11:28 -0600, haliphax wrote:
 
 Dia is also a superb diagramming software, though I don't think it generates
 any SQL for you when it's said and done. There are versions for several
 operating systems (including Linux AND Windows).


 // Todd
 
 
 Cool thanks all. I had a look at dia, and it seemed more geared to
 electronic diagrams than database ones (although I didn't play with it
 for too long).
 
 I just drew them in the end in OOo, but I'm going to take a look at
 MySQL Workbench when I get some time, but this project is already in
 danger of falling behind schedule :(
 

Hey Ash.  When you have a spare several minutes or so, just download
MySQL Workbench.  You can just suck in your existing DB and voila!  Or
if you don't have one yet it should be fairly quick to mock it up.


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

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



[PHP] PHP Syntax Help - Check?

2010-02-24 Thread Rick Dwyer

Hello all.

I'm trying to learn PHP on the fly and I have a line of code that  
contains syntax I can't find documented anywhere:


php echo check('element8');

In the above line, can someone tell me what check means?

Thank you.

 --Rick



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



Re: [PHP] PHP Syntax Help - Check?

2010-02-24 Thread Robert Cummings

Rick Dwyer wrote:

Hello all.

I'm trying to learn PHP on the fly and I have a line of code that  
contains syntax I can't find documented anywhere:


php echo check('element8');

In the above line, can someone tell me what check means?



In the above, check is a function. It is being called with parameter 
'element8'.


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

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



Re: [PHP] PHP Syntax Help - Check?

2010-02-24 Thread Paul M Foster
On Thu, Feb 25, 2010 at 12:16:08AM -0500, Robert Cummings wrote:

 Rick Dwyer wrote:
 Hello all.

 I'm trying to learn PHP on the fly and I have a line of code that
 contains syntax I can't find documented anywhere:

 php echo check('element8');

 In the above line, can someone tell me what check means?


 In the above, check is a function. It is being called with parameter
 'element8'.

This is true. But perhaps more importantly, check() is not a native PHP
function. Thus it comes from some other library or group of external
functions.

Paul

-- 
Paul M. Foster

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



[PHP] Database design

2010-02-24 Thread Angus Mann
Hi all. I know this is not strictly a PHP question but the code will be written 
in PHP, and I figure the folks here will be well versed in the questions I 
raise. Please feel free to contact me off the list if appropriate.

I need some assistance with database design for a project I'm coding in PHP. 
I'm willing to pay for the advice, since I think it will be a bit complex. I 
plan to use MySQLi

If anybody feels they can assist, or can point elsewhere please feel free to 
contact me off list, or reply to the list if you think appropriate.

Thanks,
Angus

Re: [PHP] PHP Syntax Help - Check?

2010-02-24 Thread Rick Dwyer

OK... external function... that would explain why I could not locate it.

Let me get right to the problem I am having with this code as someone  
may be able to help directly.


I have a link on a page that opens a contact form.  The link is  
mypage.php?my_id=5


So on mypage.php, I capture this value with:
$my_id=$_GET['my_id'];

I understand this much.  But when the end user submits this contact  
form they do so to formcheck.php and if formcheck.php sees a required  
field is blank, it throws it back to mypage.php with an alert.  BUT, I  
lose the value of the variable $my_id.  SO, I created a hidden field  
on mypate.php with  value=?php echo $my_id; ? and on  
formcheck.php, I added $my_id = $_Post['my_id'];


However, when formcheck.php returns me to mypage.php, $my_id is still  
blank.


Very frustrating.

Any help determining what I am doing wrong is greatly appreciated.

Thanks.



 --Rick


On Feb 25, 2010, at 12:31 AM, Paul M Foster wrote:


On Thu, Feb 25, 2010 at 12:16:08AM -0500, Robert Cummings wrote:


Rick Dwyer wrote:

Hello all.

I'm trying to learn PHP on the fly and I have a line of code that
contains syntax I can't find documented anywhere:

php echo check('element8');

In the above line, can someone tell me what check means?



In the above, check is a function. It is being called with parameter
'element8'.


This is true. But perhaps more importantly, check() is not a native  
PHP

function. Thus it comes from some other library or group of external
functions.

Paul

--
Paul M. Foster

--
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] Database design

2010-02-24 Thread Paul M Foster
On Thu, Feb 25, 2010 at 03:37:38PM +1000, Angus Mann wrote:

 Hi all. I know this is not strictly a PHP question but the code will be 
 written in PHP, and I figure the folks here will be well versed in the 
 questions I raise. Please feel free to contact me off the list if appropriate.
 
 I need some assistance with database design for a project I'm coding in PHP. 
 I'm willing to pay for the advice, since I think it will be a bit complex. I 
 plan to use MySQLi

Not sure why you want to use MySQLi, but I would suggest using PDO
functions instead. Either way, I'd design a wrapper class around
whatever library you use, to simplify error trapping, make the interface
simpler and more orthogonal, and improve portability. I've never
understood why they didn't provide such an overall wrapper class for the
PDO library. Having three separate PDO classes only complicates the
interface to the library.

Paul

-- 
Paul M. Foster

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



Re: [PHP] PHP Syntax Help - Check?

2010-02-24 Thread viraj
if you do the redirection with header('Location: /mypage.php'),
setting a variable on formcheck.php is not enough.

if you modify the header('Location: /mypage.php') to..

header('Location: /mypage.php?my_id=5')

it will take the variable to mypage.php as $_GET['my_id]

you can not expect a variable value set in to $_POST array to reflect
on a totally different page without making it a form post (aka use of
proper headers).

i guess, it's time to you to read about session_start() method and the
array $_SESSION available in php :)


~viraj

On Thu, Feb 25, 2010 at 11:22 AM, Rick Dwyer rpdw...@earthlink.net wrote:
 OK... external function... that would explain why I could not locate it.

 Let me get right to the problem I am having with this code as someone may be
 able to help directly.

 I have a link on a page that opens a contact form.  The link is
 mypage.php?my_id=5

 So on mypage.php, I capture this value with:
 $my_id=$_GET['my_id'];

 I understand this much.  But when the end user submits this contact form
 they do so to formcheck.php and if formcheck.php sees a required field is
 blank, it throws it back to mypage.php with an alert.  BUT, I lose the value
 of the variable $my_id.  SO, I created a hidden field on mypate.php with
  value=?php echo $my_id; ? and on formcheck.php, I added $my_id =
 $_Post['my_id'];

 However, when formcheck.php returns me to mypage.php, $my_id is still blank.

 Very frustrating.

 Any help determining what I am doing wrong is greatly appreciated.

 Thanks.



  --Rick


 On Feb 25, 2010, at 12:31 AM, Paul M Foster wrote:

 On Thu, Feb 25, 2010 at 12:16:08AM -0500, Robert Cummings wrote:

 Rick Dwyer wrote:

 Hello all.

 I'm trying to learn PHP on the fly and I have a line of code that
 contains syntax I can't find documented anywhere:

 php echo check('element8');

 In the above line, can someone tell me what check means?


 In the above, check is a function. It is being called with parameter
 'element8'.

 This is true. But perhaps more importantly, check() is not a native PHP
 function. Thus it comes from some other library or group of external
 functions.

 Paul

 --
 Paul M. Foster

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





-- 
~viraj

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



Re: [PHP] PHP Syntax Help - Check?

2010-02-24 Thread James McLean
On Thu, Feb 25, 2010 at 4:22 PM, Rick Dwyer rpdw...@earthlink.net wrote:
 OK... external function... that would explain why I could not locate it.

 Let me get right to the problem I am having with this code as someone may be
 able to help directly.

 I have a link on a page that opens a contact form.  The link is
 mypage.php?my_id=5

 So on mypage.php, I capture this value with:
 $my_id=$_GET['my_id'];

 I understand this much.  But when the end user submits this contact form
 they do so to formcheck.php and if formcheck.php sees a required field is
 blank, it throws it back to mypage.php with an alert.  BUT, I lose the value
 of the variable $my_id.  SO, I created a hidden field on mypate.php with
  value=?php echo $my_id; ? and on formcheck.php, I added $my_id =
 $_Post['my_id'];

 However, when formcheck.php returns me to mypage.php, $my_id is still blank.

Use the right varialble for the method you're using, so if you're
posting, use $_POST, if you're getting use $_GET..

Going by your example, $_GET is what you should probably be using,
this is usually the default method if no method is specified on the
form tag.

Cheers

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



Re: [PHP] PHP Syntax Help - Check?

2010-02-24 Thread Rick Dwyer

Hmm.  OK with the help below, I am closer.

The other fields on the page are getting passed via form fields that  
look like this:


input  type=text value=?php echo check('element9'); ?  
name=form[element9] size=40 maxlength=255

so I added:
input  type=text value=?php echo check('my_id'); ?  
name=form[my_id] size=40 maxlength=255



and formcheck.php has:

?php
//start the session
session_start();

//array of fields in form. (In the format field_name = field_label)
$form_fields = array(
element0 = 'Your Name:',
element1 = 'Your Email:',
element4 = 'Item Number:',
.
);
and I added:
my_id = 'My ID Is:',

And this works!
So when I am on mypage.php and I enter a value into the form field  
my_id it carries over and repopulates should the form fail validation.


But upon initial load of the page from my link of mypage.php?my_id=5  
(so I am not getting there via a form submit) how do I get the value  
into the form field?



 --Rick


On Feb 25, 2010, at 1:02 AM, viraj wrote:


if you do the redirection with header('Location: /mypage.php'),
setting a variable on formcheck.php is not enough.

if you modify the header('Location: /mypage.php') to..

header('Location: /mypage.php?my_id=5')

it will take the variable to mypage.php as $_GET['my_id]

you can not expect a variable value set in to $_POST array to reflect
on a totally different page without making it a form post (aka use of
proper headers).

i guess, it's time to you to read about session_start() method and the
array $_SESSION available in php :)


~viraj

On Thu, Feb 25, 2010 at 11:22 AM, Rick Dwyer rpdw...@earthlink.net  
wrote:
OK... external function... that would explain why I could not  
locate it.


Let me get right to the problem I am having with this code as  
someone may be

able to help directly.

I have a link on a page that opens a contact form.  The link is
mypage.php?my_id=5

So on mypage.php, I capture this value with:
$my_id=$_GET['my_id'];

I understand this much.  But when the end user submits this contact  
form
they do so to formcheck.php and if formcheck.php sees a required  
field is
blank, it throws it back to mypage.php with an alert.  BUT, I lose  
the value
of the variable $my_id.  SO, I created a hidden field on mypate.php  
with

 value=?php echo $my_id; ? and on formcheck.php, I added $my_id =
$_Post['my_id'];

However, when formcheck.php returns me to mypage.php, $my_id is  
still blank.


Very frustrating.

Any help determining what I am doing wrong is greatly appreciated.

Thanks.



 --Rick


On Feb 25, 2010, at 12:31 AM, Paul M Foster wrote:


On Thu, Feb 25, 2010 at 12:16:08AM -0500, Robert Cummings wrote:


Rick Dwyer wrote:


Hello all.

I'm trying to learn PHP on the fly and I have a line of code that
contains syntax I can't find documented anywhere:

php echo check('element8');

In the above line, can someone tell me what check means?



In the above, check is a function. It is being called with  
parameter

'element8'.


This is true. But perhaps more importantly, check() is not a  
native PHP

function. Thus it comes from some other library or group of external
functions.

Paul

--
Paul M. Foster

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






--
~viraj

--
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: HipHop and other PHP compiler performance evaluation

2010-02-24 Thread Mark Cilissen

Manuel Lemos schreef:

FYI

http://digg.com/programming/PHP_compiler_performance



A nice article, thank you for the information!

--
Kind regards,
Mark Cilissen / Pixlism

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