Page 1 of 1

Using insert variable

Posted: Fri Oct 23, 2009 3:37 am
by peter.kathae
need a way to inert variable data to mysql database

$acc = "212121212";
$nok = "Nokia1100";
$db_link = mysql_connect("localhost","root", "");
mysql_select_db('Phones', $db_link ) or die (mysql_error());
$sql = "INSERT INTO `phones`.`phonedata` (`accNum`, `model`) VALUES ($acc,$nok)";

the coloured part is the one bringing

Re: Using insert variable

Posted: Fri Oct 23, 2009 3:59 am
by Mark Baker
SQL requires you to quote your strings:
$sql = "INSERT INTO `phones`.`phonedata` (`accNum`, `model`) VALUES ($acc,'$nok')";