Jump to content

Question


3raser

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/208981-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.