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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:34:09+00:00 2026-05-26T07:34:09+00:00

if i take and do something like this: $p = 10; $n = 3;

  • 0

if i take and do something like this:


    $p = 10;
    $n = 3;
    $evalstr = "\$f = 0.99 + ((.025 * \$p) * \$n);";
    eval($evalstr);
    echo $f;

I get 1.74 displayed, no errors everything is fine, but when I have a mysql table that holds these equations (for the purpose of this example, it is the exact same equation)…like so:


    $p = 10;
    $n = 3;
    while ($result = mysql_fetch_assoc($results)) {
        $math = $result['math'];
        //at this point $math = "\$f = 0.99 + ((.025 * \$p) * \$n);"
        eval($math);
    }

I get Parse error: syntax error, unexpected T_VARIABLE, expecting T_STRING in ajax\getprices.php(30) : eval()’d code on line 1

Unsure as to why, if i print of echo $math is it identical to what I have as $evalstr in the first example. $p and $n are actually set from GET variables but even if I set them manually as in the example it does not work.

  • 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-26T07:34:10+00:00Added an answer on May 26, 2026 at 7:34 am

    It seems to me, that you stored the expression including the escaped $ in the database. You might try, if it works, if you first remove the slashes:

    eval(stripslashes($math));
    

    I too would recommend to be very careful with storing such code in a database and using eval to execute it. There is potential for security holes here. But i assume, you know this.

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

Sidebar

Related Questions

Is it possible to take something like x^2+5 and have it generate this: https://i.stack.imgur.com/a0f8Q.gif
Seems like this should be something straightforward, but I haven't been able to get
The questions says everything, take this example code: <ul id=css-id> <li> <something:CustomControl ID=SomeThingElse runat=server
Is there a cool way to take something like this: Customer Name - City,
What I'm looking for would allow me to take something like this: index.html.template: <html>
I have a macro that looks something like this: Foo(x) ((x - '!') &
I know something like this has been asked before, but the answer was sort
I have something like this: //html <div class=panel> <div class=tools> <a href=#action1>Action 1</a> <a
i have to take something like a screenshot in my android application. It is
Can a JavaScript function take unlimited arguments? Something like this: testArray(1, 2, 3, 4,

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.