ali_2kool2002 Posted March 2, 2007 Share Posted March 2, 2007 hi i have a customer table and it has an auto increment for the customer id, and a user name field. However, if i want to enter in php a new customer i dont want to be entering a value as it should automatically be created, so all i need to enter is the user name. How do i make php understand that i want to only enter the first name as the rest should be entered itself in mysql...? do i enter a blank value and pass it on like below?: insert_query = "insert into customer ''', '$fn'"; Quote Link to comment https://forums.phpfreaks.com/topic/40889-solved-entering-empty-value-in-query-in-php/ Share on other sites More sharing options...
wildteen88 Posted March 2, 2007 Share Posted March 2, 2007 This is more of a MYSQL question rather than PHP. What you will want to do is this: insert_query = "INSERT INTO customer(`username`) VALUES ('$fv');" Quote Link to comment https://forums.phpfreaks.com/topic/40889-solved-entering-empty-value-in-query-in-php/#findComment-198024 Share on other sites More sharing options...
redarrow Posted March 2, 2007 Share Posted March 2, 2007 for the id you need not to use auto_increment as your need to add your own like a random number use rand ok. Quote Link to comment https://forums.phpfreaks.com/topic/40889-solved-entering-empty-value-in-query-in-php/#findComment-198025 Share on other sites More sharing options...
Barand Posted March 2, 2007 Share Posted March 2, 2007 rand() will not guarantee uniqueness so you will always have to test that it hasn't been used already. Auto_increment OTOH will guarantee a unique id. Quote Link to comment https://forums.phpfreaks.com/topic/40889-solved-entering-empty-value-in-query-in-php/#findComment-198147 Share on other sites More sharing options...
ali_2kool2002 Posted March 3, 2007 Author Share Posted March 3, 2007 thanks wild teen i got it now ... INSERT INTO test(`name`) VALUES ('name'); dont need to even say anthing about the id field it does it itself!! :o Quote Link to comment https://forums.phpfreaks.com/topic/40889-solved-entering-empty-value-in-query-in-php/#findComment-198508 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.