MySQL - ERROR !!!

The db says:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Error nr: 1064

The input was:

SELECT nume,email,telefon FROM agenti WHERE id_in_bd_originala=


$_SERVER["SCRIPT_FILENAME"]:/var/www/vcc.ro/web/detalii/detalii_teren.php
$_SERVER["PHP_SELF"]:/detalii/detalii_teren.php
$_SERVER["HTTP_HOST"]www.vcc.ro
$_SERVER["REQUEST_URI"]/detalii/detalii_teren.php?back=first&id=51
$_SERVER["QUERY_STRING"]back=first&id=51
$_SERVER["HTTP_REFERER"]
$_SERVER["REMOTE_HOST"]ec2-54-221-136-62.compute-1.amazonaws.com
$_SERVER["REMOTE_ADDR"]54.221.136.62
$_SERVER["REMOTE_PORT"]41046
$_SERVER["HTTP_USER_AGENT"]CCBot/2.0 (http://commoncrawl.org/faq/)
$_SERVER["REQUEST_METHOD"]GET
$_SERVER["QUERY_STRING"]back=first&id=51
$_POST:
$_GET:
back:first
id:51
$_SESSION:
backDetAp:../middle.php
$_COOKIE:
$_ENV:
$_REQUEST:
back:first
id:51
$_SERVER:
PHP_FCGI_MAX_REQUESTS:5000
PHP_DOCUMENT_ROOT:/var/www/clients/client3/web45
PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PHPRC:/etc/php5/cgi/
PWD:/var/www/php-fcgi-scripts/web45
CONTENT_LENGTH:0
HTTP_CONNECTION:close
SCRIPT_NAME:/detalii/detalii_teren.php
REQUEST_URI:/detalii/detalii_teren.php?back=first&id=51
QUERY_STRING:back=first&id=51
REQUEST_METHOD:GET
SERVER_PROTOCOL:HTTP/1.0
GATEWAY_INTERFACE:CGI/1.1
REMOTE_PORT:41046
SCRIPT_FILENAME:/var/www/vcc.ro/web/detalii/detalii_teren.php
SERVER_ADMIN:webmaster@vcc.ro
CONTEXT_DOCUMENT_ROOT:/var/www/vcc.ro/web
CONTEXT_PREFIX:
REQUEST_SCHEME:http
DOCUMENT_ROOT:/var/www/vcc.ro/web
REMOTE_ADDR:54.221.136.62
SERVER_PORT:80
SERVER_ADDR:217.79.184.22
SERVER_NAME:www.vcc.ro
SERVER_SOFTWARE:Apache
SERVER_SIGNATURE:
HTTP_ACCEPT:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_USER_AGENT:CCBot/2.0 (http://commoncrawl.org/faq/)
HTTP_ACCEPT_ENCODING:x-gzip, gzip, deflate
HTTP_HOST:www.vcc.ro
FCGI_ROLE:RESPONDER
PHP_SELF:/detalii/detalii_teren.php
REQUEST_TIME_FLOAT:1513407176.6344
REQUEST_TIME:1513407176