请教一个PHP操作MYSQL的问题
PHP code<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->function writeLeft(){ $retArray = array(); [color=#FF0000]$sql = "select id,name,strr from jh_lanmu";[/color] $result = mysql_query($sql,$conn); while($myrow = mysql_fetch_array($result,MYSQL_BOTH)) { $retArray[] = $myrow; } mysql_free_result($result); foreach($retArray as $tmp) { echo '
'.$tmp[0].''.chr(13); }}
红色的SQL语句在Navicat中查询是没有报错的,能够查出结果,但是PHP页面上始终报错:
mysql_query(): supplied argument is not a valid MySQL-Link resource in F:\PHPWebSite\jinghong\config.php on line 11
其他的SQL操作都能正常运行。
数据库代码如下:
DROP TABLE IF EXISTS `jh_lanmu`;
CREATE TABLE `jh_lanmu` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) DEFAULT NULL,
`strr` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=gbk;
-- ----------------------------
-- Records of jh_lanmu
-- ----------------------------
INSERT INTO `jh_lanmu` VALUES ('1', '产品配料', 'cppl.php');
INSERT INTO `jh_lanmu` VALUES ('2', '产品系列', 'cpxl.php');
------解决方案--------------------
function writeLeft()
{
global $conn;