php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27493 mssql_query fails to insert row
Submitted: 2004-03-04 08:18 UTC Modified: 2004-03-04 14:40 UTC
From: jimmybrock at yahoo dot com Assigned:
Status: Closed Package: MSSQL related
PHP Version: 4.3.4 OS: Windows 2000
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jimmybrock at yahoo dot com
New email:
PHP Version: OS:

 

 [2004-03-04 08:18 UTC] jimmybrock at yahoo dot com
Description:
------------
problem:
mssql_query does not like foreign keys and primary keys that are set to varchar. It will not insert a new row and it does not return an error (returns true)

solution:
change datatype for foreign key and primary key to 'tinyint'
change underlying data to match new data types
voila! a new row is inserted

Reproduce code:
---------------
// groupName is set to varchar(25) in database
// administators is already in the table group
// so the print statement should execute
$g='administrators';

if not exists (select groupName from groups where groupName='$g')
begin
   INSERT INTO $this->dbtable
   (groupName) 
   VALUES ('$g')
end
else
print 'Group Name already exists in table groups'

Expected result:
----------------
if the variable passed into the query exists in the current table I excepted the query NOT to execute, and that the print statement would be returned.

Actual result:
--------------
mssql_query returns True, but does not insert a new row.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-04 13:29 UTC] fmk@php.net
The query returns true as everything was performed ok (that is if you add the missing end to your sample code). You can use mssql_get_last_message() to get the message you are printing. This is not returned as a result but as a message from the server.
 [2004-03-04 14:40 UTC] jimmybrock at yahoo dot com
duh! bad snytax
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC