ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-windows
php-windows
Re: [PHP-WIN] Checking for result of call to mssql_query()
by Frank M. Kromann other posts by this author
Oct 12 2006 10:39AM messages near this date
RE: [PHP-WIN] @mssql_connect() versus mssql_connect() | [PHP-WIN] re: SPAM-LOW: [PHP-WIN] PDO ODBC & MSSQL Stored Procedures that return record sets
Hi Alf,

As far as I can tell it's working just fine. Hre is a sample:

<?php

if (!extension_loaded("mssql")) {
	dl("php_mssql.dll");
}

$con = mssql_connect("server", "user", "secret");
if ($con) {
	mssql_query("create table test_a (c0 int)");
	$rs = mssql_query("insert into test_a (c0) values (1)");
	var_dump($rs);
	$rs = mssql_query("insert into test_a (c0) values ('aa')");
	var_dump($rs);
	mssql_query("drop table test_a");

	mssql_close($con);
}

?> 

and here is the output:

bool(true)

Warning: mssql_query(): message: Syntax error converting the varchar value
'aa' to a column of data type int. (severity
16) in C:\php5\test\mssql_error.php on line 10

Warning: mssql_query(): Query failed in C:\php5\test\mssql_error.php on
line 10
bool(false)


As you can see the first insert is successfull so true is returned. The
second insert has an error so errors are prontet from PHP and false is
returned.

- Frank

>  Am I misunderstanding the PHP Manual, where it says:-
>  mixed *mssql_query* ( string query [, resource link_identifier [, int
>  batch_size]] )
>  
>  Returns: A MS SQL result resource on success, *TRUE* if no rows were
>  returned, or *FALSE* on error.
>  
>   and my code reads:-
>  
>  $Reply = mssql_query($insert, $link);
>  if ($Reply == FALSE)
>          {
>  whether the query works or not I have yet to find $Reply equal to
FALSE.
>  Please tell me what I am misunderstanding and what is the correct method

>  
>  -- 
>  Regards,
>  Alf Stockton		www.stockton.co.za
>   
>  You will always have good luck in your personal affairs.
>  My email disclaimer is available at www.stockton.co.za/disclaimer.html
>  
>  -- 
>  PHP Windows Mailing List (http://www.php.net/)
>  To unsubscribe, visit: http://www.php.net/unsub.php
>  

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved