Usarjjaco Posted July 16, 2010 Share Posted July 16, 2010 Hey everyone,I'm using several scripts similar to this to enter items into a players data table. This one is giving me a fit. mysql_query("INSERT INTO weapon (username, item, pic, weight, type, npcid, vid, bid, quan) VALUES ('$uname', '$tobuilditem', '$itempic', '$itemweight', '$type', '0', '0', '$bid', '1')"); All of the values are inserting except for the one on the end (the '1'), which corresponds to the quan column.It works just fine in another table (The items table) but in this table (The weapon table) it wont put that in for the quantity.Any help would be appreciated. I'm sure it's something small I'm missing. Link to comment Share on other sites More sharing options...
xjx424 Posted July 16, 2010 Share Posted July 16, 2010 is it just showing up blank in the database? What datatype are you using for that column? Link to comment Share on other sites More sharing options...
Usarjjaco Posted July 16, 2010 Author Share Posted July 16, 2010 It always shows up as 0 in the database table. I'm using a INT type for the data. Link to comment Share on other sites More sharing options...
HungryMind Posted July 16, 2010 Share Posted July 16, 2010 Hi!Try Use Value '1' Without Quotations, Or Just Set Variable To 1 Then Use Variable In Your QueryLike: $one = 1;mysql_query("INSERT INTO weapon (username, item, pic, weight, type, npcid, vid, bid, quan) VALUES ('$uname', '$tobuilditem', '$itempic', '$itemweight', '$type', '0', '0', '$bid', '$one')"); Link to comment Share on other sites More sharing options...
justsomeguy Posted July 16, 2010 Share Posted July 16, 2010 That's going to do exactly the same thing. If you're inserting a number, you don't need to put quotes around the value. Quotes mean it's a string. Link to comment Share on other sites More sharing options...
HungryMind Posted July 16, 2010 Share Posted July 16, 2010 Xctly My Friend :)Congr8 Link to comment Share on other sites More sharing options...
justsomeguy Posted July 16, 2010 Share Posted July 16, 2010 Right, but you still have quotes around it:mysql_query("INSERT INTO weapon (username, item, pic, weight, type, npcid, vid, bid, quan) VALUES ('$uname', '$tobuilditem', '$itempic', '$itemweight', '$type', '0', '0', '$bid', '$one')"); Link to comment Share on other sites More sharing options...
HungryMind Posted July 16, 2010 Share Posted July 16, 2010 So Plz Correct, My Mistake Link to comment Share on other sites More sharing options...
thescientist Posted July 16, 2010 Share Posted July 16, 2010 so I think ultimately you're going to want to go for something like this: mysql_query("INSERT INTO weapon (username, item, pic, weight, type, npcid, vid, bid, quan) VALUES ('$uname', '$tobuilditem', '$itempic', '$itemweight', '$type', 0, 0, '$bid', 1)"); now numbers will be seen as numbers, not strings. Link to comment Share on other sites More sharing options...
Usarjjaco Posted July 17, 2010 Author Share Posted July 17, 2010 I'll give that a shot and post results. I'm sure it'll work though, thanks guys. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.