Collections:
PHP ODBC - Inserting Data into an Existing Table
PHP ODBC - How To Insert Data into an Existing Table?
✍: Guest
If you want to insert a row of data into an existing table, you can use the INSERT INTO statement as shown in the following sample script:
<?php
$con = odbc_connect('FYI_SQL_SERVER','sa','FYIcenter');
$sql = "INSERT INTO fyi_links (id, url) VALUES ("
. " 101, 'dev.fyicenter.com')";
$res = odbc_exec($con, $sql);
if (!$res) {
print("SQL statement failed with error:\n");
print(odbc_error($con).": ".odbc_errormsg($con)."\n");
} else {
print("One data row inserted.\n");
}
$sql = "INSERT INTO fyi_links (id, url) VALUES ("
. " 102, 'dba.fyicenter.com')";
$res = odbc_exec($con, $sql);
print("One data row inserted.\n");
odbc_close($con);
?>
If you run this script, two data rows should be inserted into the table. And you will get:
One data row inserted. One data row inserted.
⇒ PHP ODBC - Inserting Multiple Rows with a Subquery
⇐ PHP ODBC - Creating a New Table
⇑ SQL Server FAQs - PHP ODBC Functions - Managing Tables and Data Rows
2024-06-03, 2147🔥, 0💬
Popular Posts:
What is dba.FYIcenter.com Website about? dba.FYIcenter.com is a Website for DBAs (database administr...
How To Connect the Oracle Server as SYSDBA in Oracle? This is Step 4. The best way to connect to the...
How To Locate and Take Substrings with CHARINDEX() and SUBSTRING() Functions in SQL Server Transact-...
How To Start MySQL Server in MySQL? If you want to start the MySQL server, you can run the "mysqld" ...
What is sqlservr.exe - Process - SQL Server (SQLEX?PRESS) in SQL Server? Process sqlservr.exe is the...