Quick Syntax Question:

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vozzek
    New Member
    • Sep 2007
    • 40

    #1

    Quick Syntax Question:

    Hi all, I have a really quick syntax problem I can't seem to hammer out...

    In my script, I am trying to set a variable based upon an entry from my SQL table. Here's two different lines of code I've tried, but neither of them seems to work:

    [CODE=php]var opt_a = ($_POST['<?php echo $row_rs_detail['option_a']; ?>']);[/CODE]

    This isn't working, but I don't get an error...

    [PHP]var opt_a = <?php echo "$_POST[".$row_rs_detai l['option_a']."]"; ?>;[/PHP]

    This isn't working AND gives me an error.

    I apologize in advance for being a javascript and php newbie... maybe I'm going about this the wrong way. Any suggestions?

    Thanks in advance.
    Last edited by acoder; Nov 13 '07, 09:42 AM. Reason: Moving to PHP forum
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    This isn't working AND gives me an error.
    What do you mean by 'isn't working' and what is the error?
    What values do the variables contain?

    Comment

    • mwasif
      Recognized Expert Contributor
      • Jul 2006
      • 802

      #3
      This should fix your problem if $row_rs_detail is a resultset.
      [PHP]var opt_a = <?php echo $row_rs_detail['option_a']; ?>;[/PHP]
      Why you are using $_POST?

      Comment

      Working...