Chevy Posted February 17, 2007 Share Posted February 17, 2007 I have this query... $insert = mysql_query("INSERT INTO `useritems` (`itemid`,`owner`,`amount`) VALUES ('$itemid','$userinfo[username]','1')") or die(mysql_error()); All the query works except when the amount goes in it is not 1, it just goes in as a blank spot. Any idea whats wrong? Link to comment https://forums.phpfreaks.com/topic/38904-mysql-problem/ Share on other sites More sharing options...
hvle Posted February 17, 2007 Share Posted February 17, 2007 for the amount, try use 1 instead of '1'. if it doesn't work, please post the datatype for amount Link to comment https://forums.phpfreaks.com/topic/38904-mysql-problem/#findComment-187090 Share on other sites More sharing options...
Chevy Posted February 17, 2007 Author Share Posted February 17, 2007 Nope didn't work... In the mySQL table it is: amount int(12) NULL=No DEFAULT=0 Nothing else... Link to comment https://forums.phpfreaks.com/topic/38904-mysql-problem/#findComment-187092 Share on other sites More sharing options...
hvle Posted February 17, 2007 Share Posted February 17, 2007 ahhh VALUES ('$itemid','{$userinfo[username]}','1')" You need to wrap array item with brackets {} better yet: VALUES ('$itemid','{$userinfo['username']}','1')" single around array key is very important. Link to comment https://forums.phpfreaks.com/topic/38904-mysql-problem/#findComment-187096 Share on other sites More sharing options...
Chevy Posted February 17, 2007 Author Share Posted February 17, 2007 Yea this is really weird but it still isn't working... I don't understand, because the variables both go into the database but the 1 will not. Link to comment https://forums.phpfreaks.com/topic/38904-mysql-problem/#findComment-187100 Share on other sites More sharing options...
hvle Posted February 17, 2007 Share Posted February 17, 2007 yes, very weird. Can you post the table structure? The create table code Link to comment https://forums.phpfreaks.com/topic/38904-mysql-problem/#findComment-187102 Share on other sites More sharing options...
Chevy Posted February 17, 2007 Author Share Posted February 17, 2007 CREATE TABLE `useritems` ( `id` INT( 12 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `owner` VARCHAR( 255 ) NOT NULL , `amount` INT( 12 ) NOT NULL , `itemid` INT( 12 ) NOT NULL ) ENGINE = MYISAM ; Link to comment https://forums.phpfreaks.com/topic/38904-mysql-problem/#findComment-187104 Share on other sites More sharing options...
Chevy Posted February 17, 2007 Author Share Posted February 17, 2007 Okay I found the problem... I had a query about 20 lines below that was resetting it for some reason.. Sorry about that Thanks for the help though! Link to comment https://forums.phpfreaks.com/topic/38904-mysql-problem/#findComment-187107 Share on other sites More sharing options...
hvle Posted February 17, 2007 Share Posted February 17, 2007 LOL, ok Link to comment https://forums.phpfreaks.com/topic/38904-mysql-problem/#findComment-187108 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.