May I ask a question about MYSQL operations in PHP?

Source: Internet
Author: User
PHPcodefunctionwriteLeft () {$ retArrayarray (); [color # FF0000] $ SQL & quot; selectid, name, strrfromjh_lanmu & quot ;; [color] $ resultmysql_query ($ s ask a PHP question about MYSQL operations
PHP code
  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); }}

  • There is no error in the query of the red SQL statement in Navicat. The result can be found, but the PHP page always reports an error:

    Mysql_query (): supplied argument is not a valid MySQL-Link resource in F: \ PHPWebSite \ jinghong \ config. php on line 11

    Other SQL operations can run normally.

    The database code is as follows:
    Drop table if exists 'Your _ lanmu ';
    Create table 'Your _ 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 'values _ lanmu 'VALUES ('1', 'product batching', 'cppl. php ');
    Insert into 'values _ lanmu 'VALUES ('2', 'product series', 'cpxl. php ');



    ------ Solution --------------------
    Function writeLeft ()
    {
    Global $ conn;

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.