#118391 - 2004-04-21 01:10 PM
Db Error - Column Count doesn't match......
|
Trackz
Fresh Scripter
Registered: 2004-03-18
Posts: 37
Loc: Rotterdam, The Netherlands
|
I don't get it anymore.
The one moment my queries are working fine, a second later, after making some small changes to the query itself, I get the error below.
Any idea what this "Column count doens't match..." means?
My logging
2004/04/21 12:03:07 - OPen - Connection Verified
2004/04/21 12:03:07 - 10. rsRecordset - Error: -2147352567 - COM exception error "Execute" (Microsoft OLE DB Provider
for ODBC Drivers - [MySQL][ODBC 3.51 Driver][mysqld-4.0.18-max-nt]Column count doesn't match value count at row 1) [-2147352567/80020009]
2004/04/21 12:03:07 - Close - The operation completed successfully.
My query:
Code:
$retcode = DBExecuteSQL($objConn,"INSERT INTO software (Sid, Workstation, Application, Version, Publisher, Path, DateTime)
VALUES('', '@wksta', '', '', '', '', '$DateTime')")
Also tried:
Code:
$retcode = DBExecuteSQL($objConn,"INSERT INTO software (Sid, Workstation, DateTime) VALUES('', '@wksta', '$DateTime')")
Edited by T_Hoek (2004-04-21 01:34 PM)
|
|
Top
|
|
|
|
#118392 - 2004-04-21 01:40 PM
Re: Db Error - Column Count doesn't match......
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
A couple of ideas.
First, avoid macros and variables in strings, it will bite you later: Code:
$retcode = DBExecuteSQL($objConn,"INSERT INTO software (Sid, Workstation, Application, Version, Publisher, Path, DateTime) VALUES('', '"+@wksta+"', '', '', '', '', '"+$DateTime+"')")
Second, and more likely, have you sanitised the data? If @WKSTA is returng a value like "T Hoek's PC" it is going to break your SQL statement because of the single quote character.
Similarly other characters may cause a problem, especially when you start recording application names and so-on.
|
|
Top
|
|
|
|
#118393 - 2004-04-21 02:14 PM
Re: Db Error - Column Count doesn't match......
|
Trackz
Fresh Scripter
Registered: 2004-03-18
Posts: 37
Loc: Rotterdam, The Netherlands
|
I've read about that not using @name-thingies in queries some time ago. only for this one it should be no problem, since there is no single PC in the network that is setup different then [firstletter][lastname] (ie. THoek)
In the query @WKSTA = thoek, and $Datetime=20041029141246 (or something like this number)
What is the meaning of the error? also when I enter a numbver or a word to insert, it doesn't work.
|
|
Top
|
|
|
|
#118394 - 2004-04-21 02:44 PM
Re: Db Error - Column Count doesn't match......
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
You have to be precise! Using the following, does not work. If we did, we could be playing guessing games for some time to come.
Quote:
20041029141246 (or something like this number)
Yes, that maybe the correct error, but we cannot work in the world of being a "teeny bit dead." Enuff of the lecture. 
Kent
|
|
Top
|
|
|
|
#118395 - 2004-04-21 03:22 PM
Re: Db Error - Column Count doesn't match......
|
Trackz
Fresh Scripter
Registered: 2004-03-18
Posts: 37
Loc: Rotterdam, The Netherlands
|
This number differs every second  Its sort of a timestamp that I like to use to insert in 3 different tables, as a pointer to gather data from an entire DB. This number is also stored as a timestamp in the registry of the PC.
ie. get all from hardware where time = $x get all from software where time = $x get all from userinfo where time = $x
At that time of reporting the error, the timestamp was: 20040421130155, and is written to the registry without problems
|
|
Top
|
|
|
|
#118397 - 2004-04-21 04:17 PM
Re: Db Error - Column Count doesn't match......
|
Trackz
Fresh Scripter
Registered: 2004-03-18
Posts: 37
Loc: Rotterdam, The Netherlands
|
I use a seperate file to include a bunch of function. In this file I made some changes after I was not able able to execute the queries. Reading through this file (copy of original version), and comparing this with the original, I was not able to find any changes. Must have mixed something up, since my logging to a textfile stopped working also. Replaced the 'functions'-file with the original, ands everything worked again. Think I missed some "'s or ;'s in here. 
Thanx for your time after all.
Jumping back to Richard H.'s note/ What I do like to know, is the following. I need to store strings like "c:\program files\Map\file.txt" in my db. When I now do this it insert cprogramfilesMapfiles.txt
Is there some function for handling addslashes/specialshars in queries. Couldn't find anything with the search, but if you can point something for me, I'll be very happy.. (wow. that would be the second time today)
|
|
Top
|
|
|
|
#118398 - 2004-04-21 05:31 PM
Re: Db Error - Column Count doesn't match......
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Use the Split/Join trick.
For example, to replace "\" with "\\": Code:
$Path=Join(Split($Path,"\"),"\\")
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1198 anonymous users online.
|
|
|