Jump to content

mssql_result, simple...


scottybwoy

Recommended Posts

I have a number of sql abstraction functions, but this one always displays a notice message, but returns the correct result.  What do I need to iron out?

function selectRecord($record, $tbl, $col, $val) {

	$sql = "SELECT $record FROM $tbl WHERE $col = ";

	if (is_int($val)) {
		$sql .= "$val";
	} else {
		$sql .= "'" . $val . "'";
	}

	//echo $sql;
	$qry = mssql_query($sql);
	$res = mssql_result($qry, 0, 0) or trigger_error("$sql Failed", E_USER_NOTICE);

	return $res;
}

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/120193-mssql_result-simple/
Share on other sites

Sorry, I should have mentioned I'm using MsSQL, which doesn't like backticks.

 

The notice that is being displayed is : PHP Warning: mssql_result() [function.mssql-result]: Bad row offset (0) in D:\Inetpub\wwwroot\testing\classes\mri_central.php on line 348

 

When I comment out the E_USER_NOTICE

 

And it displays my error when its not, which displays something like : PHP Notice: SELECT name FROM client WHERE clientId = 'NOR0000' Failed in D:\Inetpub\wwwroot\testing\classes\mri_central.php on line 348

 

If I copy and paste that into a query window, it returns the expected result, as it does normally.

 

Link to comment
https://forums.phpfreaks.com/topic/120193-mssql_result-simple/#findComment-619920
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.