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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:17:26+00:00 2026-06-09T14:17:26+00:00

mySQL was doing fine until mySQLi was created :/ I’ve used mysql_fetch_array() before. However,

  • 0

mySQL was doing fine until mySQLi was created :/

I’ve used mysql_fetch_array() before. However, when I use mysqli_fetch_array() {Notice “i”}, there is a problem getting results from an ASSOCIATIVE array when selecting from multiple tables. That is,

$query = "SELECT t1.id, t2.id FROM t1, t2 WHERE ...";
$result = mysqli_query($conn,$query);
//if num of rows check...
while($row = mysqli_fetch_array($result))
{ $first_id = $row['t1.id']; $second_id = $row['t2.id']; }

And, I’d get an error: Undefined index: t1.id (or t2.id).

Queries work fine if I was only selecting from t1 or t2 (not both) or if I was saying $row[‘id’]; instead of $row[‘t1.id’]; but then that doesn’t help in getting different fields from two tables with identical names

Please help.

Thanks! =)

  • 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-09T14:17:28+00:00Added an answer on June 9, 2026 at 2:17 pm

    Your code has problems separating t1.id and t2.id, the result will return them both as ‘id’.

    Try renaming/aliasing the column(s) using AS in the query instead;

    $query = "SELECT t1.id AS t1id, t2.id AS t2id FROM t1, t2 WHERE ...";
    $result = mysqli_query($conn,$query);
    //if num of rows check...
    while($row = mysqli_fetch_array($result))
    { $first_id = $row['t1id']; $second_id = $row['t2id']; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to make MySQL cause some kind of error when doing
Doing a mysqli query and COUNTing the results, is there a preferred comparison operator
just doing an INSERT using mySQL which works fine... mysql_query(INSERT INTO FLIGHTS_AVAILABLE (aircraftID, aircraftType,
I'm doing an integration of PHP and MySQL. The following code is working fine:
I am doing a simple JSP program to connect with MySQL DB. But it's
I started doing a new project in PHP / MySql . The Aim of
Doing my first tryouts with foreign keys in a mySQL database and are trying
I am using mysql with php Yii framework.When doing data modelling I came accross
The conventional way of doing this would be $row = mysql_fetch_array($query); echo $row['column']; but
Buried in mySQL syntax and query structure problems once more. I'm currently doing this

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.