Afgelopen dagen ben ik bezig geweest met een IRC Bot. Nou loop ik tegen het volgende probleem aan:
De 2de keer dat dit word gebruikt krijg ik dit:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/gunnewe1/public_html/gic/Bot.php on line 33
Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/gunnewe1/public_html/gic/Bot.php on line 37
Hier is de code:
Ik hoop dat jullie mij kunnen helpen. Alvast bedankt voor je bijdrage!PHP Code:
function hf_claim($usr,$claim)
{
//Claim System:
$result = mysql_query("SELECT * FROM Members");
while($row = mysql_fetch_row($result))
{
$users[] = $row[0];
}
if(in_array($usr, $users)){
irc_reply("Hey ".$usr.", I'm working on your claim. You'll get an message if it is completed.","#G-I-C");
$result = mysql_query("SELECT * FROM Claims WHERE Claim = '".$claim."'");
$num_rows = mysql_num_rows($result);
if($num_rows==0){
$good=mysql_query("INSERT INTO Claims VALUES ('".$claim."','".$usr."');");
if($good){
irc_reply($usr.", Your claim on ".$claim." is succesfully placed.","#G-I-C");
}else{
irc_reply($usr.", Something went wrong while claiming ".$claim.". My boss knows it.","#G-I-C");
irc_debug_log("----------- CLAIM FAILED!!! -------------");
irc_debug_log("-- Claim Info:");
irc_debug_log("-- Nick: ".$usr);
irc_debug_log("-- Claim: ".$claim);
irc_debug_log("-----------------------------------------");
}
}else{
$row = mysql_fetch_row($result);
irc_reply("Your claim (".$claim.") is allready claimed by ".$row[1].". Please choose another target.","#G-I-C");
}
}else{
irc_reply("Sorry ".$usr.", Your nickname is not known by me. Please use your Hacker Forever name.","#G-I-C");
}
}
function hf_unclaim($usr,$claim)
{
//Claim System:
$result = mysql_query("SELECT * FROM Members");
while($row = mysql_fetch_row($result))
{
$users[] = $row[0];
}
if(in_array($usr, $users)){
irc_reply("Hey ".$usr.", I'm working on your unclaim. You'll get an message if it is completed.","#G-I-C");
$result = mysql_query("SELECT * FROM Claims WHERE Claim = '".$claim."' AND User = '".$usr."';");
$num_rows = mysql_num_rows($result);
if($num_rows==1){
$good=mysql_query("DELETE FROM Claims WHERE Claim='".$claim."' AND User='".$usr."';");
if($good){
irc_reply($usr.", Your claim on ".$claim." is succesfully removed.","#G-I-C");
}else{
irc_reply($usr.", Something went wrong while unclaiming ".$claim.". My boss knows it.","#G-I-C");
irc_debug_log("----------- UNCLAIM FAILED!!! -------------");
irc_debug_log("-- UnClaim Info:");
irc_debug_log("-- Nick: ".$usr);
irc_debug_log("-- Claim: ".$claim);
irc_debug_log("-----------------------------------------");
}
}else{
irc_reply("Your unclaim (".$claim.") is not claimed by you.","#G-I-C");
}
}else{
irc_reply("Sorry ".$usr.", Your nickname is not known by me. Please use your Hacker Forever name.","#G-I-C");
}
}
- [PHP] MySQL probleem.
-
24-05-2010, 16:17 #1
- Berichten
- 208
- Lid sinds
- 15 Jaar
[PHP] MySQL probleem.
-
-
24-05-2010, 16:36 #2
- Berichten
- 1.263
- Lid sinds
- 16 Jaar
Post dan gelieve wel het hele script of in ieder geval de lines waarin de error voorkomt, zo is het erg veel zoekwerk / onduidelijkheid.
Overigens geven de foutmeldingen van php zelf meestal al genoeg informatie, 'invalid format second argument @ in_array' gaat dus waarschijnlijk over de array $users, probeert daar eens print_r($users) en die mysql_fetch_row kan je eens proberen de query uit te voeren in de database.
-
24-05-2010, 16:56 #3
- Berichten
- 1.053
- Lid sinds
- 17 Jaar
Inderdaad, dit soort topics gewoon hard negeren. Eerst zelf wat doen om te debuggen, dan pas vragen. Lekker inefficient geschreven ook btw, bijna 2x hetzelfde ;-)
Blijkbaar wis je alle members of doe je ergens een mysql_select_db die je niet herstelt.
Plaats een
- + Advertentie
- + Onderwerp
Marktplaats
Webmasterforum
- Websites algemeen
- Sitechecks
- Marketing
- Domeinen algemeen
- Waardebepaling
- CMS
- Wordpress
- Joomla
- Magento
- Google algemeen
- SEO
- Analytics
- Adsense
- Adwords
- HTML / XHTML
- CSS
- Programmeren
- PHP
- Javascript
- JQuery
- MySQL
- Ondernemen algemeen
- Belastingen
- Juridisch
- Grafisch ontwerp
- Hosting Algemeen
- Hardware Info
- Offtopic