PHP Udate MySQL command
| From: | Gary | Date: | Fri, 04 Jun 2010 10:46:26 +0000 |
| Subject: | PHP Udate MySQL command | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-305797@lists.php.net to get a copy of this message | ||
I am trying to get an update command to work in PHP. I am able to update
records going directly to phpmyadmin command line. I have even let it
produce the php code to insert, but have not been able to get it to work.
I have it stripped down to one command hoping to get it to work then
replicate entire forms for clients to use direct.I get no error codes, I
only get my message "It did not enter into DB";
Anyone see where I am going wrong?
Gary
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>"
method="post">
test<input name="test" type="text" />
<input name="submit" type="submit" value="submit" />
</form>
<?php
$batchconnetion = mysql_connect(host, 'un', 'pw', 'db')//sanatized for
board
or die('Error connecting with MySQL Database');
$test=$_POST['test'];
//$sql="update contact set type = \'$test\' where item_id = \'164\'";
//this
is the code created by phpmyadmin
$sql = "INSERT INTO contact comments, VALUES = $test WHERE contact_id =
33";
mysql_query($sql,$batchconnetion);
$result = mysql_query($sql,$batchconnetion);
if($result == true) {
echo "Successfully Inserted Records";
} else {
echo "It did not enter into DB";
}
mysql_close($batchconnetion);
?>
</body>
</html>
__________ Information from ESET Smart Security, version of virus signature database 5171 (20100604)
__________
The message was checked by ESET Smart Security.
http://www.eset.com