Need PHP help with this script

shanes

New Member
Messages
35
Reaction score
0
Points
0
Well i'm trying to make a dynamic signature image which uses GD libary and for part of it I want there to be a dynamic image which changes if i'm online or not on a site , here's the segment of the script that checks:
PHP:
$check = file_get_contents("http://habbo.$hotel/home/$habbo);
function check()
 {
   if (eregi('<h2 class="title">Page not found!', $check))
   {
     return == true;   
   }
    else
   {
     return == false;
   }
 }
$im = imagecreatefromgif("back.gif");
if check() return true
{
  $in = imagecreatefromgif("exist.gif");  
}
else
{
  $in = imagecreatefromgif("http://www.habbo.$hotel/habbo-imaging/avatarimage?user=$habbo&action=&direction=3&head_direction=3&size=l&img_format=gif");
}
I keep getting several different errors such as unexpected T_String or expecting a < etc even though it seems fine , Someone fix it for me please :(
 
Last edited:

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
Your first line is FUBAR.

Code:
[COLOR=#000000][COLOR=#0000bb]$check [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]file_get_contents[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]"http://habbo.$hotel/home/$habbo);[/COLOR][/COLOR]


Needs the " at the end (it's actually buggering this post too cause of it; make it this:

Code:
[/COLOR][/COLOR][COLOR=#000000][COLOR=#0000BB]$check [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]file_get_contents[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"http://habbo.$hotel/home/$habbo");

And see what happens.



Edit: Heh, apparently x10's posting thing didn't like me copy/pasting colors XD
 
Last edited:

mattura

Member
Messages
570
Reaction score
2
Points
18
where it says "unexpected T_STRING" or whatever, check the line number.
It usually means the lexer can't pair up the " or ' or {} ... or you missed a semi colon
 

shanes

New Member
Messages
35
Reaction score
0
Points
0
I've tidied it up and it seems fine yet I keep getting errors grr :( :
PHP:
$check = file_get_contents("http://habbo.$hotel/home/$habbo");
function check()
 {
   if (eregi('<h2 class="title">Page not found!', $check))
   {
     return true;   
   }
    else
   {
     return false;
   }
 }
$im = imagecreatefromgif("back.gif");
if check() true
{
  $in = imagecreatefromgif("exist.gif");  
}
else
{
  $in = imagecreatefromgif("http://www.habbo.$hotel/habbo-imaging/avatarimage?user=$habbo&action=&direction=3&head_direction=3&size=l&img_format=gif");
}
 

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
what is the error you are getting now?
 

shanes

New Member
Messages
35
Reaction score
0
Points
0
what is the error you are getting now?
Parse error: syntax error, unexpected T_STRING, expecting '(' in /home/shanessa/public_html/hhgs/2.php on line 18

line 18 =
if check() true
 

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
Parse error: syntax error, unexpected T_STRING, expecting '(' in /home/shanessa/public_html/hhgs/2.php on line 18

line 18 =
if check() true

Code:
if (check())

or

Code:
if (check () == true)

Without that equals sign it won't evaluate properly; it's taking true as a string instead of "if check equals true".

Leaving out the word true will work as well as long as check returns true when it's supposed to; that'd evaluate as "if true" if check() == true.


Long story short, pick whichever, they both should work :)
 
Top