Jump to content

Undefined Index, Please Help.


ivanax

Recommended Posts

I wrote this code to retrieve data from a HTTP request in c++ program so once it recieves it it sends the data into a mysql database

 

I get this error along the line. Here is my code.

<?php
require_once('inc/config.php');

$ip = $_POST['ip'];
$country = $_POST['country'];
$compname = $_POST['compname'];
$usr = $_POST['usr'];

$con = mysqli_connect(HOSTNAME,DBUSER,DBPASS,DB);

if(mysqli_connect_errno())
	{
	  echo "Failed to Connect" .mysqli_connect_error();
	}
  mysqli_query($con,"INSERT INTO data (ip,country,compname,usr) VALUES($ip,$country,$compname,$usr)");

?>

Now here is my error

 

 

( ! ) Notice: Undefined index: ip in C:\wamp\www\panel\gate.php on line 4 Call Stack # Time Memory Function Location 1 0.0050 142200 {main}( ) ..\gate.php:0
( ! ) Notice: Undefined index: country in C:\wamp\www\panel\gate.php on line 5 Call Stack # Time Memory Function Location 1 0.0050 142200 {main}( ) ..\gate.php:0
( ! ) Notice: Undefined index: compname in C:\wamp\www\panel\gate.php on line 6 Call Stack # Time Memory Function Location 1 0.0050 142200 {main}( ) ..\gate.php:0
( ! ) Notice: Undefined index: usr in C:\wamp\www\panel\gate.php on line 7 Call Stack # Time Memory Function Location 1 0.0050 142200 {main}( ) ..\gate.php:0 Edited by ivanax
Link to comment
Share on other sites

All of your POST variables are the result of an html page being 'posted' to this script.  Do you have such a thing calling this script or are you running it as a url in your browser?

 

As gristol said - confirm that the elements exist in the POST array,even if you run it as the result of a posted form and they are supposed to exist.

Link to comment
Share on other sites

@ginerjm, yes am actually sending the data from a http request done by a c++ program so that it can receive it and in turn save the data to a mysql base. I tried that too gave me some errors, maybe I am not doing it correctly, a source code may be quite helpful.

Link to comment
Share on other sites

Sorry - I don't know anything about doing this.  I didn't know you could emulate an http request but you will have to do some research on the proper formatting of that data stream and perhaps how to make php retrieve it.  In fact, how ARE you telling php where the data is coming from?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.