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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.