HoTDaWg Posted March 10, 2007 Share Posted March 10, 2007 lol, i had this same problem a while ago i have a line here: $sql= "INSERT*INTO users(`id`,`displayname`,`username`,`password`, `email`,`usercode`,`status`,`date`,`ip`) VALUES("'0','$displayname','$username','$password','0','$usercode','.$status.','$date','$ip')"; the difficulty is some of the fields in the database i want to leave untouched for now. as for the values, i want them to match, i tried googling it but im pretty sure i couldnt find the right keywords. lol. thanks guys HoTDaWg Quote Link to comment https://forums.phpfreaks.com/topic/42067-disappointing-question/ Share on other sites More sharing options...
JasonLewis Posted March 10, 2007 Share Posted March 10, 2007 here try this, i just cleaned it up, a lot: $sql = "INSERT INTO `users` (`id`,`displayname`,`username`,`password`, `email`,`usercode`,`status`,`date`,`ip`) VALUES ('0', '{$displayname}', '{$username}', '{$password}', '0', '{$usercode}', '{$status}', '{$date}', '{$ip}')"; mysql_query($sql) or die("Error: ".mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/42067-disappointing-question/#findComment-204028 Share on other sites More sharing options...
AndyB Posted March 10, 2007 Share Posted March 10, 2007 I don't think I understand your question at all. INSERT adds a record to the database. INSERT * should generate a syntax error. If id is meant to be a record id, then where do you expect record zero to get stored? Humour me and rephrase your question (preferably with an explanation). Quote Link to comment https://forums.phpfreaks.com/topic/42067-disappointing-question/#findComment-204030 Share on other sites More sharing options...
HoTDaWg Posted March 10, 2007 Author Share Posted March 10, 2007 appologies, id is automatically generated by the database. That is why i thought that if i put a zero, it will represent that i have no data to insert into that specific row. i hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/42067-disappointing-question/#findComment-204037 Share on other sites More sharing options...
redarrow Posted March 10, 2007 Share Posted March 10, 2007 you dont need to insert somthink that not there do you if you do then you use defualt in phpmyadmin ok <?php $sql = "INSERT INTO `users` (`id`,`displayname`,`username`,`password`, `email`,`usercode`,`status`,`date`,`ip`) VALUES (' ', '$displayname', '$username', '$password', ' ', '$usercode', '$status', '$date', '$ip')"; $result=mysql_query($sql); ?> Quote Link to comment https://forums.phpfreaks.com/topic/42067-disappointing-question/#findComment-204040 Share on other sites More sharing options...
AndyB Posted March 10, 2007 Share Posted March 10, 2007 There's still something fishy about the question. You don't INSERT into a specific row. INSERT inserts a whole new row wherever MySQL wants it to go - with a unique id, but not necessarily in a specific row position (usually at the end, except when rows have been previously deleted). If you want to change data in a specific row, then UPDATE with a WHERE condition is the way to go. Quote Link to comment https://forums.phpfreaks.com/topic/42067-disappointing-question/#findComment-204044 Share on other sites More sharing options...
legohead6 Posted March 10, 2007 Share Posted March 10, 2007 if you have auto_icrepment(im not a good speller) set up in your database then just have the open and closeing quotes beside eachother... ( '' , 'somethingelse','other','etc') for that feild.... Quote Link to comment https://forums.phpfreaks.com/topic/42067-disappointing-question/#findComment-204069 Share on other sites More sharing options...
JasonLewis Posted March 10, 2007 Share Posted March 10, 2007 you dont even need that if it is an auto_increment Quote Link to comment https://forums.phpfreaks.com/topic/42067-disappointing-question/#findComment-204080 Share on other sites More sharing options...
HoTDaWg Posted March 10, 2007 Author Share Posted March 10, 2007 sorry for wasting your time guys, it was pretty late last nightaand my mind wasnt working. Basically, I want to create a new row that is why i am using the insert statement. The problem is, i do not have variables or anything to insert for certain columns such as id or password. Now, I understand that if it is auto incremement i dont have to worry much bout it but as for the email column, I want no information to be inserted into it now. How do i tell it, leave that specific column untouched? thanks guys. HoTDaWg Quote Link to comment https://forums.phpfreaks.com/topic/42067-disappointing-question/#findComment-204232 Share on other sites More sharing options...
HoTDaWg Posted March 12, 2007 Author Share Posted March 12, 2007 i dont mean to sound impatient, but can anyone help me? Quote Link to comment https://forums.phpfreaks.com/topic/42067-disappointing-question/#findComment-205158 Share on other sites More sharing options...
brad Posted March 12, 2007 Share Posted March 12, 2007 just do this ' ' Quote Link to comment https://forums.phpfreaks.com/topic/42067-disappointing-question/#findComment-205163 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.