3raser Posted July 27, 2010 Share Posted July 27, 2010 Thanks to Jcbones for giving me this code, and helping me with my previous problem. I've been fooling with the code to understand it more, and actually learn everything about it. But a question is, $name isn't inserting into the database. This is my file: Justin - Owner Josh - Customer Michael - Employee John - Customer And here is my code: $file = file("test.txt"); foreach ($file as $line) { $ex = explode("-", $line); $name = trim($ex[0]); $job = trim($ex[1]); mysql_query("INSERT INTO test VALUES ('', $name, $job)"); } Can someone please explain why I get this result in the database: id - name - job 1,,owner 2,,customer 3,,employee 4,,customer I'm not receiving the name. Why? Quote Link to comment https://forums.phpfreaks.com/topic/208981-question/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 27, 2010 Share Posted July 27, 2010 To start with, your query does not have any single-quotes around the string data values, so it is impossible that is your actual code that inserted the data you are posting as being the results. Quote Link to comment https://forums.phpfreaks.com/topic/208981-question/#findComment-1091564 Share on other sites More sharing options...
3raser Posted July 27, 2010 Author Share Posted July 27, 2010 To start with, your query does not have any single-quotes around the string data values, so it is impossible that is your actual code that inserted the data you are posting as being the results. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/208981-question/#findComment-1091565 Share on other sites More sharing options...
Pikachu2000 Posted July 27, 2010 Share Posted July 27, 2010 Sheesh. Everyone's fast tonight . . . Quote Link to comment https://forums.phpfreaks.com/topic/208981-question/#findComment-1091566 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.