SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2010
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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
    Code:
    <!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("\n", $_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

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,508
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    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.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2010
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  4. #4
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    You could use cURL: www.php.net/curl

  5. #5
    SitePoint Enthusiast
    Join Date
    Jan 2010
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is stupid all i want to do is visit a link and i have to install all of these stupid extentions

  6. #6
    SitePoint Enthusiast
    Join Date
    Dec 2011
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  7. #7
    SitePoint Enthusiast
    Join Date
    Jan 2010
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  8. #8
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    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 Guzzle. Please note, these libraries require PHP 5.3. If you don't have PHP 5.3, try the PEAR package HTTP_Request2.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •