Foros del Web » Programando para Internet » PHP »

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource

Estas en el tema de Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource en el foro de PHP en Foros del Web. Hola buenos dias, tengo el siguiente error en un script de login Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/metin2ar/public_html/members/itemshop/test_/Loginok.php ...
  #1 (permalink)  
Antiguo 17/10/2011, 06:51
 
Fecha de Ingreso: octubre-2011
Ubicación: Benidorm
Mensajes: 5
Antigüedad: 12 años, 6 meses
Puntos: 0
Busqueda Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource

Hola buenos dias, tengo el siguiente error en un script de login Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/metin2ar/public_html/members/itemshop/test_/Loginok.php on line 29

Le e dado ya muchas vueltas para solucionarlo y no e podido por eso recurro a profesionales

Os dejo el script para que le echeis un vistazo:

Código PHP:
<?php

session_start
();



$lifeTime 120;

setcookie(session_name(), session_id(), time() + $lifeTime"/"); 

$userid=$_POST["userid"];

$password=$_POST["password"];

if (
strlen($userid) < || strlen($password)< 1){

    echo 
"<table align='center' cellpadding='40' cellspacing='40'><tr><td><a href=\"javascript:history.back();\"><img src='images/fanhui.jpg' /></a></table></tr></td>";

}else{

    require_once(
"../conn.php");

    
mysql_select_db("account");

    
$exec="select id,Login,cash from account where Login='$userid' and Password=password('$password')";

    
$result=mysql_query($exec);

    
$rs=mysql_fetch_object($result);

    if(
$rs){

        
$_SESSION["ID"] = $rs->id;

        
$_SESSION["UserID"] = $rs->Login;

        
$_SESSION["cash"] = $rs->cash;

        
header("location:default.php");

    }else{

        echo 
"<table align='center' cellpadding='40' cellspacing='40'><tr><td><a href=\"javascript:history.back();\"><img src='images/fanhui1.jpg' /></a></table></tr></td>";exit;

    }

}



?>
Espero vuestra ayuda , un saludo
  #2 (permalink)  
Antiguo 17/10/2011, 07:20
 
Fecha de Ingreso: febrero-2004
Mensajes: 1.987
Antigüedad: 20 años, 2 meses
Puntos: 22
Respuesta: Warning: mysql_fetch_object(): supplied argument is not a valid MySQL resu

Hola.

Quien te ha dicho que
Código PHP:
mysql_query($exec); 
contiene datos?

Mas: que el QUERY se ha ejecutado???

El error esta aki:
Código PHP:
$result=mysql_query($exec);

    
$rs=mysql_fetch_object($result); 
Puedes ver que
Código PHP:
$result 
quizas SI, quizas NO tenga valores.

De contenerlos...

¿son los deseados?

Evalua PRIMERO el ESTADO de $result
  #3 (permalink)  
Antiguo 17/10/2011, 08:03
 
Fecha de Ingreso: octubre-2011
Ubicación: Benidorm
Mensajes: 5
Antigüedad: 12 años, 6 meses
Puntos: 0
Respuesta: Warning: mysql_fetch_object(): supplied argument is not a valid MySQL resu

ps no me aclaro :S, puedo agregarte al msn y me ayudas porfavor
  #4 (permalink)  
Antiguo 17/10/2011, 09:20
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Warning: mysql_fetch_object(): supplied argument is not a valid MySQL resu

Intenta cambiar esta linea para que descubras el error exacto:
Código PHP:
 $result=mysql_query($exec) or die('Mi error es: '.mysql_error()); 
PDTA: eso de pedir/dar el MSN va contra las reglas del foro, por favor lee las normas antes de continuar.
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #5 (permalink)  
Antiguo 17/10/2011, 13:13
 
Fecha de Ingreso: octubre-2011
Ubicación: Benidorm
Mensajes: 5
Antigüedad: 12 años, 6 meses
Puntos: 0
error mysql_fetch_array(): supplied argument is not a valid MySQL result resource in

Hola gente, tengo el siguiente error en un archivo y no puedo arreglarlo, aver si me ayudan ustedes

Error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/metin2ar/public_html/members/itemshop/test_/default.php on line 355

Este es el script:

Código PHP:
<?php

session_start
();

require_once(
"../conn.php");

            
mysql_select_db("player");

?>

<?php

function DeCode($string,$operation,$key='')

    {

        
$key=md5($key);

        
$key_length=strlen($key);

        
$string=$operation=='D'?base64_decode($string):substr(md5($string.$key),0,8).$string;

        
$string_length=strlen($string);

        
$rndkey=$box=array();

        
$result='';

        for(
$i=0;$i<=255;$i++)

        {

            
$rndkey[$i]=ord($key[$i%$key_length]);

            
$box[$i]=$i;

        }

        for(
$j=$i=0;$i<256;$i++)

        {

            
$j=($j+$box[$i]+$rndkey[$i])%256;

            
$tmp=$box[$i];

            
$box[$i]=$box[$j];

            
$box[$j]=$tmp;

        }

        for(
$a=$j=$i=0;$i<$string_length;$i++)

        {

            
$a=($a+1)%256;

            
$j=($j+$box[$a])%256;

            
$tmp=$box[$a];

            
$box[$a]=$box[$j];

            
$box[$j]=$tmp;

            
$result.=chr(ord($string[$i])^($box[($box[$a]+$box[$j])%256]));

        }

        if(
$operation=='D')

        {

            if(
substr($result,0,8)==substr(md5(substr($result,8).$key),0,8))

            {

                return 
substr($result,8);

            }

            else

            {

                return
'';

            }

        }

        else

        {

            return 
str_replace('=','',base64_encode($result));

        }

    }



