Solved

PHP to echo DB field name as a variable

Posted on 2011-09-23
2
294 Views
Last Modified: 2012-05-12
Hello Experts,
I have a conditional scenario as below:

$jobmode = {job_mode};
if ($jobmode == '9'){
$export = "recip_mm";
}else if ($jobmode == '7'){
$export = "recip_origin_export";
}else if ($jobmode == '8'){
$export = "recip_origin_export";
}
else{
$export = "recip_export";
}

Open in new window


And the below to insert the record in a table:
/**
 * Insert a record on another table
 */
$insert_table  = 'recip';              // Table name
$insert_fields = array(                   // Field list
                     '$export' => "'{job_vol}'",
);

Open in new window


Everything works fine except that I am not able to post $export to  '$export' => "'{job_vol}'",

How can this be done..
Thanks for any help
0
Comment
Question by:jayseena
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Accepted Solution

by:
dsmile earned 250 total points
ID: 36586008
Remove single quotes from line 6, or use double quotes instead

$insert_fields = array(                   // Field list
                     $export => "'{job_vol}'",

or

$insert_fields = array(                   // Field list
                     "$export" => "'{job_vol}'",
0
 

Author Closing Comment

by:jayseena
ID: 36586045
Perfect.
Thank you very much.
0

Featured Post

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question