Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6327005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:12:02+00:00 2026-05-24T17:12:02+00:00

Have been trying to figure this out all day assuming its just a small

  • 0

Have been trying to figure this out all day assuming its just a small error…..

I’m trying to use the file_put_content to put a variables value into another php file..

Code below will explain:

File that writes the data into the php:

    <?php

require ('conf_2135432135435135412312534.php');

$F_name =$_POST['F__name'];
$L_name =$_POST['L__name'];
$E_mail =$_POST['Email'];
$GDI_user =$_POST['GDIusername'];
$ip=$_SERVER['REMOTE_ADDR'];
$C_date = date("F j, Y, g:i a");


mysql_connect($hostname,$username,$password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());


$sql = "INSERT INTO $usertable (F_name, L_name, Email, GDI_username, Registration_IP, Date_registered) VALUES ('$F_name', '$L_name', '$E_mail', '$GDI_user', '$ip', '$C_date')";

if (!mysql_query($sql)) {
    die('Error: ' . mysql_error());
} 

$get_id = mysql_query("SELECT * FROM $usertable WHERE ". "GDI_username = '$GDI_user'");

while($id_check = mysql_fetch_array($get_id)) {
    $UNQ_ID = $id_check["Unique_id"];
 }

$src = "/home/files/1/741/html/WP/Default_files";
$dest = "/home/files/1/741/html/WP/$GDI_user";

echo "$GDI_user/config.php";

shell_exec("cp -r $src $dest");

 file_put_contents("/home/files/1/741/html/WP/$GDI_user/config.php",'<?

$affiliate_reference = "$UNQ_ID";
echo $UNQ_ID;

?>');
?>

^^Short explanation of what that code does:^^

1.) Takes info from a html form

2.) INSERTS the data into a DB

3.) Fetches a Unique_id number from the DB

4.) Makes a copy of a folder with all the contents in it (Default_files)

5.) The duplicate folder is given a name of what was entered into the HTML form

6.) Writes into a file contained in the duplicate folder (config.php)

What the output (config.php) SHOULD contain:

<?

$affiliate_reference = "2154216354154"; //<<<thats just an example number
echo 2154216354154;

?>

Instead, This is what’s showing up:

<?

$affiliate_reference = "$UNQ_ID";
echo $UNQ_ID;

?>

completely lost here. Any help would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:12:03+00:00Added an answer on May 24, 2026 at 5:12 pm

    You’re using ' to define the string, this means that the value will be left unparsed. The trick here, though, is that you want $UNQ_ID parsed, but you want $affiliate_reference left as is. This means you have to escape or manually concatenate

    I would use this instead:

    '<?
    
    $affiliate_reference = "'.$UNQ_ID.'";
    echo '.$UNQ_ID.';
    
    ?>'
    

    Notice, I am using the single quote for the majority of the string. This is purposeful, you don’t want the $affiliate_reference to be output. You only want $UNQ_ID turned into its string equivalent. Your other option is to use " and escape the $:

    "<?
    
    \$affiliate_reference = "'.$UNQ_ID.'";
    echo '.$UNQ_ID.';
    
    ?>"
    

    Note the \ to escape $ in front of $affiliate_reference.

    I generally prefer the first way, color syntax highlighters will make that very obvious (even notice how SO handles it), while the second example causes highlighters to glaze over the whole thing. It is a preference, but it is an important one.

    Of course, there is always the silly:

    $a = '$';
    

    followed by

    "<?
    
    ${a}affiliate_reference = "'.$UNQ_ID.'";
    echo '.$UNQ_ID.';
    
    ?>"
    

    Use that only with people you don’t like.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Been trying to figure this one out all day. I have a large text
I have been trying to figure this out all day. I've searched SO and
I have been trying to figure this out all day... but can't seem to
I've been trying to figure this out all day - I have a FormView
I'm new to python and have been trying to figure this out all day.
i have been trying to figure this out but i just can't.... for some
I have been trying to figure this out the ENTIRE DAY :( ... I
I have been trying to figure this out all afternoon with no luck. On
I have been trying to figure this out all afternoon, but have given up
I have been trying to figure this out for quite a while, but what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.