我有以下要执行的代码:
// Connecting to the database "db_name"
$connection = mysql_connect('......com', 'login', 'password', 'db_name');
if (!$connection) {
die('Could not connect: ' . mysql_error());
}
echo "Connection Successful";
// creating a query
mysql_query($connection, "INSERT INTO `customers` (`FirstName`, `Lastname`, `Username`, `Email`,
`Password`) VALUES ($firstname, $lastname, $username,$email,$password);");
mysql_close($connection);
// printing to the screen
echo "Welcome $lastname . You have successfully logged in!";
我得到的结果如下
Connection SuccessfulWelcome . You have successfully logged in! Add another user
但是,MySQL 中没有任何内容。未插入任何条目。我收到以下错误:
Warning: mysql_query() expects parameter 1 to be string, resource given in /hermes/bosweb/web241/b2418/ipg........com/login_action.php on line 28 20130143043: chmmmmm.com/login_action.php PHP Warning: mysql_query() expects parameter 1 to be string, resource given in /hermes/bosweb/web241/b2418/ipg.e........com/login_action.php on line 28