Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ODBC - INSERT INTO

Status
Not open for further replies.

mptrew

MIS
Sep 7, 2001
42
GB
Help!!!!!

I am writing several odbc applications at once. In each of them I have been able to do queries, update existing records etc but can't insert new records. I get no syntax errors but the information doesn't get added into the table.

I don't really want to go to 'classes' as i would have to rework quite a bit of code.

Hereis the cose so far:-

$dsn="hit_counter.dsn";
$usr="iusr";
$pass="pass";

$db=odbc_connect($dsn,$usr,$pass);
if (!$db) {
Echo &quot;Unable to open db - $dsn<br>&quot;;
} else {
echo &quot;New row - $row - $page - $num<br>&quot;;
$query=&quot;INSERT INTO pages &quot;;
$query.=&quot;VALUES ID='99', page='$page', hits='$num' &quot;;
$result=odbc_do($db,$query);
}

Thnaks in anticipation

Martin
 
Check to make sure that all fields that have a NOT NULL def. has some value during INSERT statement even if it's just a blank.

ie. if field ID2 is NOT NULL and in your insert statment, you never refer to it, then nothing will happen.

cheers


devnull22

--
Apparently if you play the Windows NT CD backwards you hear satanic messages. If you think that's bad, play it forwards and it installs Windows NT !
 
Thanks,

how do you deal with a 'autonumber' field.

Martin
 
don't worry about the autonumber field as it will be automatically generated when you add a records.

cheers devnull22

--
Apparently if you play the Windows NT CD backwards you hear satanic messages. If you think that's bad, play it forwards and it installs Windows NT !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top