Jump to content

What's wrong with this query?


WarKirby

Recommended Posts

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 ?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.