473,387 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to Use Insert Query In PHP With Access database?

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
1 4271
Markus
6,050 Expert 4TB
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

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

Similar topics

6
by: jason | last post by:
I am picking up an error message on a straightforward INSERT - do I need an optimistic-type to get this working....here is is the error: Microsoft JET Database Engine error '80004005' Operation...
6
by: efgh | last post by:
I'm fairly confident in my knowledge of SQL but I'm stumped with regards with an Insert Into statement in Access 2003. I've got a 4 column table that I've simplified about as much as I can, no...
3
by: John Marble | last post by:
I am quite new with Access, so please be indulgent if my question sound a little bit newbish. I have two table in the same database: DOSSIER and MAIN. MAIN is having already formatted data...
8
by: Carl | last post by:
Hi, I hope someone can share some of their professional advice and help me out with my embarissing problem concerning an Access INSERT query. I have never attempted to create a table with...
3
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
14
by: Ben | last post by:
I don't know whether anyone can help, but I have an odd problem. I have a PSP (Spyce) script that makes many calls to populate a database. They all work without any problem except for one...
6
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
10
by: MLH | last post by:
Suppose, in a multi-user environment, you have append query SQL in a VBA procedure that looks like INSERT INTO MyTable... and the next line reads MyVar=DMax("","MyTable... You can never be...
5
by: DonnaL | last post by:
I'm using Access 2000, but this question likely pertains to any version of Access. Simply put, is there a programmatic way of inserting a new Query in whatever master system table stores these...
2
by: paulmitchell507 | last post by:
I think I am attempting a simple procedure but I just can't figure out the correct syntax. My asp (classic) page runs a SELECT query to obtain dates and ID's from 2 tables uSQL = "SELECT...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.