# Elasticserach-PHP error

**URL:** <https://discuss.elastic.co/t/elasticserach-php-error/22702>\
**Category:** Elasticsearch\
**Created:** [March 17, 2015, 7:43am UTC](https://discuss.elastic.co/t/elasticserach-php-error/22702 "2015-03-17T07:43:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arul\_murugan\_Ramalin](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@Arul\_murugan\_Ramalin](https://discuss.elastic.co/u/Arul_murugan_Ramalin)\
**Post date:** [March 17, 2015, 7:43am UTC](https://discuss.elastic.co/t/elasticserach-php-error/22702/1 "2015-03-17T07:43:59Z")

</div>

I was trying to workout the example from the below link

Search Engine with PHP & Elasticsearch - YouTube  
[https://www.youtube.com/watch?v=3xb1dHLg-Lk](https://www.youtube.com/watch?v=3xb1dHLg-Lk)

I cannot index the document (add.php example).

only When I remove the code for the Indexing the html form appears.

```
<?php

```

require 'vendor/autoload.php';  
$es = new Elasticsearch\Client();

if(!empty($\_POST)) {  
if(isset($\_POST['title'],$\_POST['body'],$\_POST['keywords'])) {  
$title = $\_POST['title'];  
$body = $\_POST['body'];  
$keywords = explode(',',$\_POST['keywords']);  
$indexed = $es-\>index([  
'index' =\> 'articles',  
'type' =\> 'article',  
'body' =\> [  
'title' =\> $title,  
'body' =\> $body,  
'keywords' =\> $keywords  
]  
]);

if($indexed) {  
print\_r($indexed)  
}  
}  
}  
?\>  
\<!doctype html\>

Add in ES Title  
  
  
Body  
  
  
Keywords  
  
  

Thanks in Advance

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/71680616-7733-4244-a78e-6342013d2564%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/71680616-7733-4244-a78e-6342013d2564%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:26am UTC](https://discuss.elastic.co/t/elasticserach-php-error/22702/2 "2017-07-06T00:26:21Z")

</div>


