Re: Strange MySQL Problem
| From: | Jochen Schultz | Date: | Mon, 14 Dec 2009 08:47:10 +0000 |
| Subject: | Re: Strange MySQL Problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-300466@lists.php.net to get a copy of this message | ||
Hello Parham,
i think you should change this:
$sql = "INSERT INTO BOOK(bookname, authorsname, ISBN) VALUES
('$_POST[bookname]', '$_POST[authorsname]', $_POST[ISBN]')";
to this:
$sql = "INSERT INTO BOOK(bookname, authorsname, ISBN) VALUES
('".$_POST[bookname]."', '".$_POST[authorsname]."', '".$_POST[ISBN]."')";
best regards
Jochen
Parham Doustdar schrieb:
Hello there, Here's a short PHP script a friend has written, and given to me to test. However, I am getting a MySQL error saying that the syntax error, on the line that contains mysql_connect(); is wrong, near '')' (note that it is not a PHP error, but a MySQL error.) Here's the code: [code] <?php $username = "root"; $password = "abc"; $con = mysql_connect("", $username, $password); mysql_select_db ("test", $con); $sql = "INSERT INTO BOOK(bookname, authorsname, ISBN) VALUES ('$_POST[bookname]', '$_POST[authorsname]', $_POST[ISBN]')"; if (!mysql_query($sql, $con)) { die( 'error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> [/code]