Jump to content

return 0


scottybwoy

Recommended Posts

Small Question

 

I have a little function that gets a result from a query when supplied arguments, it works great except when the result is 0.  Here's the func :

<?php
function selectRecord($record, $tbl, $where, $val) {

$sql = "SELECT $record FROM $tbl WHERE $where = $val";
$qry = mssql_query($sql);
$res = mssql_result($qry, 0, 0) or trigger_error("There was an error selecting $record for $val", E_USER_ERROR);

return $res;
}
?>

When ever it tries to return a 0 it triggers the SQL error.  Any one know why?

Link to comment
https://forums.phpfreaks.com/topic/51463-return-0/
Share on other sites

Hi Daniel,

 

I mean that the result in the database is a 0, when I call via a SELECT Query, It fails and triggers the Defined error in my code.

 

It works fine when the result in the database is not 0.

 

When entering the same SELECT query directly into MsSQL it reters the 0 as expected.

 

It seems as if the error is not with the php or MsSQL but the way they communicate with each other.

Link to comment
https://forums.phpfreaks.com/topic/51463-return-0/#findComment-253651
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.