Skip to Content.
Sympa Menu

freetds - Hungry PHP

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Paul Schaap" <Paul.Schaap AT dingoblue.com.au>
  • To: freetds
  • Subject: Hungry PHP
  • Date: Sat, 11 Sep 1999 10:35:45


Brian,

Following on from my previous MS SQL post here is some further details on
the odd behaviour under php. Please note that under sqsh there is no
problem.

Here is a phtml
############################################################################
<HTML>
<HEAD>
<TITLE>freetds kicks butt</TITLE>
</HEAD>
<BODY>
<CENTER><H1><U>Hungry PHP</U></H1></CENTER>
<?
$cnn = sybase_pconnect("Your MS SQL Server","Login","Password")
or die("Connect");
$db = sybase_select_db("A Database",$cnn)
or die("Select");

// Surname is a VARCHAR
$sql = "SELECT ID, Surname, ID
FROM Customer
WHERE ID = 10000696";
echo "$sql<BR>";
$qry = sybase_query($sql);
if($qry){
list($i1,$i2,$i3) = sybase_fetch_row($qry);
echo "$i1 $i2 eat me $i3<BR>\n";
echo "$i1 $i2 <B> eat me $i3</B><BR>\n";
}
sybase_free_result($qry);

// WITH A CONVERT
$sql = "SELECT ID, CONVERT(CHAR(20),Surname), ID
FROM Customer
WHERE ID = 10000696";
echo "$sql<BR>";
$qry = sybase_query($sql);
if($qry){
list($i1,$i2,$i3) = sybase_fetch_row($qry);
echo "$i1 $i2 eat me $i3<BR>\n";
echo "$i1 $i2 <B> eat me $i3</B><BR>\n";
}
sybase_free_result($qry);
?>
</BODY>
</HTML>
############################################################################

Heres a possible schema, I'm not 100% on the MS SQL DB syntax ...
############################################################################
CREATE TABLE Customer (
ID INTEGER,
Surname VARCHAR(255)
);
############################################################################

Heres the output on the Browser
############################################################################
Hungry PHP

SELECT ID, Surname, ID FROM Customer WHERE ID = 10000696
10000696 Schaap
10000696 Schaap eat me 10000696
SELECT ID, CONVERT(CHAR(20),Surname), ID FROM Customer WHERE ID = 10000696
10000696 Schaap eat me 10000696
10000696 Schaap eat me 10000696
############################################################################
notice the first 'eat me 10000696' on the first query just doesnt turn up.
But the second one does turn up ? The tag entered on the second one somehow
saves the data from dissappearing. A view source on the page also doesnt
reveal the missing info hidden in a tag or anything, it just vanished !

In the second query when I CONVERT all is well and as expected.

REGARDS
Paul




Archive powered by MHonArc 2.6.24.

Top of Page