472,351 Members | 1,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Trying to update data in access database

23
I have been trying to update the details in a access database but, all I get is a white screen and all the errors I have built-in give me no help at all.

All help is greatly appreciated.


[PHP]<html>
<head><title> Customer Information Updated</title></head>
<body>

<?php

$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("2PointB.mdb").";";
$conn=odbc_connect($connstr,'','') or die(Print "connect error: ".odbc_error());


if($_POST[Emergency_Contact_Name]=="")$Emergency_Contact_Name='NULL';
else $Emergency_Contact_Name=$_POST[Emergency_Contact_Name];

if($_POST[Emergency_Contact#]=="")$Emergency_Contact#='NULL';
else $Emergency_Contact#=$_POST[Emergency_Contact#];

if($_POST[Telephone]=="")$Telephone='NULL';
else $Telephone=$_POST[Telephone];

if($_POST[Special_Deitary_Requirements]=="")$Special_Deitary_Requirements='NULL';
else $Special_Deitary_Requirements=$_POST[Special_Deitary_Requirements];


$sql="update tblCustomer set Customer_ID='$_POST[Customer_ID]',Surname='$_POST[Surname]',Forename='$_POST[Forename]', DOB='$_POST[DOB]',Sex='$_POST[Sex]',Address='$_POST[Address]', Town ='$_POST[Town]', City='$_POST[City]', Post_Code ='$_POST[Post_Code]', Telephone='$_POST[Town]', Emergency_Contact_Name='$_POST[Emergency_Contact_Name]', Emergency_Contact#='$_POST[Emergency_Contact#]', Special_Deitary_Requirements='$_POST[Special_Deitary_Requirements]' where Customer_ID='$_POST[Customer_ID]'";


$stmt=odbc_exec($conn, $sql)
or die (Print "execute error: ".odbc_error());

odbc_exec($conn, $stmt) or die (Print "error".odbc_error());

print "Thanks ".$Forename "your customer information has been updated";
?>
</body>
</html>
[/PHP]
Apr 16 '08 #1
5 1711
TheServant
1,168 Expert 1GB
[PHP]print ("Thanks ".$Forename.", your customer information has been updated.";[/PHP]

You forgot to join the string between your variable and the rest of the message (and I fixed up a little grammer), which might have confused the output line. Post back if that does not solve it and I will look at the code a bit closer.
Apr 16 '08 #2
ronverdonk
4,258 Expert 4TB
By the way: great SQL statement code for some SQL injection!

Ronald
Apr 16 '08 #3
Yew12
23
Thanks very much that help a lot. At least now I get an error.

[PHP]<html>
<head><title> Customer Information Updated</title></head>
<body>

<?php

$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("2PointB.mdb").";";
$conn=odbc_connect($connstr,'','') or die(Print "connect error: ".odbc_error());


if($_POST[Emergency_Contact_Name]=="")$Emergency_Contact_Name='NULL';
else $Emergency_Contact_Name=$_POST[Emergency_Contact_Name];

if($_POST[Emergency_Contact_No]=="")$Emergency_Contact_No='NULL';
else $Emergency_Contact_No=$_POST[Emergency_Contact_No];

if($_POST[Telephone]=="")$Telephone='NULL';
else $Telephone=$_POST[Telephone];

if($_POST[Special_Deitary_Requirements]=="")$Special_Deitary_Requirements='NULL';
else $Special_Deitary_Requirements=$_POST[Special_Deitary_Requirements];


$sql="update tblCustomer set Customer_ID='$_POST[Customer_ID]',Surname='$_POST[Surname]',Forename='$_POST[Forename]', DOB='$_POST[DOB]',Sex='$_POST[Sex]',Address='$_POST[Address]', Town ='$_POST[Town]', City='$_POST[City]', Post_Code ='$_POST[Post_Code]', Telephone='$_POST[Town]', Emergency_Contact_Name='$_POST[Emergency_Contact_Name]', Emergency_Contact_No='$_POST[Emergency_Contact_No]', Special_Deitary_Requirements='$_POST[Special_Deitary_Requirements]' where Customer_ID='$_POST[Customer_ID]'";

Print $sql;

$stmt=odbc_exec($conn, $sql)
or die (Print "execute error: ".odbc_error());

odbc_exec($conn, $stmt) or die (Print "error".odbc_error());

print ("Thanks ".$Forename. "your customer information has been updated");

?>
</body>
</html>
[/PHP]

The error is odbc error 22005 a date problem I think. Do you know what to do from here.

I don't know if this matters but Im from the uk so my date goes dd/mm/yyyy.


Oh thanks Ronald for making me aware.
Apr 16 '08 #4
TheServant
1,168 Expert 1GB
By the way: great SQL statement code for some SQL injection!

Ronald
One step at a time Ron. But Ron's right, you cannot go public with the code you have now. You need to take some security steps to stop people from using your database how they see fit. This means validating and sanitizing you inputs. Here is one to start you off (you can continue with google). But make another post if you have questions about that - one problem per post.
Apr 16 '08 #5
ronverdonk
4,258 Expert 4TB
....I don't know if this matters but Im from the uk so my date goes dd/mm/yyyy.....
It matters! I do not know the standard date format for Access but I quess it is, just like MySQL, YYYY-MM-DD. If that is true, you'll have to reformat your date before storing it in the database. You can use the PHP strtotime() and date() functions for that.

Ronald
Apr 16 '08 #6

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

Similar topics

12
by: jimserac | last post by:
I had previously posted this in an Access forum with negative results so will try here. Although this question specifies an Access database, I...
2
by: Niyazi | last post by:
Hi, I have not understand the problem. Before all the coding with few application everything worked perfectly. Now I am developing Cheque Writing...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that...
1
by: Michael Eisner | last post by:
I have an MS Access 8.0 (Office97) program that has a form called FO-008 that I need to replace on several users computers in different locations...
2
by: Joe Fetters via .NET 247 | last post by:
Have googled and read the VS.NET documentation can't seem to getthe answer to the following. Environment: Framework 1.1 VB.NET WinForm Access...
0
by: M. David Johnson | last post by:
I cannot get my OleDbDataAdapter to update my database table from my local dataset table. The Knowledge Base doesn't seem to help - see item 10...
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...
2
by: Ville Mattila | last post by:
Hi there, I will post my question to this group too bacause the .data group seems to be rather quiet. I've been playing with VB.NET and ADO...
7
by: lmnorms1 | last post by:
Hello, I am trying to update an access database record date field that matches a specific date. The code is not working. Anyone have any advice? ...
6
by: Tark Siala | last post by:
hi i'm using VS.NET 2005 +SP1 C#, and i connect access database by ADO.NET 2.0. i'm using Dataset to (insert,update,delete) and in get data i use...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

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.