![]() |
Help for php newbie, getting db error 1064 on update - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Help for php newbie, getting db error 1064 on update (/showthread.php?tid=27296) |
Help for php newbie, getting db error 1064 on update - El Forum - 02-06-2010 [eluser]Unknown[/eluser] Could some php/ codeigniter wizard assist a noob with this function? I have only been writing code for a couple of days and i am trying to update data in a database. The below function loops through each database row getting a folder and filename and loads the corresponding xml file. It then pulls a value from the xml file and inserts it into the database. It is failing at the update with a 1064 db error. I know it should probably be split up into a model and controller but I dont understand php / codeigniter enough to do that yet. Code: function index() { If i swap this line: Code: $data = array('desc' => $desc_to_store); With this line: Code: $data = array('desc' => "'$desc_to_store'"); It works, but when i query the data it is output enclosed in single quotes? Thanks! Help for php newbie, getting db error 1064 on update - El Forum - 02-06-2010 [eluser]Unknown[/eluser] Ok, thought i would let you people know i found the answer, it may help someone. If i swap this line: Code: $desc_to_store = $loadxml->Descriptions->Description->Value; with this Code: $desc_to_store = (string) $loadxml->Descriptions->Description->Value; this now works: Code: $data = array('desc' => $desc_to_store); $desc_to_store needed to be converted from an object to a string. |