Welcome Guest, Not a member yet? Register   Sign In
MYSQL Error# 1364
#1

[eluser]brandonjjon[/eluser]
Hello Everyone,

I'm attempting to insert data into my database and the code I wrote is producing this error. I have added the code and the error into this pastie document: http://beta.pastie.org/5426372

I've never had this issue with previous codeigniter applications! Could anyone provide insight on why this is happening? I don't even know why it's telling me anything about an email field. I have no idea why.

Kind Regards,
Brandon
#2

[eluser]ahmed.alsiddig[/eluser]
hi ..
i need more information 2 help
do u have email field in database ??
#3

[eluser]brandonjjon[/eluser]
Yes there is an email field in the table. But this is merely code to insert $website into the `websites` field. Nothing about the email field..
#4

[eluser]hungryhippo[/eluser]
When you are inserting in to the database, column 'email' needs a value. Error due to provided no value for this column
#5

[eluser]brandonjjon[/eluser]
But I'm not even wanting to insert any data into this column...

I provided a "where" statement to insert it into the correct row. The email field on this particular row is already populated.

The goal is to insert $website into the `websites` field.
#6

[eluser]hungryhippo[/eluser]
So you are wanting to update an existing row rather than insert a new one? You will want to use "update" rather than "insert"
#7

[eluser]Aken[/eluser]
[quote author="brandonjjon" date="1353799334"]But I'm not even wanting to insert any data into this column...

I provided a "where" statement to insert it into the correct row. The email field on this particular row is already populated.

The goal is to insert $website into the `websites` field.[/quote]
When you created the email column, you specified that it must have a value (aka NOT NULL). You need to provide a default value when doing inserts, even if you don't want to add a value, OR modify the database column to accept null values.
#8

[eluser]PhilTem[/eluser]
You can't perform an insert with a where. The only thing you can do is updating or deleting a row with a where statement.

So you either want this code

Code:
$data = array(
    'websites' => $website
}
$this->db->insert('bf_users', $data);

or this code

Code:
$data = array(
    'websites' => $website
}
$this->db->where('id', $this->current_user->id)->update('bf_users', $data);

Yet guessing from your post you want to use the second code snippet.




Theme © iAndrew 2016 - Forum software by © MyBB