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]
5 1847
[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.
By the way: great SQL statement code for some SQL injection!
Ronald
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.
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.
....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
Sign in to post your reply or Sign up for a free account.
Similar topics
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 also wish to accomplish this with a large MS SQL...
|
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
application and when the cheque is clear the...
|
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 there is a threshold on the number of columns of
the...
|
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 without me being there doing it manually.
I'm...
|
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 database
Using all automagic tools (DataAdapter...
|
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 below.
I have a Microsoft Access 2000 database...
|
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...
|
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 for a week now and find the
different data handling...
|
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?
Here is the code:
Dim gConnString As String =...
|
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
(Datareader), but my problem when i do this:
1 -...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |