WarKirby Posted February 16, 2010 Share Posted February 16, 2010 Trying to do what seems like a pretty simple insert, done plenty of these before. I mailed the query to myself just to be sure it was working. It says this: INSERT INTO tblProducts (articleNumber,productName,releaseDate) VALUES (999001001,'Test Product',1266290939) But only the articlenumber and release date go in properly. The productName from this query shows in the table as NULL. 'Test Product' does contain a space, but it's encapsulated with quotes which should prevent issues, no? What's even stranger is that NULL is not the default value. My table structure: mysql_query("CREATE TABLE tblProducts( articleNumber VARCHAR(9) NOT NULL DEFAULT '000000000', productName VARCHAR(63) NOT NULL DEFAULT 'no name', releaseDate INT NOT NULL, currentVersion VARCHAR(20) NOT NULL DEFAULT '1.0', productStatus INT DEFAULT '1', PRIMARY KEY(articleNumber))") or die(mysql_error()); It's definitely not too big, it's not an empty string, and it's properly quoted. Why isn't it working? My PHP code for the section, just in case if (!isValidProduct($articleNumber)) { $querystring = "INSERT INTO tblProducts (articleNumber,productName,releaseDate) VALUES " ."(".$articleNumber."," .QuoteSmart(trim($_POST['productName']))."," .$timeSold.")"; mail($to, "Creating product", $querystring); $result = mysql_query($querystring) or die(mail($to, "Failed creating new product", $querystring."\n".mysql_error())); if ($result === FALSE) { $errors++; } } Visible there is the mail line where I sent myself the query, as you can see there's no opportunity for $querystring to change before the query is sent. So what's wrong ? Quote Link to comment https://forums.phpfreaks.com/topic/192219-whats-wrong-with-this-query/ Share on other sites More sharing options...
WarKirby Posted February 16, 2010 Author Share Posted February 16, 2010 Wait, nevermind, this is user error, I figured it out. The problem is in another table Quote Link to comment https://forums.phpfreaks.com/topic/192219-whats-wrong-with-this-query/#findComment-1012950 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.