简体   繁体   English

关于mysql_num_rows()的DRUPAL错误

[英]error in DRUPAL with respect to mysql_num_rows()

I am new to drupal and trying to execute some database related basic query. 我是drupal的新手,正在尝试执行一些与数据库相关的基本查询。 I need to count the number of affected rows in a table. 我需要计算表中受影响的行数。 I tried with following codes : 我尝试使用以下代码:

  $query1 = "SELECT user_type,user_staus FROM `login_info` WHERE username='{$username}'   
  AND password='{$password}' LIMIT 1";
  $fetched = db_query($query1);
  //check if record exists otherwise you would receive another notice that can 
  //break redirect functionality
  if (mysql_num_rows($fetched))
  {
     $record = db_fetch_assoc($fetched);
    // make sure that value is integer
    if ((int)$record["user_staus"])
   {
       exit("Please login after some time");
   }
   else
  {  ------- codes ----  }

But I am getting following errors : 但是我收到以下错误:

Warning: mysql_num_rows() expects parameter 1 to be resource, object given in eval() (line 53 of C:\\xampp\\htdocs\\drupal\\modules\\php\\php.module(74) : eval()'d code). 警告:mysql_num_rows()期望参数1为资源,对象以eval()给出(C:\\ xampp \\ htdocs \\ drupal \\ modules \\ php \\ php.module(74)的第53行:eval()的代码)。

And then when I am trying with db_num_rows , I am getting following errors : 然后,当我尝试使用db_num_rows时,出现以下错误:

Fatal error: Call to undefined function db_num_rows() in C:\\xampp\\htdocs\\drupal\\modules\\php\\php.module(74) : eval()'d code on line 53 致命错误:在C:\\ xampp \\ htdocs \\ drupal \\ modules \\ php \\ php.module(74)中调用未定义的函数db_num_rows():第53行的eval()代码

I am very new to DRUPAL, Can anyone please help me out. 我是DRUPAL的新手,任何人都可以帮助我。 Many many thanks in advance . 在此先谢谢了。

As covered in the chat room, you're not connecting to the database using this external code. 如聊天室所述,您没有使用此外部代码连接到数据库。

You need to go into your themes folder and start in there. 您需要进入主题文件夹并从那里开始。 This way you will be connected to the database and the Drupal core etc. 这样,您将连接到数据库和Drupal核心等。

If I were you I would start at the proper beginning with some tutorials. 如果我是您,那么我将从一些教程开始。 The Drupal ones on the official site are very good and are how I got started. 官方站点上的Drupal很好,这也是我入门的方式。

http://drupal.org/documentation/customization/tutorials http://drupal.org/documentation/customization/tutorials

Good luck. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM