Tha_slughy Posted October 11, 2005 Share Posted October 11, 2005 what is wrong with this, i get error: ERROR: Unknown column 'sdfsd' in 'field list' 1054 where sdfsd is the value i put into the php array Array ( [1] => 144 [2] => sdfsd [3] => fsdf [4] => sdfsdf [5] => sdfs [6] => df [7] => sdf [8] => fsdf [9] => sdf [10] => sdfs [11] => dfsdf ) $create = $_POST['create']; print_r($create); $sql_query = "INSERT INTO kaarten VALUES (nummer=$create[1], land=$create[2], schaal=$create[3], plaats=$create[4], blad=$create[5], kaart=$create[6], conditie=$create[7], aantal=$create[8], status=$create[9], eigenaar=$create[10], comment=$create[11])"; $result = mysql_query($sql_query, $link) or die("ERROR: ". mysql_error() ." ". mysql_errno()); Quote Link to comment https://forums.phpfreaks.com/topic/2649-create-sql-problem/ Share on other sites More sharing options...
effigy Posted October 11, 2005 Share Posted October 11, 2005 review the insert syntax. Quote Link to comment https://forums.phpfreaks.com/topic/2649-create-sql-problem/#findComment-8792 Share on other sites More sharing options...
ryanlwh Posted October 11, 2005 Share Posted October 11, 2005 put single quotes around the array values. Quote Link to comment https://forums.phpfreaks.com/topic/2649-create-sql-problem/#findComment-8793 Share on other sites More sharing options...
Tha_slughy Posted October 11, 2005 Author Share Posted October 11, 2005 $sql_query = "INSERT INTO kaarten (nummer,land,schaal,plaats,blad,kaart,conditie,aantal,status,eigenaar,comment) VALUES ($create[1],$create[2],$create[3],$create[4],$create[5],$create[6],$create[7],$create[8],$create[9],$create[10],$create[11])"; gives the same error Quote Link to comment https://forums.phpfreaks.com/topic/2649-create-sql-problem/#findComment-8794 Share on other sites More sharing options...
effigy Posted October 11, 2005 Share Posted October 11, 2005 [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']insert[/span] into table (column_name1, column_name2) values ('value1', 'value2') [!--sql2--][/div][!--sql3--] Quote Link to comment https://forums.phpfreaks.com/topic/2649-create-sql-problem/#findComment-8795 Share on other sites More sharing options...
Tha_slughy Posted October 11, 2005 Author Share Posted October 11, 2005 You are right, figured it out just as you posted, thanks alot, this is buggy too: [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--]$sql_query = "[span style=\'color:blue;font-weight:bold\']UPDATE kaarten SET (land,schaal,plaats,blad,kaart,conditie,aantal,status,eigenaar,comment) = ('[/span]$nummer[2]','$nummer[3]','$nummer[4]','$nummer[5]','$nummer[6]','$nummer[7]','$nummer[8]','$nummer[9]','$nummer[10]','$nummer[11]') [span style=\'color:green\']WHERE nummer = '[/span]$nummer[1]'"; [!--sql2--][/div][!--sql3--] Quote Link to comment https://forums.phpfreaks.com/topic/2649-create-sql-problem/#findComment-8796 Share on other sites More sharing options...
ryanlwh Posted October 11, 2005 Share Posted October 11, 2005 i don't think you can use that notation for UPDATE. just SET them one by one [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']UPDATE[/span] kaarten SET land='$number[2]', schaal='$number[3]'... [!--sql2--][/div][!--sql3--] Quote Link to comment https://forums.phpfreaks.com/topic/2649-create-sql-problem/#findComment-8797 Share on other sites More sharing options...
effigy Posted October 11, 2005 Share Posted October 11, 2005 please take the time to understand the manual at mysql.com; this would handle the majority of your problems. Quote Link to comment https://forums.phpfreaks.com/topic/2649-create-sql-problem/#findComment-8798 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.