Jump to content

[SOLVED] Problem with mysql_fetch_array..?


AbydosGater

Recommended Posts

Hi Guys, Im having some sort of problem with my SQL Query and its Fetch_array.

If you look at the following code.. It should echo out the data from my table in the format "key: Val" and it does but its pulling more data then it should..

 

If you look at the output of the following code.

 

<?php
mysql_connect('localhost', 'root', '');
mysql_select_db("sb");
        $plugins_list=mysql_query("SELECT
                                   	*
                                     FROM
                                         sb_plugins
                                     WHERE
                                         sb_plugins.status = 'init'
                                     ORDER BY
                                         sb_plugins.priority ASC");    

        while($plugin=mysql_fetch_array($plugins_list)){
	foreach ($plugin as $key => $val){
		echo $key .': '.$val.'<br />';
	}
}
?>

 

Output:

0: 1

pID: 1

1: Main Menu

name: Main Menu

2: main_menu

dir: main_menu

3: menu.class.php

file: menu.class.php

 

And so on there is more.... But i dont get where the "1: Main Menu" or "2: main_menu" array objects are coming from!?!

It should not have any Keys as numbers only the field names from the database.

 

Does anyone know why its pulling the "Number: Value" aswell as "Key Val"??

 

Please any help would be greatful! Its driving me mad i cant see what i did wrong.

Link to comment
https://forums.phpfreaks.com/topic/60093-solved-problem-with-mysql_fetch_array/
Share on other sites

http://php.net/mysql_fetch_array

 

mysql_fetch_array -- Fetch a result row as an associative array, a numeric array, or both

 

array mysql_fetch_array ( resource result [, int result_type] )

 

result_type: The type of array that is to be fetched. It's a constant and can take the following values: MYSQL_ASSOC, MYSQL_NUM, and the default value of MYSQL_BOTH.

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.