?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD><TITLE></TITLE>

<META http-equiv=Content-Type content="text/html; charset=big5">

<STYLE type=text/css>

td img {display: block;}body,td,th {

    font-family: Tahoma, §ºÊ^;

    font-size: 12px;

    color: #333333;

}

body {

    margin-left: 0px;

    margin-top: 0px;

    margin-right: 0px;

    margin-bottom: 0px;

    background-image: url(images/index_r6_c10.jpg);

    background-repeat: repeat;

}

a:link {

    color: #333333;

    text-decoration: none;

}

a:visited {

    text-decoration: none;

    color: #333333;

}

a:hover {

    text-decoration: underline;

    color: #FF0000;

}

a:active {

    text-decoration: none;

    color: #FF0000;

}

.STYLE1 {

    color: #FF0000;

    font-weight: bold;

}

</STYLE>



<META content="MSHTML 6.00.6000.16788" name=GENERATOR></HEAD>

<BODY>

<TABLE width="586" border=0 align="center" cellPadding=0 cellSpacing=0>

  <TBODY>

  <TR>

    <TD height=31><img src="img/headeris2.jpg" width="586" height="125"></TD>

</TR></TBODY></TABLE>

<TABLE width="586" height=250 border=0 align="center" cellPadding=0 cellSpacing=0>

  <TBODY>

  <TR>

    <TD vAlign=top align=center>

      <TABLE cellSpacing=0 cellPadding=0 width="96%" align=center border=0>

        <TBODY>

        <TR>





          <TD height=30>

              <HR><?php

        $exec_class
="select classid,classname from shop_class order by classid  desc";

            
$result_class=mysql_query($exec_class);

            while(
$rs_class=mysql_fetch_array($result_class)){

            echo 
"<a href=\"?classid=".$rs_class["classid"]."&page=".$_GET['page']."\">".DeCode($rs_class["classname"],'D','daichao')."</a> </br>";

 }

 
?><HR>

<?php

                                          
if(isset($_SESSION["UserID"]) && strlen($_SESSION["UserID"])>1){

                                          
shop();

                                          }else{
login();}

                                          function 
login(){

                                          
?>      

<table width="560" border="0" cellspacing="0" cellpadding="0">

  <form id="Login" name="Login" method="post" action="Loginok.php">

  <tr>

    <td height="40" colspan="2" align="center"><p class="STYLE1">Dieses Itemshopscript funktioniert nur mit Mozilla Firefox <a href="http://www.mozilla.com" target="_blank">http://www.mozilla.com</a></br> Powered by <a href="http://www.elitepvpers.com/forum" target="_blank">Elitepvpers</a> </p></td>

  </tr>

  <tr>

    <td height="24" colspan="2" align="center"><p><strong>Itemshop-Login</strong></p></td>

    </tr>

  <tr>

    <td width="242" height="24" align="right">BenutzerID:</td>

    <td width="318" height="24"><input name="userid" type="text"  id="userid2" size="20"  onkeyup="value=value.replace(/[^\w\.\/]/ig,'')" style="width:140px;" /></td>

  </tr>

  <tr>

    <td height="24" align="right">Passwort:</td>

    <td height="24"><input name="password" type="password" autocomplete="off"  id="password2" size="20" onKeyUp="value=value.replace(/[^\w\.\/]/ig,'')"  style="width:140px;" /></td>

  </tr>

  <tr>

    <td height="24" colspan="2" align="center"><input type="submit" name="Submit" value="Bestaetigen" class="button">¡@

      <input type="reset" name="Submit" value="Zuruecksetzen" class="button">

      <input type="hidden" name="shop_login" value="login" /></td>

    </tr></form>

</table>

 <?php

                                        
}

                                        function 
