为什么有些变量需要引号而其他变量不需要?例如,当我连接到数据库变量时不需要引号,但是当我选择或插入数据库时,我需要引号。
例子:
//variables
$username="username";
$password="password";
$first=$_POST['first'];
$last=$_POST['last'];
//connect to DB
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to connect to database");
//values assigned
$query = "INSERT INTO guestbook VALUES
('','$first','$last','$email','$web','$comment')";
mysql_query($query);