note 8956 added to Sybase functions
| From: | jamesma at netvigator dot com | Date: | Mon, 09 Oct 2000 06:17:21 +0000 |
| Subject: | note 8956 added to Sybase functions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-6228@lists.php.net to get a copy of this message | ||
Bugs in PHP or Sybase interface?
I have many many time and try to solve some unexpected error in using Sybase with PHP.
After few days study, I found a interesting bug that make me working for long time.
The following script is a working version.
=========================================================
<html>
<head>
<title>No Title</title>
<meta http-equiv="content-Type" content="text/html">
</head>
<body>
<table border=0 width='100%' bgcolor='#51A8FF' cellspacing='1'>
<tr bgcolor='#FFA953' align='center'>
<td bgcolor='#B0D8FF'></td>
<td bgcolor='#B0D8FF'></td>
<td bgcolor='#B0D8FF'>Title</td>
<td bgcolor='#B0D8FF'>Sender</td>
<td bgcolor='#B0D8FF'>Reply</td>
<td bgcolor='#B0D8FF'>Last Repl</td>
</tr>
<?php
$a = sybase_connect("wwwsybase","sa","");
$b = sybase_select_db("james", $a);
$q = sybase_query("SELECT title FROM msgbox", $a);
while($row = sybase_fetch_object($q)) {
print "<tr bgcolor='white' aligh='center'>";
print "<td></td>";
print "<td></td>";
print "<td>$row->title</td>";
print "<td></td>";
print "<td></td>";
print "<td></td>";
print "</tr>";
}
$x = sybase_close($a);
?>
</table>
</body>
</html>
=====================================================
There has nothing special, and of course it works as expected.
But if I just add one character 'y' to line 15 to correct the spelling:
<td bgcolor='#B0D8FF'>Last Reply</td>
It will cause an error and the page does not display.
In fact, the original one is not as simple as I show here, I just try to address the problem by
removing line by line. It seems that if there has too many characters within the same area of
sybase_connect statement, it will generate an expected error.
I have try to solve this problem by making a function for sybase_connection, and the function is
defined outside <body>, which is called in the current location of original script. -- It
works!
But I encounted another problem after moving the sybase function to a function, this function cannot
accept parameters or using global variable. If a declare a input parameter for this function, or if
i declare using a global inside the function, the page cannot be show.
I don't know if I have make any syntax error in my script, or is it really a buy in PHP.
My installation setting:
RedHat Linux 6.2
Sybase for Linux 11.9.2
PHP 4.0.2
Would anyone here can give me some example on using Sybase connetion with PHP.
Thanks in advance,
James MA
http://www.php.net/manual/ref.sybase.php