Solved

PHP to echo DB field name as a variable

Posted on 2011-09-23
2
293 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Creating and Managing Databases with phpMyAdmin in cPanel.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

756 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