Jump to content


Photo

CREATE sql problem


  • Please log in to reply
7 replies to this topic

#1 Tha_slughy

Tha_slughy
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 11 October 2005 - 07:54 PM

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


#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 11 October 2005 - 08:41 PM

review the insert syntax.
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 11 October 2005 - 09:19 PM

put single quotes around the array values.
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#4 Tha_slughy

Tha_slughy
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 11 October 2005 - 09:33 PM

$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

#5 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 11 October 2005 - 09:48 PM

[!--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--]
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#6 Tha_slughy

Tha_slughy
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 11 October 2005 - 09:54 PM

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

#7 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 11 October 2005 - 10:38 PM

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--]
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#8 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 11 October 2005 - 11:47 PM

please take the time to understand the manual at mysql.com; this would handle the majority of your problems.
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users