<?php
$conn=mysql_connect("localhost","admin","admin");
mysql_select_db("lucy1015",$conn);
mysql_query("SET NAMES gbk"); 
error_reporting(0);
 function shili ( $x ){                
$sql=mysql_query("select * from phpcms_yuyan where english='$x'",$conn);
$info=mysql_fetch_array($sql);
echo $info[chinese];
echo $info[english]; }shili ( jobs ) ;                     ?>
 
数据库结构如下 
id english chinese 1  jobs     工作
2  girls    女孩
3  boys     男孩
---------------------

解决方案 »

  1.   

    function shili ( $x ){   
    $sql=mysql_query("select * from phpcms_yuyan where english='$x'");
    $info=mysql_fetch_array($sql);
    echo $info[chinese];
    echo $info[english]; }shili ( 'jobs' ) ;
      

  2.   

    为什么不行?
    你把 error_reporting(0); 去掉!!!
      

  3.   

    可以了  你为什么把$conn); 去了 就好了么?
      

  4.   

    error_reporting(0)错误全屏蔽了,根本不知道错在哪里!
      

  5.   

    因为函数内部的$conn变量值是空,看不到函数外部的$conn
      

  6.   

    去看看PHP手册上对于变量作用范围的说明。
      

  7.   


    Notice: Use of undefined constant chinese - assumed 'chinese' in D:\PC_webserver\phproot\yuyan2.php on line 14
    招聘求职
    Notice: Use of undefined constant english - assumed 'english' in D:\PC_webserver\phproot\yuyan2.php on line 15
    jobs
    Notice: Use of undefined constant japanese - assumed 'japanese' in D:\PC_webserver\phproot\yuyan2.php on line 16
    募集 
      

  8.   

    这个是Notice,不是错误。
    你把$info[chinese]改成$info['chinese']就可以了。
      

  9.   

    调试程序时
    error_reporting(E_ALL & ~E_NOTICE);正式运行时
    error_reporting(0);