这是我不断收到错误的代码。相同的包含文件适用于其他页面,我只在此页面上遇到问题。这是错误
警告:mysql_select_db():提供的参数不是第 18 行/var/www/html/spywgc/adm/ctshell/getproduct/getproduct.php 中的有效 MySQL-Link 资源
这是实际的代码:
<?php require_once('../../../Connections/spyware_adm.php'); ?>
<?php require_once('../../../includes/lib_gen.php'); ?>
<?php
//function for returing status of website
function Visit($url)
{
echo $url;
mysql_select_db($database_spyware, $spyware) || die(mysql_error());
$select_url= "select product_id from sp_url where url like '%{$url}%'";
echo $select_url;
$run_url= mysql_query($select_url, $spyware);
$result_descr = mysql_fetch_assoc($run_url);
echo $result_descr;
return $result_descr;
}
?>
最佳答案
mysql_select_db()
期望第二个参数是资源标识符 = 您的连接。问题是,您将其作为函数运行,但在该函数内未建立连接。你必须以这样的方式开始你的函数:
function Visit($url)
{
$spyware = mysql_connect(); // set this to connect properly
echo $url;
mysql_select_db($database_spyware, $spyware) || die(mysql_error());
// the rest of your function goes on ...
关于php - 警告 : mysql_select_db(): supplied argument is not a valid MySQL-Link resource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5681336/