Re: Checking for result of call to mssql_query()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux