Jump to content

Need some help fixing an error


Stefan21

Recommended Posts

Okay, so I'm gettin the error:

 

Parse error: syntax error, unexpected $end in /home/candan21/public_html/test/index.php on line 1

 

I've checked all (,)'s and " and ' and the curly brackets { }. They all have a begin and end.

 

With this code: (I've done the error reporting, but it gives me the same error).

 

<?php
  if(!isset($_GET['brute'])) {
	Echo "You need to fill in a name.";
    } else {
	$brute = $_GET['brute'];
        $brute = strip_tags($brute);
        $brute = preg_replace('#\'#', '', $brute);
        $brute = preg_replace('#\"#', '', $brute);
	if(strlen($brute) > 13) 
        {
            Echo "A name can only be 13 characters or less.";
        } 
        else
        {
		$data = file_get_contents("http://".$_GET['brute'].".mybrute.com/cellule");	   
//lvl
	$regex = "/Level(1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]|6[0-9]|7[0-9]|8[0-9]|9[0-9]|[0-9])/";
	preg_match_all($regex, $data, $mydata);
	$lvl = $mydata[0][0];

    //name
	$regex1 = "/<h1>(.*)<\/h1>/";
	preg_match_all($regex1, $data, $mydata1); 
	$name = strip_tags($mydata1[0][0]);

    // hp
	$regex2 = "/<div class=\"life\">(.*)<\/div><\/div>/";
	preg_match_all($regex2, $data, $mydata2);  
	$hp = strip_tags($mydata2[0][0]);
	$hp = preg_replace('#health points#', '', $hp);
	$hp = preg_replace('#:#', '', $hp);
	$hp = preg_replace('#Strength#', '', $hp);
	$hp = preg_replace('# #', '', $hp);
	$hp = preg_replace('#Agility#', '', $hp);
	$hp = preg_replace('#Speed#', '', $hp);

    //Victories
	$regex3 = "/<div class=\"value\" onmouseover=\"mt\.js\.Tip\.show\(this,'Number of victories in the Arena.',null\)\" onmouseout=\"mt\.js\.Tip\.hide\(\)\">(.*)<\/div>/";
	preg_match_all($regex3, $data, $mydata3);  
	$victories = strip_tags($mydata3[0][0]);

//Pupils
	$regex4 = "/<div class=\"value\" onmouseover=\"mt\.js\.Tip\.show\(this,'Number of Brutes who have been recruited. Click here to see your pupils.',null\)\" onmouseout=\"mt\.js\.Tip\.hide\(\)\"><a href=\"\/dojo\">1<\/a><\/div>/";
	preg_match_all($regex4, $data, $mydata4);  
	$pupils = strip_tags($mydata4[0][0]);

//Strenght
	$regex5 = "/<div class=\"caracBar\" onmouseover=\"mt\.js\.Tip\.show\(this,'Strength:(1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]|6[0-9]|7[0-9]|8[0-9]|9[0-9]|[0-9])',null\)\" onmouseout=\"mt\.js\.Tip\.hide\(\)\"><div class=\"legend\">Strength:<\/div><div class=\"bar\">/";
	preg_match_all($regex5, $data, $mydata5);  
	$strength = $mydata5[0][0];
	$strength = preg_replace('#<div class=\"caracBar\" onmouseover=\"mt\.js\.Tip\.show\(this,\'#', '', $strength);
	$strength = preg_replace('#\',null\)\" onmouseout=\"mt\.js\.Tip\.hide\(\)\"><div class=\"legend\">Strength:<\/div><div class=\"bar\">#', '', $strength);

//Agility
	$regex6 = "/<div class=\"caracBar\" onmouseover=\"mt\.js\.Tip\.show\(this,'Agility:(1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]|6[0-9]|7[0-9]|8[0-9]|9[0-9]|[0-9])',null\)\" onmouseout=\"mt\.js\.Tip\.hide\(\)\"><div class=\"legend\">Agility:<\/div><div class=\"bar\">/";
	preg_match_all($regex6, $data, $mydata6);  
	$agil = $mydata6[0][0];
	$agil = preg_replace('#<div class=\"caracBar\" onmouseover=\"mt\.js\.Tip\.show\(this,\'#', '', $agil);
	$agil = preg_replace('#\',null\)\" onmouseout=\"mt\.js\.Tip\.hide\(\)\"><div class=\"legend\">Agility:<\/div><div class=\"bar\">#', '', $agil);

//Speed
	$regex7 = "/<div class=\"caracBar\" onmouseover=\"mt\.js\.Tip\.show\(this,'Speed:(1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]|6[0-9]|7[0-9]|8[0-9]|9[0-9]|[0-9])',null\)\" onmouseout=\"mt\.js\.Tip\.hide\(\)\"><div class=\"legend\">Speed:<\/div><div class=\"bar\">/";
	preg_match_all($regex7, $data, $mydata7);  
	$speed = $mydata7[0][0];
	$speed = preg_replace('#<div class=\"caracBar\" onmouseover=\"mt\.js\.Tip\.show\(this,\'#', '', $speed);
	$speed = preg_replace('#\',null\)\" onmouseout=\"mt\.js\.Tip\.hide\(\)\"><div class=\"legend\">Speed:<\/div><div class=\"bar\">#', '', $speed);


if($pupils == 1){
	$puptxt = $pupils." Pupil";
} else if($pupils == 0){
	$puptxt = "No Pupils";
} else {
$puptxt = $pupils." Pupils";
}

$my_img = imagecreatefrompng("background.PNG");
$text_colour = imagecolorallocate($my_img, 139, 119, 101);

imagestring($my_img, 4, 25, 20, $name, $text_colour);
imagestring($my_img, 4, 25, 35, $lvl, $text_colour);
imagestring($my_img, 4, 25, 50, $puptxt, $text_colour);
imagestring($my_img, 4, 25, 65, $strength, $text_colour);
imagestring($my_img, 4, 25, 80, $agil, $text_colour); 
imagestring($my_img, 4, 25, 95, $speed, $text_colour);
imagestring($my_img, 4, 25, 110, $victories." Victories", $text_colour); 	
imagestring($my_img, 4, 25, 127, "http://".$brute.".mybrute.com/cellule", $text_colour);
imagesetthickness($my_img, 5);

header("Content-type: image/png");

imagepng($my_img);
imagecolordeallocate($text_color);
imagedestroy($my_img);
	}
}
?>

 

Link to comment
https://forums.phpfreaks.com/topic/159809-need-some-help-fixing-an-error/
Share on other sites

If I put the if's alone, they work, the $data and $brute are what they should be, when I echo them.

 

The imaging works aswell, so does the info getting, with the regexes and preg matches, everything works, when put apart, but when fused, they seem to collide on something and give me errors

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.