Connecting Tech Pros Worldwide Help | Site Map

Quick Syntax Question:

Member
 
Join Date: Sep 2007
Posts: 40
#1: Nov 12 '07
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:

Expand|Select|Wrap|Line Numbers
  1. var opt_a = ($_POST['<?php echo $row_rs_detail['option_a']; ?>']);
This isn't working, but I don't get an error...

[PHP]var opt_a = <?php echo "$_POST[".$row_rs_detail['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.
code green's Avatar
Expert
 
Join Date: Mar 2007
Location: England
Posts: 1,076
#2: Nov 13 '07

re: Quick Syntax Question:


Quote:
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?
mwasif's Avatar
Moderator
 
Join Date: Jul 2006
Location: Pakistan
Posts: 718
#3: Nov 13 '07

re: Quick Syntax Question:


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


Similar PHP bytes