[freetds] Sybase error

Daniel Fazekas fdsubs at axelero.hu
Thu Apr 22 20:43:59 EDT 2004

On Apr 23, 2004, at 0:03, rconner at commspeed.net wrote:

> thanks for the replys but I did find the issue.  It seems that teh 
> statement was getting messed up when it was pulling some information 
> that
> had html in it.  someone entered into the db by accident.  so i have 
> that
> all cleared up.

You shouldn't just leave it as such. Even if it's considered bogus 
data, a SELECT statement and FreeTDS ought not choke on retrieving any 
kind of data from columns. Especially not plain old html, which, for 
storage purposes, is nothing more than plain text.

>  I do have a question though.  I cant seem to put the
> output into tables with out it giving a parse error.  Any suggestions?
> $ms_con = mssql_connect("$myServer", "$myUser", "$myPass") or
>   die("mssql_connect(): Can't connect to server.\n");
> $res = mssql_query("SELECT * FROM tablename", $ms_con) or
>   die("mssql_query(): Query Failed.\n");
> while ($arr = mssql_fetch_row($res)) {
>   print $arr["0"];
>   print $arr["1"];
>   print $arr["2"];
>   print $arr["3"];
>   print $arr["4"];
>   print $arr["5"];
>   print $arr["6"];
>   print $arr["7"];
> }
> ?>

This is syntactically valid php code - well, short of the starting 
<?php tag you omitted for the message - which I can't see causing any 
PHP parsing errors.

What I also can't see is how this is going to output data into tables.
This is just dumping the first eight columns of your table concatenated 
without any separator, without any post-processing (eg. escaping or 
trimming control characters).
All those print statements are functionally equivalent in this case to 
a line of:
	echo implode('', array_slice($arr, 0, 8));

If this very simple code is already causing PHP parsing errors, I can 
only imagine a stray binary character or extra quotation mark which got 
lost when you transferred it to the email. You could then just copy it 
back to from your message to a new file. :)

If it's a html or javascript parsing error, we would need more 
information but, it would be totally unrelated to FreeTDS anyway.

For example, you should be using htmlspecialchars() or htmlentities() 
(depending on the character encoding you use for your pages) before 
outputting the data into a html page. If your PHP code outputs data to 
be inside JavaScript strings, you'd have to use addslashes(), and so 


More information about the FreeTDS mailing list