English 中文(简体)
我sql_fetch_row(以英语发言):所提供的论据不是MySQL在[复制]产生资源的有效理由。
原标题:mysql_fetch_row(): supplied argument is not a valid MySQL result resource in [duplicate]
  • 时间:2010-08-14 17:25:38
  •  标签:
  • php
  • mysql

我正在发现这一错误(Msql_fetch_row(以英语发言):提供的论点并不是一个有效的MySQL结果资源)。 为什么?

<?php

set_time_limit(0);
//MySQL globals
$mysql_server = "***";//change this server for your Drupal installations
$mysql_user = "***";//Ideally, should be root
$mysql_pass = "***";//Corresponding password
$conn = mysql_connect($mysql_server,$mysql_user,$mysql_pass);//MySQL connection string


$query = "select * from dr_wiwe_old_node WHERE type =  story ";
$noders = mysql_query($query);
var_dump($noders);
while ($row = mysql_fetch_row($noders)) {
$nid = $row[0];
$vid = $row[1];
$type = $row[2];
$title = mysql_real_escape_string($row[3]);
$uid = $row[4];
$status = $row [5];
$created = $row[6];
$changed = $row[7];
$comment = $row[8];
$promote = $row[9];
$moderate = $row[10];
$sticky = $row[11];
//Insertion into node
$query="insert into dr_wiwe_node values( " . $nid . " , " 
    . $vid . " , " . $type . " ,  , " . $title . " , " . $uid . " , " 
    . $status . " , " . $created . " , " . $changed . " , " . $comment
    . " , " . $promote . " , " . $moderate . " , " . $sticky . " , 0 , 0 )";
if (!mysql_query($query)) {
print $query;
}
?>

错误在哪里,或我能改变什么?

问题回答

当你进行询问时,检查该职能的回报价值。 如果它有<代码>false,那么你的询问有误。

$noders = mysql_query($query);
if ($noders === false) {
  error_log(mysql_error());
}

由于各种原因,包括:

  • You are not connected to the MySQL server.
  • You have not selected the right database with mysql_select_db(), so MySQL doesn t know how to find the tables you name in your query. This is the case in your code example.
  • You have an error in your SQL syntax.
  • You don t have privilege to access the tables named in your query.
  • etc.

<代码> 类型为保留词。 请在您的问询中附上它作为外地名称:

$query = "select * from dr_wiwe_old_node WHERE `type` =  story ";

原因之一

mysql_fetch_row(>):所提供的论据不是MySQL结果资源

原因是:

在界定“db”或为查阅数据库而设置的许可时所选择的错误的东道名称不正确。

例如,如果你批准<条码>行政@当地东道方,以便查阅文件副本。

你们对东道国的名称明确提出问题。

解决赠款许可问题,例如<代码>用户名称@%。

问题是,你正在找回问道。 我不认为你可以做这件事,不作克隆。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签