Jump to content

CREATE sql problem


Tha_slughy

Recommended Posts

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());

Link to comment
https://forums.phpfreaks.com/topic/2649-create-sql-problem/
Share on other sites

$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

Link to comment
https://forums.phpfreaks.com/topic/2649-create-sql-problem/#findComment-8794
Share on other sites

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--]

Link to comment
https://forums.phpfreaks.com/topic/2649-create-sql-problem/#findComment-8796
Share on other sites

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--]

Link to comment
https://forums.phpfreaks.com/topic/2649-create-sql-problem/#findComment-8797
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.