Skip to Content.
Sympa Menu

freetds - Insert/update returns failure using PHP sybase_query

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Dave Osborne" <dave.osborne AT cibc.ca>
  • To: freetds AT franklin.oit.unc.edu
  • Subject: Insert/update returns failure using PHP sybase_query
  • Date: Thu, 1 Nov 2001 17:24:14 -0500


Hi everyone,

Here's my problem, when I submit an insert or update query using the PHP
sybase_query function, the insert or update successfully completes but PHP
returns a failure status, and I think the connection is then marked dead
as any following insert/update fails to complete.

Is this a clue? using sqsh, if I submit an insert or update, the insert or
update is successful but I do not get the expected '(n rows affected)'
message, I get no response at all.

Any ideas?

The environment:
- Apache 1.3.20, PHP 4.0.6 (using sybase-ct-lib), FreeTDS 0.53pre1
- HP-UX 11
- connecting to Sybase 11.5.1 (which is running on HP-UX 10.20)

Here's the test PHP program:
<?
$cnn = sybase_connect("THEFORCE","aaaa","aaaaaaa");

sybase_select_db ("tempdb", $cnn);
if (!($result=sybase_query("insert dave values (1,1)", $cnn))) {
echo "insert failed<br>";
}
echo "affected rows = ", sybase_affected_rows($cnn), "<br>";

if (!(sybase_query("update dave set col2 = 2", $cnn))) {
echo "update failed<br>";
}

echo "affected rows = ", sybase_affected_rows($cnn), "<br>";
sybase_close($cnn);
?>

The output from this PHP program:
Warning: Sybase: Server message: Changed database context to 'tempdb'.
(severity 10, procedure N/A) in /home/oz/public_html/test.php on line 23
insert failed
affected rows = 0
update failed
affected rows = 0

The noted results: The insert worked, the update did not.

TDSDUMP:

2001-11-01 17:02:04 Connecting addr xxx.xx.x.xxx port 2050
Sending packet @ 2001-11-01 17:02:04
0000 02 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0020 00 00 00 00 00 00 00 61 61 61 61 00 00 00 00 00 |.......aaaa.....|
0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0040 00 00 00 00 00 04 61 61 61 61 61 61 61 00 00 00 |......aaaaaaa...|
0050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0060 00 00 00 00 07 33 37 38 37 36 00 00 00 00 00 00 |.....37876......|
0070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0080 00 00 00 05 02 00 06 04 08 01 00 00 00 00 00 00 |................|
0090 00 00 00 00 50 48 50 20 34 2e 30 00 00 00 00 00 |....PHP 4.0.....|
00a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00b0 00 00 07 54 48 45 46 4f 52 43 45 00 00 00 00 00 |...THEFORCE.....|
00c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00d0 00 08 00 07 61 61 61 61 61 61 61 00 00 00 00 00 |....aaaaaaa.....|
00e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
01a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
01b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
01c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
01d0 00 09 05 00 00 00 43 54 2d 4c 69 62 72 61 72 79 |......CT-Library|
01e0 0a 05 00 00 00 00 0c 10 00 00 00 00 00 00 00 00 |................|
01f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|


Sending packet @ 2001-11-01 17:02:04
0000 02 01 00 5d 00 00 00 00 00 00 00 00 00 00 00 00 |...]............|
0010 00 00 00 00 00 00 00 00 00 00 00 00 00 69 73 6f |.............iso|
0020 5f 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |_1..............|
0030 00 00 00 00 00 00 00 00 00 00 00 05 01 35 31 32 |.............512|
0040 00 00 00 03 00 00 00 00 e2 00 12 01 07 03 6d 7f |..............m.|
0050 ff ff ff fe 02 07 00 00 0a 68 00 00 00 |.........h...|


2001-11-01 17:02:04 inside tds_process_login_tokens()
2001-11-01 17:02:04 inside tds_process_default_tokens() marker is e3
2001-11-01 17:02:04 inside tds_process_default_tokens() marker is e5
2001-11-01 17:02:04 Msg 5701, Level 10, State 2, Server THEFORCE, Line 1
Changed database context to 'luke'.

2001-11-01 17:02:04 inside tds_process_default_tokens() marker is e3
2001-11-01 17:02:04 inside tds_process_default_tokens() marker is e2
2001-11-01 17:02:04 inside tds_process_default_tokens() marker is fd
2001-11-01 17:02:04 leaving tds_process_login_tokens() returning 1
2001-11-01 17:02:04 leaving ct_connect() returning 1
2001-11-01 17:02:04 inside ct_cmd_alloc()
2001-11-01 17:02:04 inside ct_command()
2001-11-01 17:02:04 inside ct_send()
Sending packet @ 2001-11-01 17:02:04
0000 0f 01 00 18 00 00 00 00 21 00 00 00 0b 00 75 73 |........!.....us|
0010 65 20 74 65 6d 70 64 62 |e tempdb|


2001-11-01 17:02:04 inside ct_results()
2001-11-01 17:02:04 processing result tokens. marker is e3
2001-11-01 17:02:04 inside tds_process_default_tokens() marker is e3
2001-11-01 17:02:04 processing result tokens. marker is e5
2001-11-01 17:02:04 processing result tokens. marker is fd
2001-11-01 17:02:04 inside ct_command()
2001-11-01 17:02:04 inside ct_send()
Sending packet @ 2001-11-01 17:02:04
0000 0f 01 00 26 00 00 00 00 21 00 00 00 19 00 69 6e |...&....!.....in|
0010 73 65 72 74 20 64 61 76 65 20 76 61 6c 75 65 73 |sert dave values|
0020 20 28 31 2c 31 29 | (1,1)|


2001-11-01 17:02:04 inside ct_results()
2001-11-01 17:02:04 processing result tokens. marker is fd
2001-11-01 17:02:04 inside ct_cancel()
Sending packet @ 2001-11-01 17:02:04
0000 06 01 00 08 00 00 00 00 |........|


2001-11-01 17:02:04 inside ct_con_props() action = 25 property = 26
2001-11-01 17:02:04 inside ct_close()
2001-11-01 17:02:04 inside ct_con_drop()






Archive powered by MHonArc 2.6.24.

Top of Page