Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql_num_行从php函数返回0值_Php_Mysql - Fatal编程技术网

mysql_num_行从php函数返回0值

mysql_num_行从php函数返回0值,php,mysql,Php,Mysql,我的script.php中有这个函数 $email=$_会话['cspa']['email'] function getit() { $get_pendingsupport=mysql_query("select cus.email, datetime, s.service_type, subject, support_id, status, u.urgency from tbl_client_suppo

我的script.php中有这个函数 $email=$_会话['cspa']['email']

    function getit()
    {
      $get_pendingsupport=mysql_query("select
    cus.email,
    datetime,
    s.service_type,
    subject,
    support_id,
    status,
    u.urgency
    from tbl_client_support c
    inner join tbl_client_service s on c.service_id=s.service_id
    inner join customer_reg cus on c.customer_reg_id=cus.id
    inner join tbl_client_urgency u on c.urgency_id=u.urgency_id

    where status='open'
    and cus.email='$email';

    ") or  die(mysql_error());

     return mysql_num_rows($get_pendingsupport) ;
    }
 that my function and am calling it like this in home.php
但它返回0作为值 但是当我把它带到home.php时,它就没事了
请找出可能的错误

它返回零,因为返回了零行。为什么?因为您从未将
$email
传递给您的函数,因此它不可用于您的查询。由于它在
WHERE
子句中使用,您的查询不会返回您认为会返回的行,因为没有任何行的状态为“打开”且客户电子邮件字段为空

可以通过将该变量传递给函数来解决此问题:

function getit($email)
{
当你称之为:

$num_rows = getit($email);

您没有将$email传递给查询。试试这个:

function getit($email)
    {
      $get_pendingsupport=mysql_query("select
    cus.email,
    datetime,
    s.service_type,
    subject,
    support_id,
    status,
    u.urgency
    from tbl_client_support c
    inner join tbl_client_service s on c.service_id=s.service_id
    inner join customer_reg cus on c.customer_reg_id=cus.id
    inner join tbl_client_urgency u on c.urgency_id=u.urgency_id

    where status='open'
    and cus.email='$email';

    ") or  die(mysql_error());

     return mysql_num_rows($get_pendingsupport) ;
    }

坦克这么多,它的工作有点享受这个论坛u摇滚