yeahz Posted June 16, 2011 Report Share Posted June 16, 2011 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSER INTO club_members (club_id, member, class, accepted) VALUES (3, 54, 'membe' at line 1 $q = "INSER INTO club_members (club_id, member, class, accepted) VALUES ($club_id, $user[id], 'member', 'no')"; mysql_query($q) or die(mysql_error()); nekādi nesaprotu kas par vainu. kāds var izlīdzēt? Quote Link to comment Share on other sites More sharing options...
briedis Posted June 16, 2011 Report Share Posted June 16, 2011 "INSER INTO club_members (club_id, member, class, accepted) VALUES ($club_id, {$user['id']}, 'member', 'no')" Quote Link to comment Share on other sites More sharing options...
waplet Posted June 16, 2011 Report Share Posted June 16, 2011 pasteidzas. + ir INSERT nevis INSER Quote Link to comment Share on other sites More sharing options...
xPtv45z Posted June 16, 2011 Report Share Posted June 16, 2011 INSER? :) Quote Link to comment Share on other sites More sharing options...
daGrevis Posted June 16, 2011 Report Share Posted June 16, 2011 Un... $user[id] ...vietā būtu jābūt: {$user['id']} Quote Link to comment Share on other sites More sharing options...
yeahz Posted June 16, 2011 Author Report Share Posted June 16, 2011 nu ja, kārtējā neuzmanības kļūda, paldies :) un variet man izskaidrot, kāpēc ir vajadzīgas tās {} iekavas? nekad neesmu viņas izmantojis un viss bija ok. (šajā gadījumā arī strādāja bez, vajadzēja tikai to INSERT) Quote Link to comment Share on other sites More sharing options...
daGrevis Posted June 16, 2011 Report Share Posted June 16, 2011 Tāpēc ka šādi nav pareizi rakstīt: $array[indexWithoutQuotes] ...ja tas ir asociatīvais masīvs. Ir jāraksta: $array['indexWithQuotes'] ...bet tā kā tā nevar darīt, ja tas viss ir kā strings; atliek vai nu: 'pam-pam-pam ' . $array['index'] . ' pam!' ...vai: "pam-pam-pam {$array['index']} pam!" Tavs variants strādās, bet tas nenozīmē, ka tā ir jādara. Un kas notiks, ja "id" būs konstante? T.i.: define( 'id', 'pam' ); Dari kā vajag un viss biežāk būs bumbās! Quote Link to comment 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.