Re: [PHP] Variable problem?
[ For those of you who are going to get pissed for top-posting, find something better to bitch about. I'm in a rush, but trying to help. ;-P ] Luc, You're not defining $contato_name. Do this: $contato_name = $_POST['contato_name']; On 7/24/07, Luc [EMAIL PROTECTED] wrote: Good afternoon list, Probably a no-brainer for the most of you but i'm in a pickle: i've set up a variable to receive in the body of the notification mail upon sending a form. The body of the mail should read like this: Obrigado por nos contatar, $contato_name. Recebemos sua mensagem e entraremos em contato em breve. (in english: tnx for contacting us, $contato_name. We received your message and will contact you shortly.) Where $contato_name is the name of the contact, as used in the form. The problem is that the message arrives without the $contato_name, so i get: Obrigado por nos contatar, . Recebemos sua mensagem e entraremos em contato em breve. Here's the script: ? // set your own preferences here # // Your email address $youremail = ; // Your web site title (John Doe's Site) $websitetitle = ; // Path to thanks for the message page $thankyoupage = ' '; // Send notification to sender (use false if not required) $sendnotification = true; // Continue with your error checking, output of form, et cetera. $contact_form_action = $_SERVER['PHP_SELF']; if ((isset($_POST[sendcontact])) ($_POST[sendcontact] == contactsent)) { $contacter_form_error = array(); if (empty($_POST['empresa_name'])){ $contacter_form_error[] = 'favor preencher nome da empresa'; } if (empty($_POST['contato_name'])){ $contacter_form_error[] = 'favor preencher nome do contato'; } if (empty($_POST['fone'])){ $contacter_form_error[] = 'favor preencher número do telefone'; } if (empty($_POST['contato_email'])){ $contacter_form_error[] = 'favor preencher seu e-mail'; } if (empty($_POST['produto'])){ $contacter_form_error[] = 'favor preencher o produto'; } if (empty($_POST['origem'])){ $contacter_form_error[] = 'favor preencher origem'; } if (empty($_POST['destino'])){ $contacter_form_error[] = 'favor preencher destino'; } if (empty($_POST['quantidade'])){ $contacter_form_error[] = 'favor preencher quantidade'; } if (empty($_POST['peso'])){ $contacter_form_error[] = 'favor preencher peso'; } if (empty($_POST['comprimento'])){ $contacter_form_error[] = 'favor preencher comprimento'; } if (empty($_POST['altura'])){ $contacter_form_error[] = 'favor preencher altura'; } if (empty($_POST['largura'])){ $contacter_form_error[] = 'favor preencher largura'; } else { $empresa_name = stripslashes($_POST['empresa_name']); $contato_email = stripslashes($_POST['contato_email']); $body =EOB Empresa: $_POST[empresa_name] Contato: $_POST[contato_name] Fone: $_POST[fone] Fax: $_POST[fax] Email: $_POST[contato_email] Produto: $_POST[produto] Origem: $_POST[origem] Destino: $_POST[destino] Quantidade: $_POST[quantidade] Peso: $_POST[peso] Comprimento: $_POST[comprimento] Altura: $_POST[altura] Largura: $_POST[largura] EOB; $subjectline = $websitetitle | Orçamento de empresa; $notification_message = Obrigado por nos contatar, $contato_name. Recebemos sua mensagem e entraremos em contato em breve.; $notification_subject = Obrigado por sua mensagem para $websitetitle.; mail($contato_email,$subjectline,$body, From: $contato_email); mail($contato_email, $notification_subject, $notification_message, From: $youremail); header(Location:$thankyoupage); } } ? // Print form field errors if present if (count($contacter_form_error)0){ print 'p id=bottomstrongAlgo está errado:/strong/p'.\n; print 'ul'.\n; foreach($contacter_form_error as $form_err) { print li class=\error\$form_err/li\n; } print '/ul'.\n; } ? form method=post id=contactform action=? print $contact_form_action; ? pTodos os campos obrigatórios são marcados com asteriscos (span class=required*/span)./p fieldset legendSeus Dados/legend label for=empresa_nameEmpresa span class=required*/span/label br / input type=text id=empresa_name name=empresa_name size=30 value=? print $empresa_name; ? / br / label for=contato_nameContato span class=required*/span/label br / input type=text id=contato_name name=contato_name size=30 value=? print $contato_name; ? / br / label for=foneNúmero do telefone span class=required*/span/label br / input
Re: [PHP] Variable problem?
Good evening Daniel, It was foretold that on 24/7/2007 @ 17:47:46 GMT-0400 (which was 18:47:46 where I live) Daniel Brown would write: snipped a bit You're not defining $contato_name. Do this: $contato_name = $_POST['contato_name']; Yes!! Oh so simple for a non-newbie lol. It works like a charm Daniel. I'm really, really grateful!!! -- Best regards, Luc _ Powered by The Bat! version 3.99.3 with Windows XP (build 2600), version 5.1 Service Pack 2 and using the best browser: Opera. The pleasure of love is in loving. We are happier in the passion we feel than in that we inspire. - François, duc de La Rochefoucauld (1613–1680) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable problem?
On Tue, July 24, 2007 3:33 pm, Luc wrote: if (empty($_POST['altura'])){ $contacter_form_error[] = 'favor preencher altura'; } if (empty($_POST['largura'])){ $contacter_form_error[] = 'favor preencher largura'; } else { $empresa_name = stripslashes($_POST['empresa_name']); $contato_email = stripslashes($_POST['contato_email']); I think you're just missing $contato_name = $_POST['contato_name'] in here somewhere... I got kinda lost, though. That said, if you are using striplashes, you have magic_quotes_gpc on, and that's something you may want to turn off in the first place. Or consider checking if it's on in your code rather than assuming it's on. -- 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
Re: Re: RE: [PHP] Variable Problem
no that doesnt work either what you get when you do that one in the edit box is: using: input type=text name=sent value=?php echo \$sent\;? or any different with echo in the value field gives me in the box: ?php \\;?} ...rest of the script outside the box - Original Message - From: Jason Wong [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, February 06, 2003 12:25 AM Subject: Re: Re: RE: [PHP] Variable Problem On Thursday 06 February 2003 07:48, Sunfire wrote: on any server i ever dealt with if i put: input type=sent value=?php\$sent\? in the edit box for the value i always always end up with ?php instead of what $sent stands for..the only way i found it to work is with echo but maybe im missing something With the above you should end up with a parse error. The correct syntax which should work regardless of your server settings is: input type=sent value=?php echo $sent; ? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Don't worry. Life's too long. -- Vincent Sardi, Jr. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: RE: [PHP] Variable Problem
On Thursday 06 February 2003 22:50, Sunfire wrote: no that doesnt work either what you get when you do that one in the edit box is: using: input type=text name=sent value=?php echo \$sent\;? or any different with echo in the value field gives me in the box: ?php \\;?} ...rest of the script outside the box Spot the difference between your code above and my code below: input type=sent value=?php echo $sent; ? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Save the whales. Collect the whole set. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable Problem
On Thursday 06 February 2003 04:41, Sierra Times.com wrote: I have a variable that get's chopped off at the %20 character. In the form page I have: bFrom: ?= $name;? brE-mail address: ?= $email;?br ?= $sent;?/b/font/td $sent and $name shows up fine, but immedieately I added (for testing) input type=text name=sent value=?= $sent;? input type=text name=name value=?= $name;? this statement shows a text box, with only the first word before the space charcter %20 is shown, and is fact the only data that is submitted upon: form action=?=$PHP_SELF;? method=post Can someone assist me? J.J. Johnson Proper HTML has value items enclosed in quotes: value=SOMETHING -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Liar: one who tells an unpleasant truth. -- Oliver Herford */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Variable Problem
You need to put quotes around the vars. If I were you I would do this: print input type=text name=sent value=\$sent\; print input type=text name=name value=\$name\; You need the quotes. Leonard. www.phpna.com -Original Message- From: Sierra Times.com [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 05, 2003 3:41 PM To: [EMAIL PROTECTED] Subject: [PHP] Variable Problem I have a variable that get's chopped off at the %20 character. In the form page I have: bFrom: ?= $name;? brE-mail address: ?= $email;?br ?= $sent;?/b/font/td $sent and $name shows up fine, but immedieately I added (for testing) input type=text name=sent value=?= $sent;? input type=text name=name value=?= $name;? this statement shows a text box, with only the first word before the space charcter %20 is shown, and is fact the only data that is submitted upon: form action=?=$PHP_SELF;? method=post Can someone assist me? J.J. Johnson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] Variable Problem
if you want to get variables into a form by value= do something like this: ?php echo BLOCK form action=php_self method=post input type=var1 value=\var1\br and so on - Original Message - From: Jason Wong [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, February 05, 2003 3:59 PM Subject: Spam: Re: [PHP] Variable Problem On Thursday 06 February 2003 04:41, Sierra Times.com wrote: I have a variable that get's chopped off at the %20 character. In the form page I have: bFrom: ?= $name;? brE-mail address: ?= $email;?br ?= $sent;?/b/font/td $sent and $name shows up fine, but immedieately I added (for testing) input type=text name=sent value=?= $sent;? input type=text name=name value=?= $name;? this statement shows a text box, with only the first word before the space charcter %20 is shown, and is fact the only data that is submitted upon: form action=?=$PHP_SELF;? method=post Can someone assist me? J.J. Johnson Proper HTML has value items enclosed in quotes: value=SOMETHING -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Liar: one who tells an unpleasant truth. -- Oliver Herford */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RE: [PHP] Variable Problem
you can do: echo BLOCK //any valid html code here input type=sent value=\sent\ BLOCK; it is easier if you have a form or large amounts of code to echo/print to the screen with vars and stuff to use the echo stuff its pretty cluttered and its harder to use print or echo for every line of code you need to echo...specially if there are 300 lines of code a block... - Original Message - From: Leonard Burton [EMAIL PROTECTED] To: Sierra Times.com [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, February 05, 2003 4:16 PM Subject: Spam: RE: [PHP] Variable Problem You need to put quotes around the vars. If I were you I would do this: print input type=text name=sent value=\$sent\; print input type=text name=name value=\$name\; You need the quotes. Leonard. www.phpna.com -Original Message- From: Sierra Times.com [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 05, 2003 3:41 PM To: [EMAIL PROTECTED] Subject: [PHP] Variable Problem I have a variable that get's chopped off at the %20 character. In the form page I have: bFrom: ?= $name;? brE-mail address: ?= $email;?br ?= $sent;?/b/font/td $sent and $name shows up fine, but immedieately I added (for testing) input type=text name=sent value=?= $sent;? input type=text name=name value=?= $name;? this statement shows a text box, with only the first word before the space charcter %20 is shown, and is fact the only data that is submitted upon: form action=?=$PHP_SELF;? method=post Can someone assist me? J.J. Johnson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RE: [PHP] Variable Problem
--- Sunfire [EMAIL PROTECTED] wrote: you can do: echo BLOCK //any valid html code here input type=sent value=\sent\ BLOCK; No, he needed to output $sent, which is dynamic. Also, it is a lot cleaner (and likely faster) just to use ? (or ?php) and ? to switch in/out of PHP as needed. If you're writing a bunch of static HTML, there's no reason to be using PHP to do it. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: RE: [PHP] Variable Problem
on any server i ever dealt with if i put: input type=sent value=?php\$sent\? in the edit box for the value i always always end up with ?php instead of what $sent stands for..the only way i found it to work is with echo but maybe im missing something - Original Message - From: Chris Shiflett [EMAIL PROTECTED] To: Sunfire [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, February 05, 2003 5:44 PM Subject: Spam: Re: RE: [PHP] Variable Problem --- Sunfire [EMAIL PROTECTED] wrote: you can do: echo BLOCK //any valid html code here input type=sent value=\sent\ BLOCK; No, he needed to output $sent, which is dynamic. Also, it is a lot cleaner (and likely faster) just to use ? (or ?php) and ? to switch in/out of PHP as needed. If you're writing a bunch of static HTML, there's no reason to be using PHP to do it. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: RE: [PHP] Variable Problem
--- Sunfire [EMAIL PROTECTED] wrote: on any server i ever dealt with if i put: input type=sent value=?php\$sent\? in the edit box for the value i always always end up with ?php instead of what $sent stands for..the only way i found it to work is with echo but maybe im missing something You are missing correct PHP syntax and correct HTML syntax, so I guess that counts as something. Try this: input type=text name=foo value=? echo $foo; ? or this: ? echo input type=\text\ name=\foo\ value=\$foo\; ? Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: RE: [PHP] Variable Problem
On Thursday 06 February 2003 07:48, Sunfire wrote: on any server i ever dealt with if i put: input type=sent value=?php\$sent\? in the edit box for the value i always always end up with ?php instead of what $sent stands for..the only way i found it to work is with echo but maybe im missing something With the above you should end up with a parse error. The correct syntax which should work regardless of your server settings is: input type=sent value=?php echo $sent; ? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Don't worry. Life's too long. -- Vincent Sardi, Jr. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Variable problem
show your code -Original Message- From: Leif K-Brooks [mailto:[EMAIL PROTECTED]] Sent: Friday, March 22, 2002 5:18 PM To: [EMAIL PROTECTED] Subject: [PHP] Variable problem I have a variable name in a print END and then some text after it. The thing is, php thinks that the text is part of the variable name, which makes the variable, and the text after it, not show up. But, if I put a space, it makes my html not work right. Any ideas? -- 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] Variable problem
${varable}ABC -Original Message- From: Leif K-Brooks [mailto:[EMAIL PROTECTED]] Sent: Friday, March 22, 2002 5:21 PM To: Rick Emery Subject: Re: [PHP] Variable problem on 3/22/02 6:18 PM, Rick Emery at [EMAIL PROTECTED] wrote: show your code -Original Message- From: Leif K-Brooks [mailto:[EMAIL PROTECTED]] Sent: Friday, March 22, 2002 5:18 PM To: [EMAIL PROTECTED] Subject: [PHP] Variable problem I have a variable name in a print END and then some text after it. The thing is, php thinks that the text is part of the variable name, which makes the variable, and the text after it, not show up. But, if I put a space, it makes my html not work right. Any ideas? It's something like this: print END $varableABC END;
RE: [PHP] Variable problem
On 22 Mar 2002 at 17:27, Rick Emery wrote: ${varable}ABC in quotes you can help php with {$(varabl)}ABC -Original Message- From: Leif K-Brooks [mailto:[EMAIL PROTECTED]] Sent: Friday, March 22, 2002 5:21 PM To: Rick Emery Subject: Re: [PHP] Variable problem on 3/22/02 6:18 PM, Rick Emery at [EMAIL PROTECTED] wrote: show your code -Original Message- From: Leif K-Brooks [mailto:[EMAIL PROTECTED]] Sent: Friday, March 22, 2002 5:18 PM To: [EMAIL PROTECTED] Subject: [PHP] Variable problem I have a variable name in a print END and then some text after it. The thing is, php thinks that the text is part of the variable name, which makes the variable, and the text after it, not show up. But, if I put a space, it makes my html not work right. Any ideas? It's something like this: print END $varableABC END; -- ! please check my email address ! ! only my email [EMAIL PROTECTED] works ! ! email [EMAIL PROTECTED] is a black hole since januari 2002 ! Chris Hayes - Droef 35 - Wageningen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable problem
I heard before that you can store session variables in a database rather than using the tmp directory etc etc..Does anybody have any links on this? Thanks Randy - Original Message - From: Yoel Benitez Fonseca [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, January 18, 2002 2:26 PM Subject: RE: [PHP] Variable problem Use an array !?, I mean : $result[$i] = test; How do I combine the following so it is treated as one variable $i=10 $result$i=test; I want this to be: $result10=test; $i changes so I cannot just put in 10 instead of I. anybody know how i can do that? -- Yoel Benitez Fonseca -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable Problem
?php $i = 10; eval (\$result$i=\test\;); echo $result10; ? Valentin Petruchek (aki Zliy Pes) http://zliypes.com.ua mailto:[EMAIL PROTECTED] - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, January 19, 2002 2:47 AM Subject: [PHP] Variable Problem How do I combine the following so it is treated as one variable $i=10 $result$i=test; I want this to be: $result10=test; $i changes so I cannot just put in 10 instead of I. anybody know how i can do that? TIA Randy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Variable problem
Use an array !?, I mean : $result[$i] = test; How do I combine the following so it is treated as one variable $i=10 $result$i=test; I want this to be: $result10=test; $i changes so I cannot just put in 10 instead of I. anybody know how i can do that? -- Yoel Benitez Fonseca -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Variable Problem
Hello. How do I combine the following so it is treated as one variable $i=10 $result$i="test"; I want this to be: $result10="test"; $i changes so I cannot just put in 10 instead of I. anybody know how i can do that? TIA Randy How about the below. ? $i=10; ${"result$i"}="test"; echo $result10; ? or ? $i=10; ${'result'.$i}="test"; echo $result10; ? Cheers :-) --- K.Tomono -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Variable Problem
How do I combine the following so it is treated as one variable. It's a good question, but why? Most likely an array will work best for this job, arrays are good: http://www.php.net/manual/en/language.types.array.php The man page on foreach is nice too, and has many examples which include while/list alternatives: http://www.php.net/manual/en/control-structures.foreach.php Your question was answered below but I couldn't resist throwing in a little array propaganda, jic :) Arrays work great in forms too! http://www.php.net/manual/en/faq.html.php#AEN73718 Regards, Philip Olson $i=10 $result$i=test; I want this to be: $result10=test; $i changes so I cannot just put in 10 instead of I. anybody know how i can do that? TIA Randy How about the below. ? $i=10; ${result$i}=test; echo $result10; ? or ? $i=10; ${'result'.$i}=test; echo $result10; ? Cheers :-) --- K.Tomono -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Variable Problem
Yes, I think too, it's better way to use an array rather than a dynamic name of the variable. I thought that the first question means how to use a dynamic variable. By the way, little array propaganda, jic :) Arrays work great in forms too! http://www.php.net/manual/en/faq.html.php#AEN73718 Does this technique work fine on the version 3.0.14 later to 3.0.18 of PHP? (Not PHP4) I tried an array in forms simply like below in the other day, but this didn't work fine... ( for the checkboxes ) INPUT TYPE=CHECKBOX NAME=MYCHK VALUE=A INPUT TYPE=CHECKBOX NAME=MYCHK VALUE=B Unfortunately, I had thought that it could be got as an array, but variable $MYCHK is overwritten by the last value B always. (To mention about java servlet, this value could be retrieved by the syntax as below. (HttpServletRequest)request.getParameterValues(MYCHK)[0] off course, such a syntax occurs an error on PHP. ;D) -- Well, I'll try the technique you mentioned. Your offering is very appreciated. Thank you! :-] ps. execute me for my english... --- K.Tomono -Original Message- From: Philip Olson [mailto:[EMAIL PROTECTED]] Sent: Saturday, January 19, 2002 2:30 PM To: Fì¤á Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP] Variable Problem How do I combine the following so it is treated as one variable. It's a good question, but why? Most likely an array will work best for this job, arrays are good: http://www.php.net/manual/en/language.types.array.php The man page on foreach is nice too, and has many examples which include while/list alternatives: http://www.php.net/manual/en/control-structures.foreach.php Your question was answered below but I couldn't resist throwing in a little array propaganda, jic :) Arrays work great in forms too! http://www.php.net/manual/en/faq.html.php#AEN73718 Regards, Philip Olson $i=10 $result$i=test; I want this to be: $result10=test; $i changes so I cannot just put in 10 instead of I. anybody know how i can do that? TIA Randy How about the below. ? $i=10; ${result$i}=test; echo $result10; ? or ? $i=10; ${'result'.$i}=test; echo $result10; ? Cheers :-) --- K.Tomono -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Variable Problem
I hope im on the right track Cause im jumping in on this post. $MYCHK isn't an array cause you aren't using array syntax or simply left out the brackets. try: ( for the checkboxes ) INPUT TYPE=CHECKBOX NAME=MYCHK[] VALUE=A INPUT TYPE=CHECKBOX NAME=MYCHK[] VALUE=B I have done this 100's of times. Hope this helps, Steve On Sat, 19 Jan 2002, K.Tomono wrote: Yes, I think too, it's better way to use an array rather than a dynamic name of the variable. I thought that the first question means how to use a dynamic variable. By the way, little array propaganda, jic :) Arrays work great in forms too! http://www.php.net/manual/en/faq.html.php#AEN73718 Does this technique work fine on the version 3.0.14 later to 3.0.18 of PHP? (Not PHP4) I tried an array in forms simply like below in the other day, but this didn't work fine... ( for the checkboxes ) INPUT TYPE=CHECKBOX NAME=MYCHK VALUE=A INPUT TYPE=CHECKBOX NAME=MYCHK VALUE=B Unfortunately, I had thought that it could be got as an array, but variable $MYCHK is overwritten by the last value B always. (To mention about java servlet, this value could be retrieved by the syntax as below. (HttpServletRequest)request.getParameterValues(MYCHK)[0] off course, such a syntax occurs an error on PHP. ;D) -- Well, I'll try the technique you mentioned. Your offering is very appreciated. Thank you! :-] ps. execute me for my english... --- K.Tomono -Original Message- From: Philip Olson [mailto:[EMAIL PROTECTED]] Sent: Saturday, January 19, 2002 2:30 PM To: Fì¤á Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP] Variable Problem How do I combine the following so it is treated as one variable. It's a good question, but why? Most likely an array will work best for this job, arrays are good: http://www.php.net/manual/en/language.types.array.php The man page on foreach is nice too, and has many examples which include while/list alternatives: http://www.php.net/manual/en/control-structures.foreach.php Your question was answered below but I couldn't resist throwing in a little array propaganda, jic :) Arrays work great in forms too! http://www.php.net/manual/en/faq.html.php#AEN73718 Regards, Philip Olson $i=10 $result$i=test; I want this to be: $result10=test; $i changes so I cannot just put in 10 instead of I. anybody know how i can do that? TIA Randy How about the below. ? $i=10; ${result$i}=test; echo $result10; ? or ? $i=10; ${'result'.$i}=test; echo $result10; ? Cheers :-) --- K.Tomono -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] variable problem - help!
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 * On 16-01-02 at 12:45 * Dani said Hi! I 'm trying not to hard code my php coding and I'm trying to pass a variable name into the $row[coloumname_$variable]; I get an error message for this code. I'm just wondering if I could do this trick using other ways of writing it. I'm not sure of the syntax but you need to be looking ar variable variables, there's a whole section on it in the manual. HTH - -- Nick Wilson Tel:+45 3325 0688 Fax:+45 3325 0677 Web:www.explodingnet.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE8RWi2HpvrrTa6L5oRAimZAJ4kWwE6Fz9VZgzFZv/1Xl9rfvBZVgCgss/C veKKxbVcUnV493/ykZzoLXw= =G3iP -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] variable problem - help!
Hi! I 'm trying not to hard code my php coding and I'm trying to pass a variable name into the $row[coloumname_$variable]; $row[columname_$variable] should do it. $row[constant] is threaten as constant which is normally not the programmers intention (set_error_reporting(0) and you'll see PHP's complaints about it) so PHP converts it to $row['constant']. You may now understand, that PHP translates your code to $row['coloumname_$variable'] whre $variable is a string and not a variable. I hope, I could express myself understandable :) best regards Stefan Rusterholz -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] variable problem - help!
$row[coloumname_${v$ariable}] -Original Message- From: Dani [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 16, 2002 8:36 AM To: [EMAIL PROTECTED] Subject: [PHP] variable problem - help! Importance: High Hi! I 'm trying not to hard code my php coding and I'm trying to pass a variable name into the $row[coloumname_$variable]; I get an error message for this code. I'm just wondering if I could do this trick using other ways of writing it. Thanks for reviewing! regards, Dani -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Variable Problem when UPGRADING...
hi again james, btw, consider doing this : if (empty($submit)) { or if (!empty($submit)) { as it doesn't run into such problems. or use isset although i tend to almost always use empty, i LOVE empty() !!! each have their uses : http://www.php.net/manual/en/function.empty.php http://www.php.net/manual/en/function.isset.php there are also compare functions such as : http://www.php.net/manual/en/function.strcmp.php but anyway, those are other options to consider. options are good. but really for such things use empty(), also the following is bad form (imho of course) : if ($var == '') { regards, philip olson http://www.cornado.com/ On Mon, 29 Jan 2001, James Smith wrote: Alright, when i was programming with PHP3, I would use if statements like this: if(!$submit) { // display form } else { // display signup complete } to make multiple pages. Or I would do this: if($action == "signup") { if(!$submit) { //display form } else { // display signup complete } } if($action == "login") { // show login screen } But now I get an error like this: Warning: Undefined variable: submit in c:\apache\htdocs\test.php on line 3 I don't know if I misconfigured my php.ini file or what. Thanks, James __ Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Variable Problem when UPGRADING...
James Smith wrote: Alright, when i was programming with PHP3, I would use if statements like this: if(!$submit) { // display form } else { // display signup complete } to make multiple pages. Or I would do this: if($action == "signup") { if(!$submit) { //display form } else { // display signup complete } } if($action == "login") { // show login screen } But now I get an error like this: Warning: Undefined variable: submit in c:\apache\htdocs\test.php on line 3 I don't know if I misconfigured my php.ini file or what. Very likely you used the optimized version of php.ini which has global variables registration off. As for your question, I can tell you my tip: I use input type="submit" name="action[login]" value="Login" input type="submit" name="action[signup]" value="SignUp" and in the form do: $PV = $HTTP_POST_VARS; $action = isset ($PV['action']) ? key($PV['action']) : 'default-action-here'; switch ($action) { // allows lots of action w/o too many ifs and such case 'login': // login break; case 'signup': // signup break; case 'default-action': default: // evetually break; } so on. hope it helps ciao -- teodor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Variable Problem when UPGRADING...
You set error_reporting to 15 (E_ALL) instead of 7. Turn it back down to 7 or fix your scripts to use if (isset($submit)){ } -- Visit the Zend Store at http://www.zend.com/store/ Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm - Original Message - From: James Smith [EMAIL PROTECTED] Newsgroups: php.general Sent: Tuesday, January 30, 2001 1:54 AM Subject: [PHP] Variable Problem when UPGRADING... Alright, when i was programming with PHP3, I would use if statements like this: if(!$submit) { // display form } else { // display signup complete } to make multiple pages. Or I would do this: if($action == "signup") { if(!$submit) { file://display form } else { // display signup complete } } if($action == "login") { // show login screen } But now I get an error like this: Warning: Undefined variable: submit in c:\apache\htdocs\test.php on line 3 I don't know if I misconfigured my php.ini file or what. Thanks, James __ Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Variable Problem when UPGRADING...
this has to do with error reporting, using the function : http://www.php.net/manual/en/function.error-reporting.php definition of types : http://www.php.net/manual/en/phpdevel-errors.php you may have E_ALL or E_NOTICE on within php.ini philip olson http://www.cornado.com/ On Mon, 29 Jan 2001, James Smith wrote: Alright, when i was programming with PHP3, I would use if statements like this: if(!$submit) { // display form } else { // display signup complete } to make multiple pages. Or I would do this: if($action == "signup") { if(!$submit) { //display form } else { // display signup complete } } if($action == "login") { // show login screen } But now I get an error like this: Warning: Undefined variable: submit in c:\apache\htdocs\test.php on line 3 I don't know if I misconfigured my php.ini file or what. Thanks, James __ Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]