• Welcome to Web Hosting Community Forum for Webmasters - Web hosting Forum.
 

Recommended Providers

Fully Managed WordPress Hosting
lc_banner_leadgen_3
Fully Managed WordPress Hosting

WordPress Theme

Divi WordPress Theme
WPZOOM

Forum Membership

Forum Membership

UPDATE MS ACCESS USING PHP

Started by crusty, January 25, 2008, 06:40:25 PM

crusty

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.
<?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]

Kailash

#1
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:

<?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,

crusty

#2
Thanks for that.
Brilliant. Thanks a lot.
alec