operafanboy Posted March 16, 2006 Share Posted March 16, 2006 I have a few column names in my MYSQL table that have a forward slah in them, and when I try to access them with php via something like $row['N/O'] it doesn't work. Is it not possible to access a column name like this if it has a '/' or am I doing something wrong?Cheers Quote Link to comment Share on other sites More sharing options...
Humpty Posted March 16, 2006 Share Posted March 16, 2006 Try the following:In your code instead of / use \/ (that is \ then / not the letter v)if that doesn't work do that for the data in the table instead.If that doesn't work you could try // in the data in the table. (not the code though) I don't think that // does anything in the data in the table though. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 16, 2006 Share Posted March 16, 2006 How about changing the name of the column in your database?Ken Quote Link to comment Share on other sites More sharing options...
Humpty Posted March 16, 2006 Share Posted March 16, 2006 Ken; operafanboy;I'm an idiot, I thought that your data had the / in it not the field names.I try not to use anything other than numbers and letters in mine. To help identify them I use uper and lower case which is bad enough and causes enough errors because I keep forgetting which ones are capps and not.I'm an idiot, will stay out now :D Quote Link to comment Share on other sites More sharing options...
operafanboy Posted March 16, 2006 Author Share Posted March 16, 2006 Thanks, the \/ in the code doesn't work. I think I might just change the column names like kenr said though. Is it considered bad practice to use special characters in column names?BTW does anyone know of any good tutorials about good coding practices/habits with mysql and php?cheers Quote Link to comment Share on other sites More sharing options...
Twentyoneth Posted March 16, 2006 Share Posted March 16, 2006 what about something like:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]$row[N//O][/quote]$newrow = stripslashes($row); Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 16, 2006 Share Posted March 16, 2006 It looks like my earlier reply got lost in the transition to the new box...Thinking about your problem...Slashes in the field name shouldn't cause a problem. PHP doesn't have a problem with array indices with slashes and MySQL doesn't have a problem with field names with slashes.What indications are you getting that the slash in the field name is causing a problem? Errors?Ken Quote Link to comment Share on other sites More sharing options...
operafanboy Posted March 18, 2006 Author Share Posted March 18, 2006 [!--quoteo(post=355585:date=Mar 16 2006, 11:53 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 16 2006, 11:53 AM) [snapback]355585[/snapback][/div][div class=\'quotemain\'][!--quotec--]It looks like my earlier reply got lost in the transition to the new box...Thinking about your problem...Slashes in the field name shouldn't cause a problem. PHP doesn't have a problem with array indices with slashes and MySQL doesn't have a problem with field names with slashes.What indications are you getting that the slash in the field name is causing a problem? Errors?Ken[/quote]Just that nothing came up on the webpage when it should have. I've got a feeling it's something I did wrong though or forgot to do. Anyway I've changed the names and everything is working well. Thanks for the help :). Quote Link to comment 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.