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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Fri Mar 29 15:01:28 2024 UTC