Help with a database insert - 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 with a database insert (/showthread.php?tid=42836) Pages:
1
2
|
Help with a database insert - El Forum - 06-21-2011 [eluser]Miguel Diaz[/eluser] Hi I am trying to store in a table multiple values in one time, my table have three columns 1.categoriaslocatariosID 2.localID 3.categoriaID and I tried this Code: $categorias = array( but it is sending me an error A Database Error Occurred Error Number: 1054 Unknown column 'Array' in 'field list' INSERT INTO `categoriasLocatarios` (`localID`, `categoriaID`) VALUES (Array, 0) Filename: /Applications/MAMP/htdocs/modules/clientes_corporativos/controllers/clientes_corporativos.php Line Number: 57 and this one A PHP Error was encountered Severity: Notice Message: Array to string conversion Filename: mysql/mysql_driver.php Line Number: 535 can someone help me with this query is the first time I am trying to insert multiple rows in one table Help with a database insert - El Forum - 06-21-2011 [eluser]adityamenon[/eluser] This is happening because you're sending an array to MySQL. Try this out... Code: $categorias = array( let me know what error you get, if any. Help with a database insert - El Forum - 06-21-2011 [eluser]adityamenon[/eluser] I also have an uneasy feeling about the structure of your table. Post your table schema also in case what I wrote doesn't work. Help with a database insert - El Forum - 06-21-2011 [eluser]Miguel Diaz[/eluser] thanks adityameno that is right my table structure is different I try using how you put it and it is sending me this error and it is because the column of telefonia does not exist My table structure is first column = categoriaLocatarioID - int - key - autoincrement second column = categoriaID third column = localID I need to insert in this database all the categories that our clients sale so i am putting the clientID in localId and the category id in the categoryID Thanks for all the help I am new with databases and php Help with a database insert - El Forum - 06-21-2011 [eluser]adityamenon[/eluser] So... it's working now, right? Help with a database insert - El Forum - 06-21-2011 [eluser]Miguel Diaz[/eluser] no it is sending me an error A Database Error Occurred Error Number: 1054 Unknown column 'telefonia' in 'field list' INSERT INTO `categoriasLocatarios` (`localID`, `telefonia`) VALUES (0, 0) Filename: /Applications/MAMP/htdocs/modules/clientes_corporativos/controllers/clientes_corporativos.php Line Number: 53 Help with a database insert - El Forum - 06-21-2011 [eluser]adityamenon[/eluser] What are the values you are getting via POST? Help with a database insert - El Forum - 06-21-2011 [eluser]Miguel Diaz[/eluser] These are the values. <input type="hidden" name="computo" value="1"> <input type="hidden" name="telefonia" value="2"> <input type="hidden" name="reparacion" value="3"> <input type="hidden" name="instrumentos_musicales" value="4"> <input type="hidden" name="fotografia" value="5"> <input type="hidden" name="entretenimiento" value="6"> <input type="hidden" name="electronica" value="7"> <input type="hidden" name="localID" value="1"> I was checking and my first error is that I am putting columns that does not exist in my database in the array like you said those columns didnt exist I want to store those values in the same column Code: $categorias = array( This doesnot work either but you have any idea how can i do it. Thanks Help with a database insert - El Forum - 06-21-2011 [eluser]Miguel Diaz[/eluser] categoriaLocatarioID is the column key to identify the union between localID and CategoriaID Help with a database insert - El Forum - 06-21-2011 [eluser]adityamenon[/eluser] So, you are generating hidden input fields for every category a dealer has products in (checkboxes and javascript?). Then, you want to store the dealer's ID, and the categories he deals in. Now I get it. Try this: Code: $categorias = array( Let me know if there's more errors |