Novice asking for advice PHP+JS
袅袅
袅袅 2019-07-03 14:47:56
0
5
1277

The program is PHP mysql. Everything is normal when running on Alibaba Cloud. After entering the customer code, other customer information is automatically retrieved from the database. The php version is 5.

QQ拼音截图未命名.png

After moving to the new server, the PHP version is 7, and nothing happens after entering the customer code.

QQ拼音截图未命名1.png

The log only contains the following errors.

PHP Warning: implode(): Invalid arguments passed in /var/www/html/action.php on line 45

But I don’t think this is the reason

htmlSource code

<form id="form1" name="form1" method="post" action="action.php?act=add" onsubmit="return check( )">

<div class="hang_item"><span>Quotation No:</span><input name="danhao" type="text" id="danhao" size="60" readonly="readonly" value="<?=$ddh?>"/></div>

<div class="hang_tit">Customer Information< /div>

<div class="hang_item">

<table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td>Customer No.:<span class="khxx"><input name="kehu" type="text" id="kehu" size="10" placeholder="" onblur="khxx(this)"/></span></td>

    <td>Category:<span class="Category"></span></td>

    <td>Grade:<span class="Grade"></span></td>

  </tr>

  <tr>

    <td>Customer Name: <span class="khname"></span></td>

    <td>Address: <span class="address"></span></td>

    <td> </td>

  </tr>

  <tr>

    <td>Contact Person: <span class="Person"></span></td>

    <td>Email:: <span class="email"></span></td>

    <td><span class=""></span></td>

  </tr>

</table>

对应的JS代码

function khxx(obj){

khid=$(obj).attr("value");

//console.log(khid);

$.post("action.php?act=getKehu", { "khid": khid },

   function(data){

   //console.log(khid);

//$(obj).parents('tr').find('.pname').html(data.data[0].pname);

$(".Category").html(data.data[0].Category);

$(".Grade").html(data.data[0].Grade);

$(".khname").html(data.data[0].khname);

$(".address").html(data.data[0].address);

$("#d_address").val(data.data[0].address);

$(".Person").html(data.data[0].Person);

$(".email").html(data.data[0].email);

   }, "json");

}

action.php

if($act=="getKehu"){

$sql_kh="select * from customer where CustomerNo='$khid'";

$result_kh=mysqli_query($GLOBALS['conn'], $sql_kh);

        $info_kh=mysqli_fetch_array($result_kh);

$Category=$info_kh['Category'];

$Grade=$info_kh['Grade'];

$khname=$info_kh[2];

$address=$info_kh['Address'];

$Person=$info_kh['ContactPerson'];

$email=$info_kh['Email'];

echo '{"status" : 0 ,"msg" : "SUCCESS","data" :[{"Category":"'.$Category.'" ,"Grade" : "'.$Grade. '","khname" : "'.$khname.'","address" : "'.$address.'","Person" : "'.$Person.'","email" : "'.$ email.'"},{"id" : 2,"name" : "xiaoming"}]}';

}

I hope you can help me, thank you.

If the code problem is serious, you can get paid.

袅袅
袅袅

reply all(2)
樂成

Warning: implode(): The parameters passed are invalid

Ntework reviews the parameters passed and prints $khid; and $info_kh, has the data been found? Make sure that the entered customer ID exists in the table.

  • reply You can see the ID by calling up the console
    袅袅 author 2019-07-05 17:02:44
  • reply What about the other questions I mentioned? 1. Ntework checks the passed parameters; (you can see the id when you call up the console) 2. Print $khid on the PHP side; (?) 3. Have you found any data in $info_kh? (?) 4. Make sure the entered customer ID exists in the table; (?)
    kanglecheng author 2019-07-08 15:16:36
殘留の回憶

*** Try to synchronize the environment with the test environment, one is 5 and the other is 7, there must be a difference

  • reply I can't change the environment now, I have to use 7.
    袅袅 author 2019-07-04 10:26:21
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!