Forum Moderators: coopster
query failed: ERROR: pg_atoi: zero-length string in... this is because the variable contains no value nothing so I'm trying to assign a null value if the variable is empty...
if (empty($Memory)) { $Memory=NULL;} Bob
$Memoryvariable the value of
NULL. If you print it out, nothing will be displayed or printed to output, just the null value. Try running your INSERT with the actual word NULL, not the value null.
if (empty($Memory)) { $Memory='NULL';}Note the single quotation marks, now assigning the word NULL to your variable as opposed to the value.
$INSquery= "INSERT INTO \"tblWorkstation\" Values (
'{$WSID}',
'{$Make}',
'{$WSModelName}',
'{$WSModelNum}',
'{$Serial}',
'{$CPU}',
'{$HDD}',
'{$FDD}',
'{$Memory}',
'{$MacAdd}',
'{$NIC}',
'{$IPAdd}',
'{$RCCode}',
'{$OSName}',
'{$DatPurch}',
'{$Replaced}',
'{$PCordLen}',
'{$AssetID}',
'{$DatInst}',
'{$DatEnt}',
'{$TName}',
'{$Comments}',
'{$DeptName}',
'{$BuildName}',
'{$Level}',
'{$ComUser}',
'{$Outlet}',
'{$Situation}')";
$INSquery= "INSERT INTO \"tblWorkstation\" Values (...specifically in that you are enclosing the value in quotation marks, which postgresql is choking on.
...
'{$Memory}',
...
'{$ComUser}',
'{$Outlet}',
'{$Situation}')";
This thread [webmasterworld.com] addresses a similar issue, how to insert a NULL value, except for MySQL. However, the same syntax holds true for postgresql. Note particularly message number 17.
[edited by: jatar_k at 4:02 pm (utc) on May 19, 2004]