Possible Duplicate:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select在php中处理数组?
我似乎遇到了与我的PHP的问题,收到此错误:
Warning: mysql_real_escape_string() expects parameter 1 to be string, array given in /home/nightl7/public_html/demos/autocompletejquery/submit.php on line 27
Warning: mysql_query() [function.mysql-query]: Access denied for user 'nightl7'@'localhost' (using password: NO) in /home/nightl7/public_html/demos/autocompletejquery/submit.php on line 36
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/nightl7/public_html/demos/autocompletejquery/submit.php on line 36 Access denied for user 'nightl7'@'localhost' (using password: NO) SELECT * FROM markers WHERE select3 = ''
这是我的代码有:
<?php
require("db_access.php");
function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
return $xmlStr;
}
$name=$_POST['name'];
$address=$_POST['address'];
$type=$_POST['type'];
$request=$_POST['$_REQUEST'];
// Select all the rows in the markers table
$inputs = array('select3');
$where = array();
foreach($inputs as $input)
{
if(!empty($_POST[$input])) {
$where[] = "{$input} = '" . mysql_real_escape_string($_POST[$input]) . "'";
}
}
if ($where) {
$query = 'SELECT * FROM markers WHERE ' . implode(' AND ', $where);
} else {
user_error("No rows returned by:<br />\n$query");
}
$result = mysql_query($query);
if($result == false) {
die(mysql_error() . "<br />\n$query");
}
if(mysql_num_rows($result) == 0) {
user_error("No rows returned by:<br />\n$query");
}
// Fetch the result
$rowset = array();
while ($row = mysql_fetch_array($result)) {
$rowset[] = $row;
}
// Look at your rowset structure:
print_r($rowset);
header("Content-type: text/xml");
// Start XML file, echo parent node
echo '<markers>';
// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
echo '<marker ';
echo 'name="' . parseToXML($row['name']) . '" ';
echo 'address="' . parseToXML($row['address']) . '" ';
echo '/>';
}
// End XML file
echo '</markers>';
?>
而且我不知道为什么我得到一个密码错误,因为这是我的db_access.php看起来像:
<?
$username="nightl7_mapus";
$password="MYPASSWORD - is is correct :)";
$database="nightl7_map";
?>
请修复您的标题:技术列表不是您问题的描述。这个问题是......呃,究竟是什么? –
你好,我的问题是我如何使上述代码工作。我读了可能会有不同类型的数组,我仍然无法确定我做的是否正确。 – user944589
我的感觉是,这太“太”了。你有关于编程语言的具体问题吗? –