Inserting data MySQL

Mar 12, 2012   //   by phpfreelancer.biz   //   Blog, MySQL Tutorial  //  No Comments

To add new records to the database table

Here’s the code:

<?php
$db_host        = 'localhost'; 
$db_user        = 'root'; 
$db_pass        = '*******'; // root pass 
$db_database    = 'contacts';  

$link = @mysql_connect($db_host,$db_user,$db_pass); 
mysql_select_db($db_database,$link); 

$query = "INSERT INTO contacts VALUES ('','John','Smith')"; 

mysql_query($query); 
mysql_close(); 
?> 

Leave a comment

Share This Post

RSS Wordpress News