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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:21:29+00:00 2026-06-17T07:21:29+00:00

I have several strings stored in a database (yes, I know it’s not the

  • 0

I have several strings stored in a database (yes, I know it’s not the best practice, but I’m working with a system someone else designed and I cannot change it.)

For example, in my table called specialDates, I have a computedDate column that contains this:

 date('d', strtotime("thursday, november ".date("Y")." + 3 weeks")) 

This is pulled into my code and stored in a variable called $request['order_date'].

This, when used in standard PHP code, returns the date that Thanksgiving falls on in the current year. I need to pass the evaluated value of this (for this year – 2013 – the value is 28) to another query. But I can’t seem to get the value to evaluate.

$query = 'SELECT count(orderID) as numberOfOrders FROM customer_orders WHERE customerID = ? AND orderDate = ?';
$param = array($request['customer_id'], eval($request['order_date']));

doesn’t work. And when I just try to echo out the value to the screen, doing this:

echo eval($request['order_date']);

or this:

echo eval(" return \$request['order_date']; ");

just prints out the literal value of the string (i.e. date('d' etc.) rather than the expected evaluated value.

What am I doing wrong?

UPDATED
I tried AScherer’s answer below, and although it does work when I just echo the value to the screen:

echo eval(" return {$request['order_date']}; ");

it does not work when I try to use the eval inside my array:

$param = array($request['customer_id'], eval("return {$request['order_date']}"));

How can I get this working so that the value I’m passing in the array is the actual value of 28, rather than the string pre-eval?

  • 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-17T07:21:30+00:00Added an answer on June 17, 2026 at 7:21 am

    You were escaping the $request in your return part, which you dont want to do. This method should work, but id suggest adding return the the row in the database so u dont have to modify the eval

    $sql = "SELECT customer_id, CONCAT( 'return ', order_date, ';' ) as function from customer_orders WHERE customerID = ? AND orderDate = ?";
    $param = array( $request[ 'customer_id' ], eval( $request[ 'function '] ) );
    
    ---
    OR
    ---
    
    $evalData = eval(" return {$request['order_date']}; ");
    $param = array($request['customer_id'], $evalData );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've seen this asked several times, but not with a good resolution. I have
For example, I have object user stored in database (Redis) It has several fields:
I have an SQLite database that stores several hundred or thousand strings, I keep
I have an object with several text strings as members. I want to write
I have a class containing several properties (all are strings if it makes any
I have several Delphi programs that maintain connections to a database (some Oracle, some
I have a SQL Server 2008 database. This database has a stored procedure that
I have a text file with several strings of hex in it: 013d7d16d7ad4fefb61bd95b765c8ceb 007687fc64b746569616414b78c81ef1
I have several records in a database that have Start and End Dates 09/15/2011
We have some legacy database mappings in GORM and several have a primary key

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.