在MySQL中唱变量

Using Variable in MySQL

I have tried many possibilities and consulted a number of sources but still not have been able to insert a string into a MySQL command in php.

Code below works well

 $SQL = 'INSERT INTO tb_addressbook (`ID`, `First_Name`, `Last_Name`, `Address`) VALUES (\'24\', \'JJ\', \'Gates\', \'Microsoft\');';

Code below does not work

 $SQL = 'INSERT INTO tb_addressbook (`ID`, `First_Name`, `Last_Name`, `Address`) VALUES (\'27\', \''.'"$first"'.'\''.', \'Gates\', \'Microsoft\');';

Can you help?

P.S. Is there a special way to insert a string for numbers?

Hugh hugh@hahaggerty.com

Try like this :

$SQL = "INSERT INTO tb_addressbook (ID, First_Name, Last_Name, Address) VALUES ('27', '".$first."', 'Gates', 'Microsoft')";