If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > PHP with ODBC INSERT INTO fails

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-27-09, 23:00
TommyGunn TommyGunn is offline
Registered User
 
Join Date: Jul 2009
Posts: 6
PHP with ODBC INSERT INTO fails

Hi all Doing a project for Uni here and am having a problem Insert date into one table the Code I am using as as follows

<?php
$Conn = odbc_connect ('0602', 'root', '');

$fbcom = $_REQUEST['fbcom']; $fbrating = $_REQUEST['fbrating']; $fbdate = $_REQUEST['fbdate']; $fbcust = $_REQUEST['fbcust']; $fbdate = $_REQUEST['fbdate'];

$post = odbc_prepare($Conn, "INSERT INTO feedb(comments, rating, date, Custid)VALUES('$fbcom', '$fbrating', '$fbdate', '$fbcust')");

if (!odbc_execute($post))
{echo "Feedback Table Update failed";}

else {{echo "Feedback Table Updated";}
?>

I am usig microsoft access as my database, I have the same code from inserting data into two tables and it works fine on that, I have removed all relationship from the feedback table so at the moment nothing else effects it and it has one more field that is a primary key that is set using auto number,

this ha mt stumped and I need help big time.
Reply With Quote
  #2 (permalink)  
Old 07-28-09, 04:22
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
have you checked the ODBC_ErrorMsg, and if so what did it tell you was wrong?

I'm surprised you are using odbc_prepare & odbc_execute.. I thought these were only used on strored procedures, something I don't think JET supports. I would have expected to be using odbc_exec
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 07-28-09, 10:01
TommyGunn TommyGunn is offline
Registered User
 
Join Date: Jul 2009
Posts: 6
Ok turned on the ODBC_ErrorMsg

and it comes back with

Error: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
Reply With Quote
  #4 (permalink)  
Old 07-28-09, 10:17
TommyGunn TommyGunn is offline
Registered User
 
Join Date: Jul 2009
Posts: 6
OK thanks for the help have solved the problem

I believe that date is restricted so changed this to fbdate and all was well
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On