0

I'm running this query, on two tables, and in first table, table tblhosting two condition must be met, WHERE tblhosting.server = tblservers.id AND tblhosting.domain = 'provided domain'. "provided domain is unique and here is complete query:

$result = mysql_query("SELECT hostname FROM tblhosting, tblservers WHERE tblhosting.server = tblservers.id AND tblhosting.domain = 'developer.infonet.hr'");

Query return correct result set, but two times, here is also var_dump output:

array(2) {
  [0]=>
  string(18) "lin-b15.infonet.hr"
  ["hostname"]=>
  string(18) "lin-b15.infonet.hr"
}

Why is returning two same results, correct output is one, because domain is unique, is this because result is generate with mysq_fetch_array, so it is returning both associative array, and normal indexed array?

3
  • Thats alright you need to use the index name hostname while accessing the value. Commented Mar 30, 2015 at 11:53
  • Can you explain what do you mean with index name hostname? Hostname isn't index but is unique record in table. Commented Mar 30, 2015 at 12:05
  • index means index of array like [0] and hostname means ["hostname"] . You can use as $result['0'] or $result['hostname']. Commented Mar 30, 2015 at 13:01

1 Answer 1

1

use

mysql_fetch_row() to Get a result row as an enumerated array

or

mysql_fetch_assoc() to Fetch a result row as an associative array

For Multiple record use it in while condition..

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, that is correct, but I am confused because I been thinking that query returns two rows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.