millercj Posted March 23, 2009 Share Posted March 23, 2009 I'm running a sql query and I have a table that houses coded names for classes, one is named "5-1" my query loops and is saved to an array by this statement: $classes[$i] [0] = $nextresult['class_name']; And then later does this: $tblname=$classes [$i][0]; for the record "5-1" by the time it goes through this it's interpreting table "5-1" as 4 (the result of 5 minus 1) How can i fix this?! Link to comment https://forums.phpfreaks.com/topic/150649-solved-php-sql-character-issue/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 23, 2009 Share Posted March 23, 2009 It would help if you showed how this is used, but based on the variable being called $tblname, you are likely using this in a query - A) You should not be using numbers for table names, and B) If you are using numbers for table name, you must enclose them in back-ticks so that they are treated as an identifier instead of a math expression. Link to comment https://forums.phpfreaks.com/topic/150649-solved-php-sql-character-issue/#findComment-791435 Share on other sites More sharing options...
millercj Posted March 23, 2009 Author Share Posted March 23, 2009 back-ticks will do it...thanks Link to comment https://forums.phpfreaks.com/topic/150649-solved-php-sql-character-issue/#findComment-791475 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.