shop(){

                                        echo 
"<div align='center'>Willkommen ".$_SESSION["UserID"]."</br>Du hast noch <span style='color:black;'>&nbsp;&nbsp;".$_SESSION["cash"]."&nbsp;&nbsp;</span>Coins.&nbsp;&nbsp;</br><a href=\"Loginout.php\">Ausloggen</a>&nbsp;&nbsp;<a href='../ChangePSD.php'>Passwort aendern</a>&nbsp;&nbsp;<a href='enter/entermoney.php'>Konto aufladen</a></br></br><div>";

                                        
?>



 <?php

                                        $classid
=$_GET["classid"];

                                        if(
$classid<|| $classid=="" || is_numeric($classid)==false){$classid=0;}

                                        if(
$classid>0){

                                        
$exec="select count(*) from item_proto where vnum in (select vnum from item_proto_shop where classid=$classid)";

                                        }else{

                                        
$exec="select count(*) from item_proto where vnum in (select vnum from item_proto_shop)";

                                        }

        
mysql_query("set names gb2312 ");

        
mysql_query("set CHARACTER  gb2312 ");

            
$result=mysql_query($exec);

            
$rs=mysql_fetch_array($result);

            
$num=$rs[0];

            if(empty(
$_GET['page'])){

                
$page=0;

            }else{

                
$page=$_GET['page'];

                if(
$page<0)$page=0;

                if(
$page>=ceil($num/16))$page=ceil($num/16)-1;

            }

            if(
$classid>0){

            
$exec="select item_proto.vnum,item_proto.gb2312name,item_proto_shop.img,item_proto_shop.prices,item_proto_shop.content from item_proto,item_proto_shop where item_proto.vnum =item_proto_shop.vnum and  item_proto_shop.classid=$classid order by item_proto.vnum  desc limit ".($page*16).",16";

            }else{

            
$exec="select item_proto.vnum,item_proto.gb2312name,item_proto_shop.img,item_proto_shop.prices,item_proto_shop.content from item_proto,item_proto_shop where item_proto.vnum =item_proto_shop.vnum  order by item_proto.vnum  desc limit ".($page*16).",16";

            }



              

            
$result=mysql_query($exec);

            while(
$rs=mysql_fetch_array($result)){

            
$i+=1;

          
?>

          

          

<table width="100%"  border="0" cellpadding="0" cellspacing="0" id="itemshop_table">

  <tr>

    <td width="85" rowspan="3" align="center">

    

    <a href="http://www.forosdelweb.com/f18/admin/<?=urldecode($rs["img"])?>" target="_blank" title="ÂIÀ»¬d¬Ý¹Ï¤ù"><div style="margin:0px 10px 0px 10px;"><img src="http://www.forosdelweb.com/f18/admin/<?=urldecode($rs["img"])?>" border="0" height="70" width="70" /></div></a>

    

    </td>

    <td class="header" width="30%"><div align="left"><?=$rs["gb2312name"]?></div></td>

    <td class="header" width="65%"><div align="left">Preis: <?=$rs["prices"]?> Coins</div></td>

  </tr>

  <tr>

    <td height="46" colspan="2"><?=DeCode($rs["content"],'D','daichao');?></td>

    </tr>

  <tr>

    <td colspan="2" align="right"><a href="player.php?id=<?=$rs["vnum"]?>" title="ɲ®æ¡G<?=$rs["prices"]?>¡AÂIÀ»ÁʶR" >Kaufen</a></td>

    </tr>

</table>













                                        <?

                                        
}

                                        
?>

</div>

</div>                                

<div style="clear:both;" align="center">&nbsp;&nbsp;

<a href="?classid=<?=$_GET["classid"]?>&page=0">Erste Seite</a>&nbsp;&nbsp;

<a href="?classid=<?=$_GET["classid"]?>&page=<?=($page-1)?>">Vorherige Seite</a>&nbsp;&nbsp;

<a href="?classid=<?=$_GET["classid"]?>&page=<?=($page+1)?>">Naechste Seite</a>&nbsp;&nbsp;

<a href="?classid=<?=$_GET["classid"]?>&page=<?=ceil($num/16)-1?>">Letzte Seite</a>&nbsp;&nbsp;

</div>

<?php

}

?>











</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>

</BODY></HTML>
Un saludo
  #6 (permalink)  
Antiguo 17/10/2011, 13:47
Avatar de Rodrhigo  
Fecha de Ingreso: septiembre-2011
Ubicación: Temuco-Valdivia-Osorno
Mensajes: 254
Antigüedad: 12 años, 7 meses
Puntos: 48
Respuesta: error mysql_fetch_array(): supplied argument is not a valid MySQL result r

Ese error es porque tienes un error en tu consulta (mysql_query).

Revisa tu $exec de la linea 341 o 345.
  #7 (permalink)  
Antiguo 17/10/2011, 15:10
 
Fecha de Ingreso: junio-2011
Ubicación: Barcelona
Mensajes: 212
Antigüedad: 12 años, 11 meses
Puntos: 17
Respuesta: error mysql_fetch_array(): supplied argument is not a valid MySQL result r

La verdad yo organizaria mejor las consultas para que se vea mejor y lo entiendas mejor:

Cita:
$exec="SELECT
item_proto.vnum,
item_proto.gb2312name,
item_proto_shop.img,
item_proto_shop.prices,
item_proto_shop.content
FROM
item_proto,
item_proto_shop
WHERE
item_proto.vnum =item_proto_shop.vnum
ORDER BY
item_proto.vnum
DESC LIMIT ".($page*16).",16";
Por ejemplo.. no se si en las consultas SQL produce error si hay mas de 1 espacio, si es a si fijate apartir de los WHERE.

Un saludo
__________________
Twitter: @ed33x

Etiquetas: mysql_fetch_array, mysql_fetch_object
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:40.