/    Sign up×
Community /Pin to ProfileBookmark

problem with mysql error checking

Hi,

I have created myself some mysql function to make it easier when calling mysql data.

The problem I get is that if the value of the field is 0 then it picks it up as an error and fires it over to sqlerrorhandler function. When it is actually working just the fields value is 0.

[code=php]
function mysqlresult($queryresult, $field, $file, $function, $line, $sql) {

$sqlresult = @mysql_result($queryresult, 0, $field);

if (!$sqlresult) {
sqlerrorhandler(“(“.mysql_errno().”)”,”S0006″, mysql_error(), $file, $function, $line, $sql);
} else {
return $sqlresult;
}
}
[/code]

The same issue occurs if num rows equals 0 too.

Any help would be great,

Thanks
k0r54

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@TecBratMar 04.2009 — Zero is boolean false. You might try [code=php]//snip
if ($sqlresult===FALSE){
[/code]


Tripple equal checks for exact type and value match.
Copy linkTweet thisAlerts:
@Phill_PaffordMar 04.2009 — You might try this as well

[CODE]
// You have
$sqlresult = @mysql_result($queryresult, 0, $field);

// Try this
$sqlresult = mysql_result($queryresult, 0, $field);
[/CODE]


I believe the @ symbol is used to suppress error warnings. Your query could be throwing an error and it's not being passed back and that is why it's failing.
×

Success!

Help @k0r54 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...