I have created a SIMPLE function to update a table in mySQL, but for some reason it won't work.
function addMainPage($title, $content) {
$db = mysql_connect("localhost", "root", "") or die("Could not connect");
$query = "INSERT INTO mainpage (title, content) VALUES ('$title', '$content');";
mysql_db_query("$db", "$query") or die("Couldn't add contents foo!");
mysql_close($db);
}
The database name is intranet, the table name is mainpage (all lower case). I have a form that passes the $title and $content variables to the function. It always tells me it "couldn't add contents foo!" (the die statement for the query). Now, if I copy the query and run it from the command line it works. So the query has to be fine. Wouldn't it tell me it couldn't connect if the username and password weren't right? I checked that the fields in the table were right. BTW, mySQL is installed on a Windows NT 4 system, under IIS 4. The service is running. I can run SQL statements just fine from PHPmyAdmin.
I'm frustrated... Thanks for any help. It's probably some simple thing and I am just retarded.
Thanks!
Chad