Jump to content

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

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.