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
Using insert variable
Moderator: General Moderators
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Using insert variable
SQL requires you to quote your strings:
$sql = "INSERT INTO `phones`.`phonedata` (`accNum`, `model`) VALUES ($acc,'$nok')";
$sql = "INSERT INTO `phones`.`phonedata` (`accNum`, `model`) VALUES ($acc,'$nok')";