Home > Backend Development > PHP Tutorial > 请问一个PHP操作MYSQL的有关问题

请问一个PHP操作MYSQL的有关问题

WBOY
Release: 2016-06-13 13:16:42
Original
841 people have browsed it

请教一个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 '
Copy after login
  • '.$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;
  • Related labels:
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template