error with insert



I have the following code, which functions properly as is, but when I try to bring in data from a form or just simply create a variable in the code, it doesn't execute properly. (e.g. I want to say $x = 5. If I put this in the code, nothing will execute.) Any ideas what is wrong?


// Make a MySQL Connection
mysql_connect ("localhost", "username here", "password here") or die (mysql_error());
mysql_select_db ("Botag") or die (mysql_error());

// Insert a row of information into the table "example"

$query = "INSERT INTO articles ( title , author, art_text, art_date )
'titlehere2', '30', 'text', '0000-00-00 00:00:00'

mysql_query($query) or die(mysql_error());

echo "Data Inserted!";

We can't help you unless you tell us what error you're getting. If you're not getting an error, turn error_reporting in php.ini to E_ALL. And have you tried echoing your query and posting it into a MySQL client?
No errors are coming up. I added error_reporting(E_ALL); at the beginning and I get the same thing, nothing. I do get error messages most of the time if I do something wrong, but in this case, nothing is printed. I tried executing the commands in phpmyadmin but I can't even get the code to work without the added variables, so this is of no help.

What do you mean, "with the added variables"? What variables?

And when I say "in a MySQL client", I don't mean phpMyAdmin. Try mysql.exe or MySQLCC.
try this...
$query = "INSERT INTO articles ( title , author, art_text, art_date )
'".$title."', '".$author."', '".$art_text."', '".date("Y-m-d H:i:s", $datestamp)."'

I actually don't know what solved my original problem, but I fixed it. But I soon ran into another one. When I tried to put variables into "values," it spit up errors saying that my columns were not in the field. Perhaps you thought this is what I meant previously. But either way, your solution solved my new problem. I had searched the internet looking for solutions, and the only thing that I could come across was people saying that installations were bad. I am curious to know why the combination of ', ", and . fix this problem. I greatly appreciate your help.