These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
 

Syntax Help - Unexpected T_Variable

Author
Jack Bennett
E.M.P.I.R.E. Allied Unlimited
#1 - 2012-03-15 13:43:49 UTC
Hi Everyone.
I'm working on some customized API EVE stuff.
I was actually following the Tutorial from the sticky. Everything was going great until the functions file got started. Then it started giving me syntax errors.

I cannot seem to find out why - or what's wrong - I've search and search.

Any help would be greatly appreciated!

The Syntax error is coming from "line 3" -- which is the "function makeApiRequest($url)" line ---


function makeApiRequest ($url)

// Initialize a new request for this UR
$ch = curl_init($url)

// Set the options for this reques
curl_setopt_array($ch, array
CURLOPT_FOLLOWLOCATION => true, // Yes, we want to follow a redirec
CURLOPT_RETURNTRANSFER => true, // Yes, we want that curl_exec returns the fetched dat
CURLOPT_SSL_VERIFYPEER => false, // Do not verify the SSL certificat
)

// Fetch the data from the UR
$data = curl_exec($ch)

// Close the connectio
curl_close($ch)

// Return a new SimpleXMLElement based upon the received dat
return new SimpleXMLElement($data)


MrWhitei God
Sebiestor Tribe
Minmatar Republic
#2 - 2012-03-15 14:03:53 UTC  |  Edited by: MrWhitei God
Jack Bennett wrote:
Hi Everyone.
I'm working on some customized API EVE stuff.
I was actually following the Tutorial from the sticky. Everything was going great until the functions file got started. Then it started giving me syntax errors.

I cannot seem to find out why - or what's wrong - I've search and search.

Any help would be greatly appreciated!

The Syntax error is coming from "line 3" -- which is the "function makeApiRequest($url)" line ---


function makeApiRequest ($url)

// Initialize a new request for this UR
$ch = curl_init($url)

// Set the options for this reques
curl_setopt_array($ch, array
CURLOPT_FOLLOWLOCATION => true, // Yes, we want to follow a redirec
CURLOPT_RETURNTRANSFER => true, // Yes, we want that curl_exec returns the fetched dat
CURLOPT_SSL_VERIFYPEER => false, // Do not verify the SSL certificat
)

// Fetch the data from the UR
$data = curl_exec($ch)

// Close the connectio
curl_close($ch)

// Return a new SimpleXMLElement based upon the received dat
return new SimpleXMLElement($data)




not sure if its the forum formatting or not but you have no semi-colons after each statement or opening/closing braces for the function

also the array your passing into curl_setopt has a comma after the last element which is incorrect


function makeApiRequest ($url)
{
// Initialize a new request for this UR
$ch = curl_init($url);

// Set the options for this reques
curl_setopt_array($ch, array(
CURLOPT_FOLLOWLOCATION => true, // Yes, we want to follow a redirec
CURLOPT_RETURNTRANSFER => true, // Yes, we want that curl_exec returns the fetched dat
CURLOPT_SSL_VERIFYPEER => false // Do not verify the SSL certificat
)
);

// Fetch the data from the UR
$data = curl_exec($ch);

// Close the connectio
curl_close($ch);

// Return a new SimpleXMLElement based upon the received dat
return new SimpleXMLElement($data);
}
Steve Ronuken
Fuzzwork Enterprises
Vote Steve Ronuken for CSM
#3 - 2012-03-15 14:06:29 UTC
It'll be the lack of semicolons.

I run into this every so often (as I'm a bad typist. or something like that).

Woo! CSM XI!

Fuzzwork Enterprises

Twitter: @fuzzysteve on Twitter

Jack Bennett
E.M.P.I.R.E. Allied Unlimited
#4 - 2012-03-15 17:09:35 UTC
MrWhitel and Steve,

Thanks ---

The forum format must have stripped my semicolons.... I didn't even take notice they were missing in the forum post.

---

Now -- for an update ---

I just tried the same code - that was posted here by MyWhitel and I'm still getting the same syntax error, unexpected T_FUNCTION on the exact same line "3" ---

Perhaps I've got something wrong with my web server?

There's gotta be something I'm just not figuring out that's causing the syntax error.

Is there something else -- other then actual missing syntax -- that would cause this syntax error that it's showing me?

The error is thus ---

Parse error: syntax error, unexpected T_FUNCTION in /blablabla/blablabla/evefunctions.php on line 3


Thanks for the continued support -- this is my first attempt to use the EVE API --- not my first attempt at PHP in general....So I'm all ears....I expect to learn something. :)
MrWhitei God
Sebiestor Tribe
Minmatar Republic
#5 - 2012-03-15 19:13:52 UTC
the error message you see "unexpected T_FUNCTION on line 3" normally means check the previous line of code.


whats on lines 1 and 2?
perhaps you have missed another opening/closing braces or semi-colon.

if your including this file from another script check the line before where you include it.
Jack Bennett
E.M.P.I.R.E. Allied Unlimited
#6 - 2012-03-15 19:59:08 UTC  |  Edited by: Jack Bennett
MrWhitei God wrote:
the error message you see "unexpected T_FUNCTION on line 3" normally means check the previous line of cod


whats on lines 1 and
perhaps you have missed another opening/closing braces or semi-colo

if your including this file from another script check the line before where you include i


Cripes! --- that's it ! --- Thanks!

Had a space between the ? and PHP ...... nothing more.

Error is gone now

.... holy cows.

Thanks for helping me fix this ---- i hate "ID10T" errors! ---- :)