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

  • Home
  • SEARCH
  • 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 9246439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:29:20+00:00 2026-06-18T09:29:20+00:00

The question in simple. What i have and what’s the problem? I do have

  • 0

The question in simple.

What i have and what’s the problem?
I do have two dimensional array $someArray[][]. The first bracket i could put “subject” or “date”. The second one, goes from 1 to 4 (just an example – $someArray['date'][0])

Now when i try to get some data from database with mysql_query() i have some problems. I am trying to use this two dimensional array in WHERE part in query.

Examples what works and what doesn’t
$result = mysql_query("SELECT some from table where date='$someArray[date][0]' AND subject='$someArray[subject][0]') or die(mysql_error());

When i use this, it doesn’t return me anything. But when i first assing those values to new variables:

$variable1 = $someArray['date'][0];
$variable2 = $someArray['subject'][0];

and then use them in query

`$result = mysql_query("SELECT some from table where date='$variable1' AND subject='$variable2') or die(mysql_error());

It works like a charm.

Question
Whats wrong with my first query, am I writing those arrays wrong? I get no errors.
Tried to put single apostrophes inside [] brackets in mysql query, but then i do get errors. Also it works without them if i use array like: $someotherArray[somedata] in query.

  • 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-18T09:29:21+00:00Added an answer on June 18, 2026 at 9:29 am

    Array interpolation only works for a single level of subscripting. For multidimensional arrays, you need to use {...} wrappers:

    $result = mysql_query("SELECT some from table where date='{$someArray['date'][0]}' AND subject='{$someArray['subject'][0]}') or die(mysql_error());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question is simple: I have two List List<String> columnsOld = DBUtils.GetColumns(db, TableName); List<String> columnsNew
I have simple question. As we know that Char takes two bytes (16 bit),
I am new starter android. I have simple question. When I choose date through
I have two simple question i couldnt managed to find the answer in the
I have a simple question. lets say we have two arrays: data = [1
i have simple question may be someone asked it before me but i could
Simple question (I hope): I have a simple two column table, a measurement and
I have a simple question related to one-line programming. First an example: function test(a)
I have simple question. User supplies URL to my PHP script where I fetch
Question simple and quick: I have started to use Netbeans to write some code

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.