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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.