Jump to content

[SOLVED] $column = mysql_fetch_row($stmt)[0]; why not?


tivrfoa

Recommended Posts

You're welcome.

 

That's the problem, $column = mysql_fetch_row($stmt)[0]; should work.

 

No, it shouldn't work at all. mysql_fetch_array() is not an array, it's a function. You can only call an index (ex: [0]) on an array. Functions don't have indexes. So you can't call an index on mysql_fetch_array(), as you are trying to call an index on a function.

 

The function returns an array. That means that the value it spits out is an array. The function itself isn't an array, only the value it produces. So you can call an index on $column, as it contains the value that mysql_fetch_array() gave it, but you cannot call an index on the function itself.

you did'nt understand. here is a Java example.

 

public class MyArray {

public static String[] returnArray() {
	String[] newArray = {"Hello", "World"};
	return newArray;
}

public static void main(String[] args) {
	System.out.println(returnArray()[0]); // prints Hello. NO PROBLEM!!!
}
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.