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 9009411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:11:19+00:00 2026-06-16T02:11:19+00:00

I have spent an hour or so attempting to figure out this one error..

  • 0

I have spent an hour or so attempting to figure out this one error.. It looks right to me, but I am by far no expert. So I thought I would ask the experts! I keep getting this error:

Parse error: syntax error, unexpected ” (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in … on line 29

from this line of code:

eval("$var_value = $_REQUEST['{$value}']");

Here is the code around it..

function save_edits($var_name, $var_value)
{
    eval("{$var_name} = sql_safe({$var_value});");
    eval("mysql_query(\"UPDATE settings set {$var_name}='{$var_value}' where variable='{$var_name}'\") or die(mysql_error());");
}     
foreach ($_REQUEST as $key => $value)
{
    eval("$var_value = $_REQUEST['{$value}']");
    save_edits($value, $var_value);
}
  • 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-06-16T02:11:20+00:00Added an answer on June 16, 2026 at 2:11 am

    missing a ] is appears:

    eval("$var_value = $_REQUEST['{$key}\'");
                                         ^^
    

    Also missing a ):

    eval("{$var_name} = sql_safe({$var_value};");
                                            ^^
    

    However, you should avoid eval at much cost, especially with $_REQUESTs (implying user input). As it stands, this query would be harmful to your site:

    http://your-site.com/?foo='];exec('rm%20*.*');
    

    So how about a refactor:

    function save_edits($var_name, $var_value)
    {
        $clean_name = mysql_real_escape_string($var_name);
        $clean_value = mysql_real_escape_string($var_value);
        $sql = "UPDATE settings "
            .= "SET    value = '{$clean_value}' "
            .= "WHERE  variable = '{$clean_name}'";
        mysql_query($sql) or die(mysql_error());
    }     
    foreach ($_REQUEST as $key => $value)
    {
        save_edits($key, $value);
    }
    

    However you should really look in to using:

    CREATE TABLE settings
    (
      id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
      name VARCHAR(50) NOT NULL,
      value VARCHAR(255)
    );
    

    Then you can sanitize both the name and the value field. You also probably want to look in to using PDO to prevent exploits better.

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

Sidebar

Related Questions

Have spent an hour trying to solve this - but to no avail. I'm
I have spent an hour looking for an answer to this, but unless you
I have just spent half an hour figuring this thing out, I have managed
I have spent hours in this problem and my fellows couldn't help me out.
I have spent all Friday and Saturday on this and I am running out
The answer to this is likely to be trivial, but I have spent half
I think my question must be really stupid, but I just spent one hour
I have spent the last hour and a half looking over this code and
I have spent about an hour or two trying to find out how to
I feel embarrassed asking this question, but I've spent the last half an hour

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.