Inserting into table twice..:( |
[eluser]Roy MJ[/eluser]
Hi everyone, I am not sure so as to whether im doing anything wrong with the databse operations. The values that im intending to insert into the database once are being added twice.. Can anyone tell me what im doing wrong..?? Here is the controller part.. Code: function memberadd($id, $pgoffset='') Here is the model part.. Code: function add_member($id,$member) Can anyone help me find out y the data is being added twice into the table??
[eluser]Roy MJ[/eluser]
The table name is friends : The data inserted is as follows at a single time. id member_id friend status 1 13 11 0 2 13 0 0
[eluser]WanWizard[/eluser]
Did you search for this? This question has been asked several times here... Check for multiple page requests in your logs, due to rewriting of non-existent assets.
[eluser]Roy MJ[/eluser]
Yeah i have. But i found only problems regarding to htsccess file and stuff. In my case its the insert query or the controller. The value is geting passed to the variables, but somehow it reinserts the same value except on value which go in as null when it performs the query a second time... any idea y?... i haven called the model twice nor am i writing the query twice. But somehow its inserting 2 times. First with all the values and second with one value null.
[eluser]WanWizard[/eluser]
Did you do what I asked, and checked your logs? Because the most common cause IS a double URI request due to a rewrite of an non-existent asset...
[eluser]russ_kern[/eluser]
I found this happening one time in one of my scripts (2 actually)... turns out it was an error in how I was presenting pages... in essence, I was allowing the user to do the double post by returning them to the same form page and not providing adequate confirmation that the data had been successfully posted. They were then hitting the button a second time. It was a silly error on my end (because I was rushing)... Not saying this is the cause of your problem, but it may be worth a look. R
[eluser]Roy MJ[/eluser]
@WanWizard - how do i check the logs? the controller and model is just the same as the one i have displayed above. And im not calling the view twice or anything. Im really going mad with the deadline comin up fast.. @russ_kern - Yeah i think im not redirectig users to same page as u can see frm the controller that thr's actually 2 lines. One is to post data into database and other to redirect the user to a different page. (I'm rushing though..!!)
[eluser]WanWizard[/eluser]
To check CI's logs, enable logging in the config (set log_threshold to 4). You can also check your webserver's log. If it's a rewriting issue, you will see two page requests for the same URI (which is easier to see in your webserver log). The first is going to be the post, the second a get (which is why you don't have any values).
[eluser]toopay[/eluser]
It will be great, if CI Teams develop some Core Debugging Function (like Kohana did with Kohana::debug), instead log process... |
Welcome Guest, Not a member yet? Register Sign In |