trying to send data to mysql problem

hello

I’m trying to send data from my arduino to phpmysql but no data send to the server

the code for arduino as follow

#include <enc28j60.h>
#include <EtherCard.h>
#include <net.h>
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
static byte myip[] = { 192,168,1,200 };
static byte gwip[] = { 192,168,1,20 };
const char website[] PROGMEM = "192.168.1.12:8080";
//char website[] PROGMEM = "google.com";
byte Ethernet::buffer[500];
static uint32_t timer;
BufferFiller bfill;
static word homePage(){
   bfill = ether.tcpOffset();
   bfill.emit_p(PSTR("ya 3eeb elshooom...\r\n\r\n"));
   return bfill.position();
}


// called when the client request is complete
static void my_callback (byte status, word off, word len) {
  Serial.println(">>>");
  Ethernet::buffer[off+300] = 0;
  Serial.print((const char*) Ethernet::buffer + off);
  Serial.println("...");
}
void setup() {
   Serial.begin(57600);
   Serial.print("[test]");
 if (ether.begin(sizeof Ethernet::buffer, mymac, 53) ==0)
   Serial.print("Failed to access Ethernet controller");
 else
   Serial.print("Ethernet controller ok!");
   ether.staticSetup(myip);
   ether.printIp("IP:  ", ether.myip);
   ether.printIp("GW:  ", ether.gwip);  
   ether.printIp("DNS: ", ether.dnsip);  
if (!ether.dnsLookup(website))
    Serial.println("DNS failed");
    
  ether.printIp("SRV: ", ether.hisip);

}



void loop() {
  /*word pos = ether.packetLoop(ether.packetReceive());
  if(pos)
  ether.httpServerReply(homePage());
  ether.packetLoop(ether.packetReceive());*/
  ether.packetLoop(ether.packetReceive());
  
  if (millis() > timer) {
    timer = millis() + 5000;
    Serial.println();
    Serial.print("<<< REQ ");
   /* ether.hisip[0] = 192;
    ether.hisip[1] = 168;
    ether.hisip[2] = 1;
    ether.hisip[3] = 12;*/
    ether.hisport = 8080;//to access  local host
    ether.browseUrl(PSTR("/add_data.php?"), "sensor=2&temperature=1", website, my_callback);
  

}
}

I save add_data.php page in the following folder C:\xampp\htdocs\add_data.php

and the code for that page

<?php
	// Connect to MySQL
	include("dbconnect.php");
	$sensor=$_GET["sensor"];
	$temperature=$_GET["temperature"];
		// Prepare the SQL statement
		$SQL = "INSERT INTO test(sensor ,celsius) VALUES ('$sensor','$temperature')";     
			// Execute SQL statement
		mysql_query($SQL);
		
		
	
	// Go to the review_data.php (optional)
	header("Location: review_data.php");
?>

i can view data from my server

http://192.168.1.12:8080/review_data.php

the circuit is attached

any help would be greatly appreciated :slight_smile:

Are you able to insert data into mySQL from your browser? eg if you visit http://192.168.1.12:8080/add_data.php?sensor=2&temperature=1 in your browser does it insert?

have you checked the xampp access and error logs? Theres some info at apache - Where does PHP's error log reside in XAMPP? - Stack Overflow

rw950431:
Are you able to insert data into mySQL from your browser? eg if you visit http://192.168.1.12:8080/add_data.php?sensor=2&temperature=1 in your browser does it insert?

have you checked the xampp access and error logs? Theres some info at apache - Where does PHP's error log reside in XAMPP? - Stack Overflow

thanks for your reply yes it does insert from the browser o the database without any problem

the serial give me the following reading

GW:0.0.0.0
DNS:0.0.0.0
DNs faild
SRV: 0.0.0.0

All those 0.0.0.0’s mean that there was a problem initializing the ethernet shield. Perhaps you should check your wiring and try the basic example sketch for your shield.

(Heres a neat trick- if you attach a picture, right-click on it and “save image location”. Re-edit your post and click the Ádd image button, paste the address and your photo is now inline)

158e27cd5709036798df869c56c382cbace89663.png