echo mysql_query($s);无任何值输出解决方法

WBOY
Release: 2016-06-13 10:17:24
Original
3260 people have browsed it

echo mysql_query($s);无任何值输出
  $query="select * from user";
  $results=mysql_query($query);
  while(@$r=mysql_fetch_array($results)){ 
  echo htmtocode($r['userid']);
  echo " "?>
  delete
 

    }
  ?>
    if(@$_GET['action']=='delete'){
  $s="select from user where userid=$_GET[userid]";
  echo mysql_query($s);
  die();
  if(mysql_query($s)){
 
  exit(')');
  }
  }
  ?>

------解决方案--------------------

PHP code
<?php $query="select * from user";  $results=mysql_query($query);  if( ! $results)      die("SQL: {$query} error: " . mysql_error() );  while( $r=mysql_fetch_array($results) )  {        echo htmtocode($r['userid']);      echo " ";  ?>      <a href="?action=delete&userid=<php%20echo%20%24r%5B'userid'%5D;%20?>">delete</a>      <br>  <?php }  ?>  <?php if($_GET['action']=='delete'){     if( ! isset($_GET['userid']) )         exit('userid 为空,放弃操作');     $userid = trim( $_GET['userid'] );     // 我不明白删除操作用select做什么?     $s="select * from `user` where userid = '{$userid}'";     // echo 只对字符串和数字有效,调试的话用var_dump()     var_dump( $result = mysql_query($s) );      if( $result ){          exit('<script language="javascript">                alert("删除成功!");                self.location = "admin.php";                ');     }else         echo "mysql error:". mysql_error();  }?><br><font color="#e78608">------解决方案--------------------</font><br>if(@$_GET['action']=='delete'){<br>$s="select from user where userid=$_GET[userid]";<br>echo mysql_query($s);<br>die();<br>你写的这三句<br>改为这样<br>if(@$_GET['action']=='delete'){//确认这个条件满足,进入了循环<br>$s="select from user where userid=$_GET[userid]";//<br>echo $s."<br>";//输出语句内容,也查一下运行到此步没有,可以单独到数据库里查一下看有值没<br>echo mysql_query($s);//query返回的只是成功不成功并不是查得的内容<br>die();//语句到此句就中止了<br>要注意你的userid是不是int型,若是text或是char啥的两边需加引号''<br>到此你定会知道为啥没有输出内容了<br><font color="#e78608">------解决方案--------------------</font><br>echo 只能输出字符串和数字,<br>mysql_query();返回值是资源类型,当然输不出来<br>用var_dump就可以输出了 ,要看结果要使用函数处理返回的资源<br><font color="#e78608">------解决方案--------------------</font><br>返回false表示你的SQL语句有问题,没成功执行<br>给后面加上一句 echo mysql_error();<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template