felipeebs Posted October 20, 2008 Share Posted October 20, 2008 my code is something like this: $value = "10-2008"; mysql_query("insert into editions(edition) values ($value)"); But it's not inserting "10-2008" in the table, is inserting "-1998" the "editions" table is id int(9) auto_increment, edition varchar(7) not null why is this happening? how to avoid? thank's Quote Link to comment https://forums.phpfreaks.com/topic/129286-solved-mysql-is-a-crazy-thing/ Share on other sites More sharing options...
rhodesa Posted October 20, 2008 Share Posted October 20, 2008 it's evaluating it as a number. wrap it in single quotes: $value = "10-2008"; mysql_query("insert into editions(edition) values ('$value')"); Quote Link to comment https://forums.phpfreaks.com/topic/129286-solved-mysql-is-a-crazy-thing/#findComment-670263 Share on other sites More sharing options...
felipeebs Posted October 20, 2008 Author Share Posted October 20, 2008 oh lord! thank's ^^ Quote Link to comment https://forums.phpfreaks.com/topic/129286-solved-mysql-is-a-crazy-thing/#findComment-670269 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.