PHP syntax

Discussion in 'PHP' started by ataloss, Mar 17, 2014.

  1. #1
    Hi, please tell me why the following code. No error message, just doesn't work.

    <input type="text" STYLE="color: #000000; background-color: #AAFFAA;" size=25 name="acctno" value="<? echo $acctno;?>"></td>
    <input type=text size=25 STYLE="color: #000000; background-color: #AAFFAA;" name="bname" value="<? echo $bname;?>"><br>
    PHP:

     
    ataloss, Mar 17, 2014 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    No idea, but my first tip would be to clean up the code. That's some messy use of quote marks, and horrible use of table cells etc.
     
    PoPSiCLe, Mar 17, 2014 IP
  3. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #3
    Maybe you don't have the short tag enabled. Try <?php instead of <?
     
    ThePHPMaster, Mar 17, 2014 IP
  4. DomainerHelper

    DomainerHelper Well-Known Member

    Messages:
    445
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    100
    #4
    Add this to the top of your script. Ignore what Popsicle said, has nothing to do with your issue.

     
    DomainerHelper, Mar 18, 2014 IP
  5. startdream

    startdream Member

    Messages:
    76
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    28
    #5
    Change like that
    <input type="text" STYLE="color: #000000; background-color: #AAFFAA;" size=25 name="acctno" value="<?php echo $acctno;?>"></td>
    <input type=text size=25 STYLE="color: #000000; background-color: #AAFFAA;" name="bname" value="<?php echo $bname;?>"><br>
    PHP:
     
    startdream, Mar 19, 2014 IP
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #6
    I'd say it probably has a lot to do with it, and even if it doesn't it's still likely something that should be fixed. That markup is BAD... Should probably be thrown out altogether since the TD is closed and no new one is opened... of course the inlined static style is some outright inept BS that has no place EVER being done either. The lack of ID's probably means no labels, which is why in general whatever that form is it's likely an inaccessible train wreck! When the OP has decade and a half out of date markup and broken/bloated methodologies, it's good SOMEBODY bothered to point it out!

    Though I think @ThePHPMaster hit it on the head, it's likely that shorttags aren't enabled. IF the OP is on PHP 5.4/newer (If you aren't your hosting is **** and it's time to either bitch them out or MOVE), you could use the <?= shorttag instead, which is basically a shorttag that ONLY echos. It's now enabled by default regardless of whether shorttags is enabled or not.

    <input type="text" size="25" name="acctno" value="<?= $acctno; ?>" />
    <input type="text" size="25" name="bname" value="<?= $bname; ?>" />
    Code (markup):
    Though really this is another reason I don't believe in using that ugly stupid "let's open and close PHP tags on every blasted line" crap... and would have it all inside an echo.

    echo '
    	<input type="text" size="25" name="acctno" value="', $acctno, '" />
    	<input type="text" size="25" name="bname" value="', $bname, '" />';
    Code (markup):
    Though I do have a question for @ataloss -- DEFINE "doesn't work"? Does it not output the markup? Does it not submit it's values properly? You really didn't give much for people to try and even figure out.
     
    deathshadow, Mar 19, 2014 IP