2016-07-25 3 views
0

Я пытаюсь удалить строку из таблицы «Клиенты» с php и угловой. это ошибка, что я получаюНевозможно прочитать свойство «сращивание» неопределенной ошибки

«Не удается прочитать свойство„сращивание“неопределенных».

может кто-нибудь знать, почему?

это мой код:

контроллер:

$scope.delete = function(deletingId, index) { 
     var params = $.param({"customer_id":deletingId}); 
     $http({ 
      headers: {'Content-Type': 'application/x-www-form-urlencoded'}, 
      url: 'http://localhost:8081/hamatkin/api/delete-customer.php/', 
      method: "GET", 
      data: params 
     }).success(function(data){ 
     console.log(data); 
     $scope.customerDetails = data; 
     $scope.customerDetails.splice(index, 1); 
     }); 
     } 

Customer.php

<?php 
class Customer { 

    private $table_name = "customers"; 

    public $customer_id; 
    public $kind_Of_Customer; 
    public $full_name; 
    public $id; 
    public $city; 
    public $address; 
    public $phone; 
    public $phone_2; 
    public $email; 
    public $fax; 
    public $referrer; 
    public $comments; 


} 

?> 

удалить-customer.php

<?php header('Content-Type: text/html; charset=utf-8'); 
$connect=mysqli_connect("localhost", "root", "", "hamatkin"); 

    include_once 'Customer.php'; 

// Check connection 
if (mysqli_connect_errno()) { 
    echo "Failed to connect to MySQL: " . mysqli_connect_error(); 
} 
$customer = new Customer(); 


if(isset($_GET['customer_id'])){ 
    $customer_id = $_GET['customer_id']; 
    $del = "DELETE FROM posts WHERE customer_id='".$customer_id."'"; 
    mysql_query($connect, $del); 
} 


$newURL = "/hamatkin/#/customerCards"; 
header('Location: '.$newURL); 
?> 

HTML

<tr ng-repeat="x in customers | filter:search_query | orderBy: order_query:reverse_query"> 
      <td>{{ x.customer_id}}</td> 
      <td>{{ x.kind_Of_Customer}}</td> 
      <td>{{ x.full_name}}</td> 
      <td> {{ x.id}} </td> 
      <td> {{ x.city}} </td> 
        <td><a href="/hamatkin/index.html#/customerCardDetails/{{ x.customer_id}}" class="btn btn-primary btn- active">הצג פרטי לקוח </a></td> 
      <td><a ng-click="delete(x.customer_id, $index)" class="btn btn-primary btn- active">מחיקה</td> 

при использовании console.log (данные)

