Function popList()
takes two parameters - name of the column and name of the table.
Basically the popList(
) function connects to a mysql
server and then a database and builds an sql query to retrieve data based on what you passed to the function to be used to populate a listbox on the page.
只有一个名单箱与这一功能相配,但如果在网页上有第二个名单箱,要求该功能再次使用不同的参数(颜色名称和表格名称),则该名单似乎空洞,以下文字在第一人口名单箱的源头上打印:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user ODBC @ localhost (using password: NO) in C:xampphtdocs est on line 7
Not connected : Access denied for user ODBC @ localhost (using password: NO)
我在两条电话中都使用同样的联系全权证书,这些电话是缺席的当地东道方,是根本的,没有密码(纯粹为了测试目的)。
Why is it behaving like this?
www.un.org/Depts/DGACM/index_spanish.htm
<?php
function popList($col, $tbl) {
require_once "credentials.php";
// Opens a connection to a MySQL server
$connection=mysql_connect($host, $username, $password);
if (!$connection) {
die( Not connected : . mysql_error());
}
// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ( Can t use db : . mysql_error());
}
$sql = "SELECT $field FROM $table";
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
echo <option value=" . $row["$field"] . "> . $row["$field"] . </option> ;
}
mysql_close($connection);
}
?>
<require_once
和include_once
。 产生这一问题,但使用<代码>include或require<
这个问题实际上已经解决。
credentials.php
如:
function popList(...) {
require "credentials.php"; // changed to require from require_once. same with include
...
}