a newbie question here.
what is the correct syntax to use with PHP for an INSERT INTO query to a MySQL database that resides on the same server.
The server runs these versions
- PHP version 5.2.6
- MySQL version 5.0.77-community-log
Code:
<?php
$link = mysql_connect('localhost', 'admin1', 'admin2');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('database', $link);
if (!$db_selected) {
die('<p>unable to locate the database</p>');
}
/* Insertion Query to store attributes into Database */
mysql_query ("INSERT INTO tester
('value1', 'value2') VALUES ('tested', 'successfully')")
or die(mysql_error());
echo '<br />done successfully<br />';
mysql_close($link);
?>
The connection and database selection was successful. However I have labored for days on the right syntax to INSERT DATA with no luck, so i've turned to the forum for help. Thanks in advance.
Bookmarks