473,790 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to update data in access database

23 New Member
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={Micros oft Access Driver (*.mdb)}; DBQ=" . realpath("2Poin tB.mdb").";";
$conn=odbc_conn ect($connstr,'' ,'') or die(Print "connect error: ".odbc_error()) ;


if($_POST[Emergency_Conta ct_Name]=="")$Emergency _Contact_Name=' NULL';
else $Emergency_Cont act_Name=$_POST[Emergency_Conta ct_Name];

if($_POST[Emergency_Conta ct#]=="")$Emergency _Contact#='NULL ';
else $Emergency_Cont act#=$_POST[Emergency_Conta ct#];

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

if($_POST[Special_Deitary _Requirements]=="")$Special_D eitary_Requirem ents='NULL';
else $Special_Deitar y_Requirements= $_POST[Special_Deitary _Requirements];


$sql="update tblCustomer set Customer_ID='$_ POST[Customer_ID]',Surname='$_PO ST[Surname]',Forename='$_P OST[Forename]', DOB='$_POST[DOB]',Sex='$_POST[Sex]',Address='$_PO ST[Address]', Town ='$_POST[Town]', City='$_POST[City]', Post_Code ='$_POST[Post_Code]', Telephone='$_PO ST[Town]', Emergency_Conta ct_Name='$_POST[Emergency_Conta ct_Name]', Emergency_Conta ct#='$_POST[Emergency_Conta ct#]', 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_er ror());

print "Thanks ".$Forename "your customer information has been updated";
?>
</body>
</html>
[/PHP]
Apr 16 '08 #1
5 1864
TheServant
1,168 Recognized Expert Top Contributor
[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 Recognized Expert Specialist
By the way: great SQL statement code for some SQL injection!

Ronald
Apr 16 '08 #3
Yew12
23 New Member
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={Micros oft Access Driver (*.mdb)}; DBQ=" . realpath("2Poin tB.mdb").";";
$conn=odbc_conn ect($connstr,'' ,'') or die(Print "connect error: ".odbc_error()) ;


if($_POST[Emergency_Conta ct_Name]=="")$Emergency _Contact_Name=' NULL';
else $Emergency_Cont act_Name=$_POST[Emergency_Conta ct_Name];

if($_POST[Emergency_Conta ct_No]=="")$Emergency _Contact_No='NU LL';
else $Emergency_Cont act_No=$_POST[Emergency_Conta ct_No];

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

if($_POST[Special_Deitary _Requirements]=="")$Special_D eitary_Requirem ents='NULL';
else $Special_Deitar y_Requirements= $_POST[Special_Deitary _Requirements];


$sql="update tblCustomer set Customer_ID='$_ POST[Customer_ID]',Surname='$_PO ST[Surname]',Forename='$_P OST[Forename]', DOB='$_POST[DOB]',Sex='$_POST[Sex]',Address='$_PO ST[Address]', Town ='$_POST[Town]', City='$_POST[City]', Post_Code ='$_POST[Post_Code]', Telephone='$_PO ST[Town]', Emergency_Conta ct_Name='$_POST[Emergency_Conta ct_Name]', Emergency_Conta ct_No='$_POST[Emergency_Conta ct_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_er ror());

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 Recognized Expert Top Contributor
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 Recognized Expert Specialist
....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
22948
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 Server database that we have. Question follows: The following SQL statement, used in VBScript,
2
5266
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 user have to open a form and entera date so we know in report that the desiered check has been cleared. It takes me while to wrtie. But when I try to update the datagrid changes via dataset to MS Access 2003 I get an error that simply says...
16
3877
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 table, or perhaps bytes, being updated where the engine just decides, screw it, i'll just make a new one. surfed this group and google, but couldn't find anything. the context: we have some java folk who like to parametize/
1
2016
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 trying to perform the replacement by using an external MS Access program that contains the replacement form also called FO-008. I need to keep the same form name since the form contains relationships to other forms and quarries in the program. ...
2
2877
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 Wizard with generatedDataset and generated Select, Update, Insert and Deletecommands, controls bound to DataSet using the AdvancedDatabinding properties) Issue: Do I have to set parameters before I issue theDataSet.Update(Dataset, )? Again, my...
0
5828
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 which indexes computer magazine articles for personal reference. I am developing a Visual Basic.NET program whose sole purpose is to enter new records into the database. No updates to existing entries, no deletions, and no display
3
3451
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 the necessary records in it when testing it. I get the error "No value given for one or more required parameters." when I try to update the database. Can you tell me what am I doing wrong?
2
2340
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 functions very easy and nice. Anyway, I'm afraid that I haven't understood the data binding things correct. I'm using MySQL Connector/.NET to access my database from the
7
1283
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 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Customer development\VBNET\CSFV\CSFV.mdb;" Dim Conn As New OleDbConnection(gConnString) 'Actual Connection to database. Conn.Open()
6
2026
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 - insert data (by dataset). 2- get data (by datareader). when i run this commands i can't get latest data from database, i get data before insert!!! but after few second i can get real data after insert, is this problem from Dataset or Datareader...
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9512
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10413
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10145
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7530
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.