tags:

views:

26

answers:

1

I am trying to have a php script that displays a url with user data in it. The script is shown as follows.

<?php 
$url = "localhost/" + $_GET['type'] + "/" + str_replace(' ','%20',$_GET['message']) + "/";
print $url;
// create curl resource 
$ch = curl_init(); 
// set url 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_PORT, 6677); 
//return the transfer as a string 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
// $output contains the output string 
$output = curl_exec($ch); 
// close curl resource to free up sylstem resources 
curl_close($ch);

if ($output) { 
print $output;
}
else
{
print 'FAILED';
}
?>

This is part of a game that I am trying to make where the people talk using A.L.I.C.E, written in AIML (Artificial Intellagence Markup Language). I am using PyAIML. It needs to connect to a Python server on a different port.

The says when a request is received and it does not say it is getting a request at the when I load the page. I used tamper data to remove ALL request headers and it still worked with Firefox.

+1  A: 

The problem is with your first line. You're using the numeric addition operator + when you want to use the string concatenation operator instead .

Before:

$url = "localhost/" + $_GET['type'] + "/" + str_replace(' ','%20',$_GET['message']) + "/";

After:

$url = "http://localhost/" . $_GET['type'] . "/" . str_replace(' ','%20',$_GET['message']) . "/";

Also, note it couldn't hurt to explicitly declare the protocol portion of the URL.

pygorex1
Thanks. I program mainly javascript so I often forget this.
Eric