Fatal error: Class 'HttpRequest' not found in /home/patricka/public_html/index/admins

Fatal error: Class ‘HttpRequest’ not found in /home/patricka/public_html/index/adminswaper.php on line 49

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Admin</title>
<link rel="stylesheet" type="text/css" href="/css/main.css?a=<%=now%>" />
</head>
<body>
<img src="background.jpg" alt="background image" id="fixed" />
<div id="content">
<div id="admin">

  <?php
	// redifine variables for different server
	require_once "mysqlconfig.php";  
	// connect to database
	$connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS); 
	if (!$connection)
	{
		die("Database connection failed: " . mysql_error());
	}
 
	// select database
	$db_select = mysql_select_db(DB_NAME,$connection);
	if (!$db_select)
	{
		die("Database selection failed: " . mysql_error());
	}
 
	// get table
	$result = mysql_query("SELECT * FROM th3rrc", $connection);
	if (!$result)
	{
		die("Database query failed: " . mysql_error());
	}
	$i=0;
	// display table
	while ($row = mysql_fetch_array($result)) 
	{
		$rank[$i]=$row["rank"];
		$name[$i]=$row["name"];
		$i++;
	}
	
	$pieces = explode("\
", $_POST[text]);
	$count=count($pieces);

	if($count>$i)
	{
		$toomany = new HttpRequest('toomany.php', HttpRequest::METH_GET);
		try 
		{
			$toomany->send();
			if ($toomany->getResponseCode() == 200) 
			{
				file_put_contents('local.rss', $toomany->getResponseBody());
			}
		} 
		catch (HttpException $ex) 
		{
			echo $ex;
		}
	}
	for($j=0;$j<$count;$j++)
	{
		$check[j]=0;
	}

	for($j=0;$j<$count;$j++)
	{
		$fieces = explode(" ", $pieces[j], 2);
		$dbmember[j]=$fieces[1];
		for($k=0;$k<=$i;$k++)
		{
			if($fieces[1]==$name[$k])
			{
				if($check[j]==0)
				{
					$check[j]=1;
				}
				else
				{
					$doubleentry = new HttpRequest('doubleentry.php', HttpRequest::METH_GET);
					try 
					{
						$doubleentry->send();
						if ($doubleentry->getResponseCode() == 200) 
						{
							file_put_contents('local.rss', $doubleentry->getResponseBody());
						}
					} 
					catch (HttpException $ex) 
					{
						echo $ex;
					}
				}
			}
		}
	}

	for($j=0;$j<$count;$j++)
	{
		if($check[j]==0)
		{
			$deletemember = new HttpRequest('deletemember.php', HttpRequest::METH_POST);
			$deletemember->addPostFields(array('member' => $dbmember[j]));
			try 
			{
				echo $deletemember->send()->getBody();
			}
			catch (HttpException $ex)
			{
				echo $ex;
			}
		}
	}

	for($j=0;$j<$count;$j++)
	{
		$fieces = explode(" ", $pieces[j], 2);
		for($k=0;$k<=$i;$k++)
		{
			if($fieces[1]==$name[$k])
			{
				if($fieces[0]!=$rank[$k])
				{
					$query="UPDATE th3rrc SET rank=".$fieces[0]." WHERE name=".$fieces[1];
					$result = mysql_query($query, $connection);
					if (!$result) 
					{
						die("Database INSERT failed: " . mysql_error());
					}
					$rank[$k]=$fieces[0];
				}
			}
		}
	}
	for($k=0;$k<=$i;$k++)
	{
	
	}
?>
 </div> 
 </div> 
</body>
</html>

not quite sure why im getting this error, i thought the httprequest class was in the standard library, im copying the code right from php.net! http://www.php.net/manual/en/httprequest.send.php

http://www.php.net/manual/en/http.install.php

This » PECL extension is not bundled with PHP.

So I guess you’ll have to check if the extension has been installed.

oh thank you so much
id like to make more generic code, is there a more common way to make an http request?
i would think they would have something like this bundled with php, since the only way to use php is with a request lol

You could use cURL: www.php.net/curl

this is stupid all i want to do is visit a link and i have to install all of these stupid extentions

It looks like you don’t just want to visit the link. What you trying to do is post a data to a web form at that location. For something like this CURL extension is required. HttpRequest is even better but it’s still just a wrapper for CURL.

alright thanks guys, ultra1 ur specifics were especially helpful, ill probably use httprequest, all i have to do is put the class where the error said it should be right?

Sadly not. It’s a PECL extension so it will need to be built into PHP (unlike PEAR). If you’re looking for a HTTP library which you can just include (if cURL is not your thing) take a look at Buzz or [URL=“https://github.com/guzzle/guzzle”]Guzzle. Please note, these libraries require PHP 5.3. If you don’t have PHP 5.3, try the PEAR package [URL=“http://pear.php.net/package/HTTP_Request2”]HTTP_Request2.