Problems with Client Connection Ethernet Shield W5100


I tried to perform the following operation: configure my ethernet module as a client to perform a query in the mysql database, I connect but I do not get the answer.
Any information would be very helpful, below the code I used to perform the operation

Thank you!


#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  //MAC Shield

char server[] = "localhost";    // Nombre del servidor  (usando DNS)

IPAddress ip(192, 168, 1,103 ); //Asignacion Ip de la shield

EthernetClient client; //Inicializa cliente

void setup() {

   Ethernet.begin(mac, ip);   //Inicia Ethernet Shield

  if (client.connect(server, 80)) {
    // Peticion HTTP 
    client.println("GET pinfo/pbusqueda.php?buscar=M HTTP/1.1");
    client.println("Host: localhost");
    client.println("Connection: close");
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");

void loop() {
//Si servidor esta disponible lee e imprime datos 
  if (client.available()) {
    char c =;

//Si servidor esta desconectado, detiene cliente
  if (!client.connected()) {

    // do nothing forevermore:
    while (true);


<!DOCTYPE html>
	<title>Registro Base de Datos</title>


$busqueda=$_GET["buscar"]; 	//Obtiene el valor de la variable del cuadro de texto buscar

$servidor="localhost";	//Nombre del servidor
$usuarios="";	//Usuario Base de Datos
$pass="";			//Contrasena del Servidor
$db="operaciones";	//Nombre de la Base de Datos

  $conexion = new mysqli($servidor,$usuarios,$pass);	//Conexion con Base de Datos

/* Si la conexion es fallida entra en este if*/
  if (mysqli_connect_errno()) {
  	echo "Fallo al conectar con la Base de Datos";
  	exit();	//Forza la salida del codigo php

 mysqli_select_db($conexion,$db) or die("Base de Datos no se encuetra"); 		//Selecciona Base de Datos

mysqli_set_charset($conexion,"utf8"); 		//Se especifica que se usara caracteres latinos

$_consulta="SELECT * FROM usuarios WHERE apellido LIKE '%$busqueda%' ";		//Se especifica que se buscara en la BD
$_resultado= mysqli_query($conexion,$_consulta);	//Se hace consulta a la BD y guard info virtualmente

while ( $_filas= mysqli_fetch_array($_resultado,MYSQL_ASSOC) ) {

echo "<table><tr><td>";
echo $_filas['id']. 		"	</td><td></td><td>	"; /*Imprime cada elemenetos del array*/
echo $_filas['nombre']. 	"	</td><td></td><td>	"; /*Imprime cada elemenetos del array*/
echo $_filas['correo']. 	"	</td><td></td><td></tr></table>	";


mysqli_close($conexion);	//Cierra conexion con Base de Datos


You can't use localhost as the server. That is only valid on the server itself. Use the IP of the server.

I made the change from localhost to ip as follows:
Char server = “”;
But the server still does not return the correct value
Here I leave what returns me:

localhost or is the internal address of the local device (your Arduine Ethernet shield). You need to point to your SQL server (external to the arduino).