Reply to Inserting NULL into a smalldatetime

Your name:

Reply:


Posted by Techie123 on 10/13/86 11:51

You'll probably all cry heretic or something when I tell that I'm
working with SQL Server databases, but I am. I actually don't have a
lot of choice in the matter. Changing it would mean telling a guy over
the phone how to install mySQL, so I'm trying to work SQL Server with
PHP.

I'm working with PHP version 4.3.1.0 and SQL Server 2000 housed on a
Win 2000 machine. I've decided the easiest for phone setup was to use
the ODBC function instead of trying to setup the mssql function...

To get to the point, I'm currently facing a problem with the
smalldatetime datatype. I can't INSERT a NULL value. The best I can get
so far is having 01/01/1900 00:00:00 AM show up.

The field is already set to accept NULL values and I can insert them
manually by creating a new line with nothing in the smalldatetime
fields or using ctrl+0, but when I try to do the following I get an
error:

<?php
$qryStr = "INSERT INTO OPSCenterISS (EventTypeID, EventStatus,
EventTitle, Location, AffectedUsers, EventDescription, StartDateTime,
EndDateTime, Contact, Organization, SubmitDateTime )
VALUES ( '$typeidinput', '$statusinput', '$titleinput', '$locinput',
'$affectedinput', '$descinput', '$startdatetime', 'NULL',
'$contactinput', '$orginput', '$submitdatetime' )"
or die ("Error in ODBC Write");
odbc_prepare ($sqlconnect, $qryStr);
odbc_exec($sqlconnect, $qryStr);
?>

It spits back an error that it can't convert to the smalldatetime
datatype. I think I might be using the wrong syntax, so it doesn't like
it. This error doesn't come up until I put that NULL in there. I have
other similar INSERT statements that use PHP variables alone and it
doesn't like that. Plus, if I try to set a PHP variable = NULL and
stick it in there, it gives me the same error.

Here's the error:

Warning: odbc_exec(): SQL error: [Microsoft][ODBC SQL Server
Driver][SQL Server]Syntax
error converting character string to smalldatetime data type.,
SQL state 22008 in SQLExecDirect in D:\input.php on line 173

I know not many people work with SQL Server 2000 but I'm sure there's
someone out there. I just need to keep trying!

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация