Re: FreeTDS and PHP: empty strings and NVARCHAR
Frediano Ziglio <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <CAHt6W4cBdeAHUucEC_2RkGN1sdPNUou1h8Gsyq8HYAdTOPCqjw@mail.gmail.com> |
2011/7/11 Mattia <[email protected]>: > 2011/7/11 Frediano Ziglio: >> 2011/7/9 Mattia: >>> So, >>> with SYBVARCHAR an empty string is inserted (in presence of strange characters); >>> with SYBNVARCHAR, sql server throws an error (unknown data type) >>> with XSYBNVARCHAR, everything works perfectly. >>> >> >> Could you provide a simple PHP code which demonstrate the problem? >> Have you the problem inserting data or fetching them? Did you setup >> correctly client charset? >> > > The problem is inserting data. Fetching them works fine. > Client charset is UTF-8. > > Php code is pretty simple: > > <?php > $conn = mssql_connect($hostname, $db_user, $db_pass ) or die ( "Unable > to connect" ); > mssql_select_db($db_name) or die("$db_name not found"); > > $an_id = 1; > $the_string="This would result Ő in an empty string"; > > $stmt = mssql_init('My_Stored_Proc'); > mssql_bind ($stmt, '@string', $the_string, SQLVARCHAR, false, false); > mssql_bind($stmt, '@id', $an_id, SQLINT4, false, false); > > $result=mssql_execute($stmt) or die('Stored proc execution failed'); > mssql_free_statement($stmt); > mssql_close($conn); > ?> > > Id gets inserted and mssql_execute returns true. The string is empty. > Db is a Sql 2008 R2 Web Edition (with the standard edition is the same). > > -- > Mattia Got it! However I'm pondering if is not better to pass always strings as unicode. The conversion matrix is the same except for image where conversion is not possible and binary/varbinary where conversion is different. But who should pass binary using char data ?? freddy77 _______________________________________________ FreeTDS mailing list [email protected] http://lists.ibiblio.org/mailman/listinfo/freetds