Home > Misc > PHP – MySQL Insert

PHP – MySQL Insert

After long wait I got my hands dirty with PHP and MySQL.

$dbServer = 'localhost';
$dbUserName = 'username';
$dbPassword = 'password';
$connection = mysql_connect($dbServer, $dbUserName, $dbPassword);
if(!$connection) {
		  die('Connection Failed : ' . mysql_error());
}

$insertStatement = 'INSERT INTO TableName(Column) VALUES("Value")';
mysql_select_db('databaseName');
$returnValue = mysql_query( $insertStatement, $connection );
if(!$returnValue){
		  die('Insertion Failed : ' . mysql_error());
}
echo "Data Inserted.";
mysql_close($conn);

Advertisements
Categories: Misc Tags: ,
  1. January 16, 2014 at 9:11 PM
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: