In a php script, I've attempted an insert statement several different ways:
$query = "INSERT INTO table (charfield,charfield,intfield,decimalfield) VALUES ('$stringvar','$stringvar',$intvar,$decimalvar)";
$query = "INSERT INTO table (charfield,charfield,intfield,decimalfield) VALUES ('".$stringvar."','".$stringvar."',".$intvar.",".$decimalvar.")";
$query = 'INSERT INTO table (charfield,charfield,intfield,decimalfield) VALUES ("'.$stringvar.'","'.$stringvar.'",'.$intvar.','.$decimalvar.')';
$query = 'INSERT INTO table (charfield,charfield,intfield,decimalfield) VALUES ("'.$stringvar.'","'.$stringvar.'","'.$intvar.'","'.$decimalvar.'")';
I've executed it several different ways too using combinations of these:
mysql_real_escape_string($query);
mysql_query($query);
$result = @mysql_query($query);
I've echo'd out the statement that is being concatenated and it looks fine. Even if I copy and paste that into phpmyadmin sql editor, it executes fine. The database is MySQL and the user has the correct permissions.
What am I doing wrong?
EDIT:
Error message using or die:
Access denied for user 'schaffins'@'localhost' (using password: NO)
I've added a user with the rights to select, insert, and update and I'm connecting using that user in the php before executing anything.
Also, I was able to insert into another table I made in the same script.
mysql_query($query) or die(mysql_error())and it will tell you what's wrong.