PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > Newbie ' If Statement' Question
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Newbie ' If Statement' Question

Réponse
 
LinkBack Outils de la discussion
Vieux 15/03/2008, 00h56   #1
cool7@hosting4days.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Newbie ' If Statement' Question

Hello Folks,

I would like to be able to wrap a 'form' inside a php 'if statement' - so
that the form will appear if the 'if condition' is met.

- most likely I cannot have a <?php tag inside another one - and am sure
I'm doing other things wrong also...
- now I get the error - Parse error: syntax error, unexpected T_STRING in...

Q: What is the best way to accomplish this goal?


-----------------------

<?php if ($emp_row->getField('testfield') !="") {
print "<form name="edit" method="post" action="emp_edit_result2.php">
<input type="hidden" name="Status" value="Active"/>
<input type="hidden" name="The_Date" value=""/>
<input type="hidden" name="-recid" value="<?php echo
$emp_row->getRecordId(); ?>">
<input type="submit" name="edit_submit" value="Activate">
</form>

";}else {print "Non Print";} ?>



--
Thanks - RevDave
Cool7 @ hosting4days . com
[db-lists]



  Réponse avec citation
Vieux 15/03/2008, 01h08   #2
Nathan Nobbe
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Newbie ' If Statement' Question

On Fri, Mar 14, 2008 at 7:56 PM, cool7@hosting4days.com <
cool7@hosting4days.com> wrote:

> Hello Folks,
>
> I would like to be able to wrap a 'form' inside a php 'if statement' - so
> that the form will appear if the 'if condition' is met.
>
> - most likely I cannot have a <?php tag inside another one - and am sure
> I'm doing other things wrong also...
> - now I get the error - Parse error: syntax error, unexpected T_STRING
> in...
>
> Q: What is the best way to accomplish this goal?
>
> -----------------------
>
> <?php if ($emp_row->getField('testfield') !="") {
> print "<form name="edit" method="post" action="emp_edit_result2.php">
> <input type="hidden" name="Status" value="Active"/>
> <input type="hidden" name="The_Date" value=""/>
> <input type="hidden" name="-recid" value="<?php echo
> $emp_row->getRecordId(); ?>">
> <input type="submit" name="edit_submit" value="Activate">
> </form>
>
> ";}else {print "Non Print";} ?>
>


something like this,

<?php if($emp_row->getField('testfield') != '') { ?>
<form name="edit" method="post" action="emp_edit_result2.php">
<input type="hidden" name="Status" value="Active" />
<input type="hidden" name="The_Date" value="" />
<input type="hidden" name="-recid" value="<?php echo
$emp_row->getRecordId(); ?> />
<input type="submit" name="edit_submit" value="Activate" />
</form>
<?php } ?>

// warning: typed directly into browser w/ no testing

-nathan

  Réponse avec citation
Vieux 15/03/2008, 01h09   #3
Benjamin Darwin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Newbie ' If Statement' Question

On Fri, Mar 14, 2008 at 7:56 PM, cool7@hosting4days.com <
cool7@hosting4days.com> wrote:

> Hello Folks,
>
> I would like to be able to wrap a 'form' inside a php 'if statement' - so
> that the form will appear if the 'if condition' is met.
>
> - most likely I cannot have a <?php tag inside another one - and am sure
> I'm doing other things wrong also...
> - now I get the error - Parse error: syntax error, unexpected T_STRING
> in...
>
> Q: What is the best way to accomplish this goal?
>
>
> -----------------------
>
> <?php if ($emp_row->getField('testfield') !="") {
> print "<form name="edit" method="post" action="emp_edit_result2.php">
> <input type="hidden" name="Status" value="Active"/>
> <input type="hidden" name="The_Date" value=""/>
> <input type="hidden" name="-recid" value="<?php echo
> $emp_row->getRecordId(); ?>">
> <input type="submit" name="edit_submit" value="Activate">
> </form>
>
> ";}else {print "Non Print";} ?>
>
>
>
> --
> Thanks - RevDave
> Cool7 @ hosting4days . com
> [db-lists]
>


Your first mistake I'm finding is the use of quotes. You started the print
with a ", which means the print ends at name=", and it's expecting more PHP
code, rather than a HTML string. The first fix would be to either escape all
quotes in the HTML with a slash (\) before it, or to change your opening and
closing quotes on the print to a single quote (').
Second, yes, you cannot enclose PHP tags inside PHP tags. To do this,
change that portion to end the print, attach the two portions with a period
(.) and start up with the php function, then a period, and back to the
print.

Here's a fix that should work. I haven't tested it though, so I may have
missed one or two quotes.

<?php if ($emp_row->getField('testfield') !="") {
print "<form name=\"edit\" method=\"post\"
action=\"emp_edit_result2.php\">
<input type=\"hidden\" name=\"Status\" value=\"Active\"/>
<input type=\"hidden\" name=\"The_Date\" value=\"\"/>
<input type=\"hidden\" name=\"-recid\" value=\""$emp_row->getRecordId()."\">
<input type=\"submit\" name=\"edit_submit\" value=\"Activate\">
</form>

";}else {print "Non Print";} ?>

  Réponse avec citation
Vieux 16/03/2008, 16h38   #4
cool7@hosting4days.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Newbie ' If Statement' Question

Thank you everybody for these great tips!


--
Thanks - RevDave
Cool7 @ hosting4days . com
[db-lists]



  Réponse avec citation
Vieux 16/03/2008, 20h03   #5
Al
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie ' If Statement' Question

Here's how I'd do it.

<?php
$row= $emp_row->getRecordId();//Or, you can put this inside the heredoc with {}

//heredoc
$str= <<<txt
<form name="edit" method="post" action="emp_edit_result2.php">
<input type="hidden" name="Status" value="Active" />
<input type="hidden" name="The_Date" value="" />
<input type="hidden" name="-recid" value="$row" />
<input type="submit" name="edit_submit" value="Activate" />
</form>
txt;

if (!empty($emp_row->getField('testfield')) print $str;
else print "Non Print";
?>


cool7@hosting4days.com wrote:
> Hello Folks,
>
> I would like to be able to wrap a 'form' inside a php 'if statement' - so
> that the form will appear if the 'if condition' is met.
>
> - most likely I cannot have a <?php tag inside another one - and am sure
> I'm doing other things wrong also...
> - now I get the error - Parse error: syntax error, unexpected T_STRING in...
>
> Q: What is the best way to accomplish this goal?
>
>
> -----------------------
>
> <?php if ($emp_row->getField('testfield') !="") {
> print "<form name="edit" method="post" action="emp_edit_result2.php">
> <input type="hidden" name="Status" value="Active"/>
> <input type="hidden" name="The_Date" value=""/>
> <input type="hidden" name="-recid" value="<?php echo
> $emp_row->getRecordId(); ?>">
> <input type="submit" name="edit_submit" value="Activate">
> </form>
>
> ";}else {print "Non Print";} ?>
>
>
>
> --
> Thanks - RevDave
> Cool7 @ hosting4days . com
> [db-lists]
>
>
>

  Réponse avec citation
Vieux 18/03/2008, 22h28   #6
Eric Gorr
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut SOAP Server in PHP4

Looks like I will be unable to use PHP5 to do a SOAP server. I believe
it was possible to do such a thing in PHP4, but perhaps not as
cleanly. Unfortunately, I am unable to locate the appropriate
documentation on php.net for some reason...perhaps I am just blind.

Can anyone point me to it?

This page:

http://us3.php.net/manual/en/ref.soap.php

seems to apply only to PHP5 and beyond.


Thank you.


  Réponse avec citation
Vieux 18/03/2008, 22h40   #7
Nathan Nobbe
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] SOAP Server in PHP4

On Tue, Mar 18, 2008 at 5:28 PM, Eric Gorr <mailist@ericgorr.net> wrote:

> Looks like I will be unable to use PHP5 to do a SOAP server. I believe
> it was possible to do such a thing in PHP4, but perhaps not as
> cleanly.



is this because you arent able to use php5 in your current situation,
because php can do soap servers in php5.


> Unfortunately, I am unable to locate the appropriate
> documentation on php.net for some reason...perhaps I am just blind.



there was no native support for soap w/ php4. i dont even know if nusoap
offered this, and anyway i didnt really like it nor have i ever heard of a
php4 soap server.

-nathan

  Réponse avec citation
Vieux 19/03/2008, 13h44   #8
Eric Gorr
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: SOAP Server in PHP4

> > Looks like I will be unable to use PHP5 to do a SOAP server. I
believe
> > it was possible to do such a thing in PHP4, but perhaps not as
> > cleanly.

>
>
> is this because you arent able to use php5 in your current situation,


Yes.

> because php can do soap servers in php5.


I know...I have one working in php5 now.

> > Unfortunately, I am unable to locate the appropriate
> > documentation on php.net for some reason...perhaps I am just blind.

>
>
> there was no native support for soap w/ php4.


Thanks.

> i dont even know if nusoap offered this,


Apparently, it does.

http://www.scottnichol.com/nusoapprogwsdl.htm


  Réponse avec citation
Vieux 20/03/2008, 00h59   #9
Dan
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie ' If Statement' Question

heredoc is probably the best way to go. There's no way you can mess up your
quotes, and you don't have to worry about escaping. Altough I wonder what
would happen if you put ?> in a heredoc, would it stop processing the php,
thinking that it was the end of the php file, or would it just treat it as a
string still?

- Dan

"Al" <news@ridersite.org> wrote in message
news:EA.9A.00283.00F6DD74@pb1.pair.com...
> Here's how I'd do it.
>
> <?php
> $row= $emp_row->getRecordId();//Or, you can put this inside the heredoc
> with {}
>
> //heredoc
> $str= <<<txt
> <form name="edit" method="post" action="emp_edit_result2.php">
> <input type="hidden" name="Status" value="Active" />
> <input type="hidden" name="The_Date" value="" />
> <input type="hidden" name="-recid" value="$row" />
> <input type="submit" name="edit_submit" value="Activate" />
> </form>
> txt;
>
> if (!empty($emp_row->getField('testfield')) print $str;
> else print "Non Print";
> ?>
>
>
> cool7@hosting4days.com wrote:
>> Hello Folks,
>>
>> I would like to be able to wrap a 'form' inside a php 'if statement' -
>> so
>> that the form will appear if the 'if condition' is met.
>>
>> - most likely I cannot have a <?php tag inside another one - and am sure
>> I'm doing other things wrong also...
>> - now I get the error - Parse error: syntax error, unexpected T_STRING
>> in...
>>
>> Q: What is the best way to accomplish this goal?
>>
>>
>> -----------------------
>>
>> <?php if ($emp_row->getField('testfield') !="") {
>> print "<form name="edit" method="post" action="emp_edit_result2.php">
>> <input type="hidden" name="Status" value="Active"/>
>> <input type="hidden" name="The_Date" value=""/>
>> <input type="hidden" name="-recid" value="<?php echo
>> $emp_row->getRecordId(); ?>">
>> <input type="submit" name="edit_submit" value="Activate">
>> </form>
>> ";}else {print "Non Print";} ?>
>> --
>> Thanks - RevDave
>> Cool7 @ hosting4days . com
>> [db-lists]
>>
>>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 04h53.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,17918 seconds with 17 queries