Divi WordPress Theme

Topic: UPDATE MS ACCESS USING PHP  (Read 7118 times)

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

  • Web Hosting Master
  • *****
  • Administrator
  • Posts: 610
  • 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: