budimir Posted May 5, 2013 Share Posted May 5, 2013 I have to connect to mssql database and everything is working fine until I reach db filed which has whitespace in a name. Is there any workaround for this? code example while($row = sqlsrv_fetch_array( $rezultat_ms, SQLSRV_FETCH_ASSOC)){ $kataloski_broj = $row["No_"]; $naziv = $row["Description"]; $kategorija = $row["Item Category Code"]; $grupa_proizvoda = $row["Product Group Code"]; Error Notice: Undefined index: Item Category Code in C:\wampserver\www\erp\katalog_pribora\sync\sync_item.php on line 28 First two variables are OK, but second two are failing beacuse of a space in a name. I can not change db field names. Any workarounds? Quote Link to comment https://forums.phpfreaks.com/topic/277649-retriveing-column-name-for-db-with-whitespace/ Share on other sites More sharing options...
requinix Posted May 5, 2013 Share Posted May 5, 2013 What is the actual contents of $row? Quote Link to comment https://forums.phpfreaks.com/topic/277649-retriveing-column-name-for-db-with-whitespace/#findComment-1428333 Share on other sites More sharing options...
budimir Posted May 5, 2013 Author Share Posted May 5, 2013 There is a lot of information in $row, around 15 variables in total. VARCHAR, DECIMAL, INT... Everything is working fine for me, until I have to read a column that has a space in the name. There it fails. Tried to test it on test databse and I managed to simulate my problem, but I can't change working db. Quote Link to comment https://forums.phpfreaks.com/topic/277649-retriveing-column-name-for-db-with-whitespace/#findComment-1428337 Share on other sites More sharing options...
requinix Posted May 5, 2013 Share Posted May 5, 2013 Okay, rephrase: What does print_r($row);output? Quote Link to comment https://forums.phpfreaks.com/topic/277649-retriveing-column-name-for-db-with-whitespace/#findComment-1428342 Share on other sites More sharing options...
Solution budimir Posted May 5, 2013 Author Solution Share Posted May 5, 2013 OK, I found a problem... Of course it's stupid me... I have limited my query to only two columns while I was testing, and didn't realise it when I wanted to see everything. After I selected columns I needed, error was gone! Magic! Sorry to disturbe you! Quote Link to comment https://forums.phpfreaks.com/topic/277649-retriveing-column-name-for-db-with-whitespace/#findComment-1428396 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.