Web Hosting Forum - A Web Hosting community for Webmasters


Divi WordPress Theme

Author Topic: UPDATE MS ACCESS USING PHP  (Read 6668 times)

0 Members and 1 Guest are viewing this topic.

Offline crusty

  • Newbie
  • *
  • Posts: 2
  • iTrader: +0/-0
    • View Profile
UPDATE MS ACCESS USING PHP
« on: January 25, 2008, 06:40:25 PM »
Not sure if this is the correct place to post this question but here goes.
I've managed to read a record and insert a record but can't do an update using the following code.
Code: [Select]
<?php
$connect 
odbc_connect&#40;'Ah123', '', ''&#41;;
if &#40;!$connect&#41;
  
&#123;exit&#40;"Connection Failed&#58; " &#46; $connect&#41;;&#125;
$sql="SELECT * FROM Data";
$rs=odbc_exec&#40;$connect,$sql&#41;;
if &#40;!$rs&#41;
  
&#123;exit&#40;"Error in SQL"&#41;;&#125;
$id1;
$Header "New Entry";
$query1 "UPDATE data SET Header = $Header WHERE ID1= $id";
echo 
$query1;

$cr1=odbc_exec&#40;$connect,$query1&#41;; 

odbc_close&#40;$connect&#41;;
?>

The odbc_exec produces an error.

Please help an old struggling crusty
[/code]
« Last Edit: January 01, 1970, 05:30:00 AM by crusty »

VPS Hosting - AccuWebHosting

Offline Kailash

  • Administrator
  • Web Hosting Master
  • *****
  • Posts: 601
  • iTrader: +153/-0
    • View Profile
(No subject)
« Reply #1 on: January 29, 2008, 11:04:41 AM »
Hi Crusty,

If Header value is varchar data type then you will need to use Header = '$Header' in your update query. Your code should be as below:

Code: [Select]
<?php
$connect 
odbc_connect&#40;'Ah123', '', ''&#41;;
if &#40;!$connect&#41;
  
&#123;exit&#40;"Connection Failed&#58; " &#46; $connect&#41;;&#125;
$sql="SELECT * FROM Data";
$rs=odbc_exec&#40;$connect,$sql&#41;;
if &#40;!$rs&#41;
  
&#123;exit&#40;"Error in SQL"&#41;;&#125;
$id1;
$Header "New Entry";
$query1 "UPDATE data SET Header = '$Header' WHERE ID1= $id";
echo 
$query1;

$cr1=odbc_exec&#40;$connect,$query1&#41;;

odbc_close&#40;$connect&#41;;
?>


Regards,
« Last Edit: January 01, 1970, 05:30:00 AM by Kailash »

Offline crusty

  • Newbie
  • *
  • Posts: 2
  • iTrader: +0/-0
    • View Profile
UPDATE MS ACCESS USING PHP
« Reply #2 on: January 29, 2008, 04:49:34 PM »
Thanks for that.
Brilliant. Thanks a lot.
alec
« Last Edit: January 01, 1970, 05:30:00 AM by crusty »

Divi WordPress Theme
Tags:
 

Related Topics

  Subject / Started by Replies Last post
0 Replies
775 Views
Last post July 01, 2013, 10:52:16 AM
by Kailash
0 Replies
862 Views
Last post November 20, 2013, 09:39:44 AM
by Kailash
0 Replies
885 Views
Last post November 21, 2013, 09:56:21 AM
by Kailash
2 Replies
996 Views
Last post September 17, 2014, 11:06:55 AM
by WebhostingTalk
0 Replies
100 Views
Last post July 26, 2017, 11:30:51 AM
by maheshseo