Can't Add Record

From: Date: Fri, 09 Jun 2000 02:35:37 +0000
Subject: Can't Add Record
Groups: php.general 
Request: Send a blank email to php-general+get-1360@lists.php.net to get a copy of this message
I'm a a loss! The following scripts fails at the $result = mysql_query($sql); line. I've also tried: $result = mysql_query($sql, $connection); The required variables are being passed correctly. The script gets past the 'if' test withut a problem. It connects to the server OK and selects the database ok, but the record fails to be written. My table is called 'users', and I can telnet to the table and enter the exact same INSERT command without a problem. I have the $sql variable echoing back to check that it's being formed ok. If I haven't changed things by the time you look at it, you can see for yourself at http://www.dallasbureau.com/admin_add.php. Log in as admin with pw of hardies. Anyone? Many thanks Don Smith <? if ((!$name) || (!$password) || (!$company) || (!$email)) { header("Location: http://www.dallasbureau.com/admin_add.php"); exit; } $connection = mysql_connect("localhost", "username", "mysqlpw") or die ("Couldn't connect to server."); $db = mysql_select_db("dallasbureau", $connection) or die ("Couldn't select database."); $sql = "INSERT INTO USERS (name,password,company,email) VALUES ('$name','$password','$company','$email')"; $result = mysql_query($sql); if (!$result) { echo "<P>Couldn't add record!"; } else { echo " <HTML> <HEAD> <TITLE></TITLE> </HEAD> <BODY> </BODY> </HTML> "; } ?>

« previous php.general (#1360) next »