<br /> 
<font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'> 
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>(!)</span> Notice: Undefined variable: con in C:\wamp64\www\hamatkin\api\delete-customer.php on line <i>5</i></th></tr> 
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr> 
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr> 
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0005</td><td bgcolor='#eeeeec' align='right'>242216</td><td bgcolor='#eeeeec'>{main}()</td><td title='C:\wamp64\www\hamatkin\api\delete-customer.php' bgcolor='#eeeeec'>...\delete-customer.php<b>:</b>0</td></tr> 
</table></font> 
<br /> 
<font size='1'><table class='xdebug-error xe-warning' dir='ltr' border='1' cellspacing='0' cellpadding='1'> 
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>(!)</span> Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\wamp64\www\hamatkin\api\delete-customer.php on line <i>5</i></th></tr> 
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr> 
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr> 
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0005</td><td bgcolor='#eeeeec' align='right'>242216</td><td bgcolor='#eeeeec'>{main}()</td><td title='C:\wamp64\www\hamatkin\api\delete-customer.php' bgcolor='#eeeeec'>...\delete-customer.php<b>:</b>0</td></tr> 
<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>0.0041</td><td bgcolor='#eeeeec' align='right'>256080</td><td bgcolor='#eeeeec'><a href='http://www.php.net/function.mysqli-query' target='_new'>mysqli_query</a> 
()</td><td title='C:\wamp64\www\hamatkin\api\delete-customer.php' bgcolor='#eeeeec'>...\delete-customer.php<b>:</b>5</td></tr> 
</table></font> 
<br /> 
<font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'> 
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>(!)</span> Notice: Undefined variable: con in C:\wamp64\www\hamatkin\api\delete-customer.php on line <i>6</i></th></tr> 
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr> 
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr> 
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0005</td><td bgcolor='#eeeeec' align='right'>242216</td><td bgcolor='#eeeeec'>{main}()</td><td title='C:\wamp64\www\hamatkin\api\delete-customer.php' bgcolor='#eeeeec'>...\delete-customer.php<b>:</b>0</td></tr> 
</table></font> 
<br /> 
<font size='1'><table class='xdebug-error xe-warning' dir='ltr' border='1' cellspacing='0' cellpadding='1'> 
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>(!)</span> Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\wamp64\www\hamatkin\api\delete-customer.php on line <i>6</i></th></tr> 
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr> 
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr> 
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0005</td><td bgcolor='#eeeeec' align='right'>242216</td><td bgcolor='#eeeeec'>{main}()</td><td title='C:\wamp64\www\hamatkin\api\delete-customer.php' bgcolor='#eeeeec'>...\delete-customer.php<b>:</b>0</td></tr> 
<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>0.0069</td><td bgcolor='#eeeeec' align='right'>256088</td><td bgcolor='#eeeeec'><a href='http://www.php.net/function.mysqli-query' target='_new'>mysqli_query</a> 
()</td><td title='C:\wamp64\www\hamatkin\api\delete-customer.php' bgcolor='#eeeeec'>...\delete-customer.php<b>:</b>6</td></tr> 
</table></font> 
<br /> 
<font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'> 
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>(!)</span> Notice: Undefined variable: con in C:\wamp64\www\hamatkin\api\delete-customer.php on line <i>7</i></th></tr> 
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr> 
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr> 
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0005</td><td bgcolor='#eeeeec' align='right'>242216</td><td bgcolor='#eeeeec'>{main}()</td><td title='C:\wamp64\www\hamatkin\api\delete-customer.php' bgcolor='#eeeeec'>...\delete-customer.php<b>:</b>0</td></tr> 
</table></font> 
<br /> 
<font size='1'><table class='xdebug-error xe-warning' dir='ltr' border='1' cellspacing='0' cellpadding='1'> 
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>(!)</span> Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\wamp64\www\hamatkin\api\delete-customer.php on line <i>7</i></th></tr> 
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr> 
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr> 
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0005</td><td bgcolor='#eeeeec' align='right'>242216</td><td bgcolor='#eeeeec'>{main}()</td><td title='C:\wamp64\www\hamatkin\api\delete-customer.php' bgcolor='#eeeeec'>...\delete-customer.php<b>:</b>0</td></tr> 
<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>0.0095</td><td bgcolor='#eeeeec' align='right'>256040</td><td bgcolor='#eeeeec'><a href='http://www.php.net/function.mysqli-query' target='_new'>mysqli_query</a> 
()</td><td title='C:\wamp64\www\hamatkin\api\delete-customer.php' bgcolor='#eeeeec'>...\delete-customer.php<b>:</b>7</td></tr> 
</table></font> 
<br /> 
<font size='1'><table class='xdebug-error xe-warning' dir='ltr' border='1' cellspacing='0' cellpadding='1'> 
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>(!)</span> Warning: Cannot modify header information - headers already sent by (output started at C:\wamp64\www\hamatkin\api\delete-customer.php:6) in C:\wamp64\www\hamatkin\api\delete-customer.php on line <i>23</i></th></tr> 
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr> 
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr> 
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0005</td><td bgcolor='#eeeeec' align='right'>242216</td><td bgcolor='#eeeeec'>{main}()</td><td title='C:\wamp64\www\hamatkin\api\delete-customer.php' bgcolor='#eeeeec'>...\delete-customer.php<b>:</b>0</td></tr> 
<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>0.0115</td><td bgcolor='#eeeeec' align='right'>257184</td><td bgcolor='#eeeeec'><a href='http://www.php.net/function.header' target='_new'>header</a> 
()</td><td title='C:\wamp64\www\hamatkin\api\delete-customer.php' bgcolor='#eeeeec'>...\delete-customer.php<b>:</b>23</td></tr> 
</table></font> 

ответ

0

$scope.data не определен, таким образом, ошибка. Должно быть,

.success(function(data){ 

      data.splice(index, 1); 
      $scope.customerDetails = data; 

     }); 

Или,

.success(function(data){ 
      $scope.customerDetails = data; 
      $scope.customerDetails.splice(index, 1); 
     }); 

Если данные не является массивом, он не будет работать.

Я предполагаю, что это должно быть,

.success(function(data){ 
      console.log(data); 

      $scope.customerDetails = data.data; 
      $scope.customerDetails.splice(index, 1); 
     }); 
+0

спасибо, я изменил на то, что вы предложили, но теперь он говорит: $ scope.customerDetails.splice не function – tanyaa

+0

Это потому, что $ scope.customerDetails не является массивом. Можете ли вы консолировать сообщение DATA и показать мне ответ. – Ved

+0

Я точно не понял, что делать? – tanyaa

0

Это означает, что ваш $scope.data не определен. Убедитесь, что значение $scope.data имеет значение и представляет собой массив, прежде чем вы выполните сращивание.

Кроме того, я не вижу в вашем коде $scope.data. data, который вы получаете в обратном вызове, может быть тем, который вам нужен для сращивания.

+0

спасибо, я изменил код, и у меня есть другая ошибка $ scope.customerDetails.splice не является функцией – tanyaa

+0

означает, что '$ scope.customerDetails' не является массивом. Можете ли вы сделать 'console.log' в' $ scope.customerDetails'? – Srijith

+0

вы имеете в виду консоль.войти ($ scope.customerDetails)? и где писать? – tanyaa

0

$ scope.data не определено, поэтому он бросает, что использование ошибок только данные

data.splice(index, 1);

+0

спасибо, я изменил на то, что @Ved сказал, и теперь у меня есть ошибка - $ scope.customerDetails.splice не является функцией – tanyaa

+0

либо вы не можете получить данные, либо данные, которые вы извлекаете, не являются массивом, поэтому вы лучше сначала зарегистрировать данные. –

+0

Вы загружаете целую страницу, а не данные, так что вы получаете вот это, попробуйте привязать к бэкэнд не к странице php. –

Смежные вопросы