Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.