Jump to content

Doubled array


klepec

Recommended Posts

Hello,

This is my mysql search:

$req="%".mysql_real_escap.......;

"SELECT companyID, cName FROM bcompany WHERE
companyID LIKE '$req' OR cName LIKE '$req' ORDER BY companyID LIMIT 10"

 

For example my search ($req) is krneki.

 

There is one record in database which matches the criteria.

 

And the array is like:

 

array
  0 => string '7' (length=1)
  'companyID' => string '7' (length=1)
  1 => string 'krneki jao' (length=10)
  'cName' => string 'krneki jao' (length=10)

 

Is it ok that there are double values in array i fetch from mysql?

Link to comment
https://forums.phpfreaks.com/topic/259796-doubled-array/
Share on other sites

Yes, that is entire normal and to be expected, if you have used the mysql_fetch_array function. The documentation states that it will "fetch a result row as an associative array, a numeric array, or both". When the optional second parameter is left out, it defaults to retrieving both.

 

If you just want a numerial array, you can use mysql_fetch_row, or if you want a associative array, you can use mysql_fetch_assoc.

Link to comment
https://forums.phpfreaks.com/topic/259796-doubled-array/#findComment-1331517
Share on other sites

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.