/    Sign up×
Community /Pin to ProfileBookmark

how do I ignorewarnings in php

[code]
$query = “select wwlands.type as type from wwlands where number1 = $y”;
$result = [b]@[/b]querydatabase ($query);
if (mysql_result($result, 0, “type”) == 1)
echo “<img src=images/stst.jpg alt=M />”;
[/code]

Heres the code. Now I am looking up alot of things that may exist or may not. I do I do this look up and not have all the warnings not found printed on the page.

tia

to post a comment
PHP

11 Comments(s)

Copy linkTweet thisAlerts:
@aznchong91Sep 07.2005 — The @ should do the trick...
Copy linkTweet thisAlerts:
@bokehSep 07.2005 — What error does it return?
Copy linkTweet thisAlerts:
@DARTHTAMPONauthorSep 08.2005 — ok fixed it. thx
Copy linkTweet thisAlerts:
@bathurst_guySep 08.2005 — how do I ignorewarnings in php[/quote]
you pretend they arent there ?
Copy linkTweet thisAlerts:
@DARTHTAMPONauthorSep 08.2005 — they are still there but I am going to get a warning regardless. In certain instances The data I look up cannot be found so when I try to use it, it is not there and hence gives me a warning. Is there a way to check to see if data exists befor I try to use it???
Copy linkTweet thisAlerts:
@NogDogSep 08.2005 — [code=php]
$query = "select wwlands.type as type from wwlands where number1 = $y";
if($result = @querydatabase ($query))
{
if (mysql_result($result, 0, "type") == 1)
{
echo "<img src=images/stst.jpg alt=M />";
}
}
[/code]

However, depending on what's in your querydatabase() function, you may need some code there, too, to keep it from throwing any errors.
Copy linkTweet thisAlerts:
@bokehSep 08.2005 — <>
Copy linkTweet thisAlerts:
@SpectreReturnsSep 10.2005 — error_reporting(0);

Saves me every time.
Copy linkTweet thisAlerts:
@theuedimasterSep 11.2005 — The errors pop up for a reason man... you don't want to ignore them....
Copy linkTweet thisAlerts:
@DARTHTAMPONauthorSep 11.2005 — yes but errors and warning are 2 different things.

warnings are inevatable when I look for data that does not exist.
Copy linkTweet thisAlerts:
@NogDogSep 11.2005 — yes but errors and warning are 2 different things.

warnings are inevatable when I look for data that does not exist.[/QUOTE]

Hmmm....how so? A mysql_query() should only trigger a warning if the query is invalid, not if it returns no matches. If you're running into errors when trying to read from a query result that has no rows, then precede that part with an if statement, such as:
[code=php]
if(mysql_num_rows($result) > 0)
{
while($row = mysql_fetch_array($result))
{
# output data for this row
}
}
else
{
# output error message saying no data was found.
}
[/code]
×

Success!

Help @DARTHTAMPON 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.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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