By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,723 Members | 1,876 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,723 IT Pros & Developers. It's quick & easy.

How to Use Insert Query In PHP With Access database?

P: 12
Hi to all,
How to use insert query in php?
I m using ODBC connection with access database.I want to save data in table.
I m using database 'PHPDB1'.
Table Name 'EDETAIL'.
There r two fields in table: 'ENO' & 'ENAME'.
I want to take to text box and one submit button.
I want to save the value of text box in table when i click on submit button.
How to do all this process using PHP?
I had already create connection
I m using Below code to fetch data from this table.
It works properly.
"
[PHP]$conn=odbc_connect('phptest1','','');
if (!$conn)
{exit("Connection Failed: " . $conn);}

//$sql="INSERT INTO edetail(eno)values('$_POST[name]')";


$sql="SELECT * FROM edetail";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{exit("Error in SQL");}

echo "<table><tr>";
echo "<th>ECode</th>";
echo "<th>EName</th></tr>";
while (odbc_fetch_row($rs))
{
$eno=odbc_result($rs,"eno");
$ename=odbc_result($rs,"ename");
echo "<tr><td>$eno</td>";
echo "<td>$ename</td></tr>";
}
odbc_close($conn);
echo "</table>";

?>[/PHP]"

But i want to save data through form....So plz help me...I Want to learn more about PHP.

Thanx In Advance.....
Feb 23 '08 #1
Share this Question
Share on Google+
1 Reply


Markus
Expert 5K+
P: 6,050
Doesn't line number five work?
[php]
$_query = "INSERT INTO `table_name` (`row`) VALUES ('{$_POST['ESCAPED_STRING']}']";
ob_exec($_conn, $_query) or die("Error inserting " . odbc_error());
[/php]
I can't stress enough that you have to escape user input.

DONT DOUBLE POST!
http://www.thescripts.com/forum/thread774403.html
Feb 23 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.