Jump to content

papaface

Members
  • Posts

    1,437
  • Joined

  • Last visited

    Never

Posts posted by papaface

  1. change:

    $con = mysql_connect(PATH,USERNAME,PASSWORD);
    $database = mysql_select_db(DATABASE);
    if(!$database)
    {
       header('Location: login.php?database=no');
    }

    to

    $con = mysql_connect(PATH,USERNAME,PASSWORD);
    $database = mysql_select_db(DATABASE,$con);
    if(!$database)
    {
       header('Location: login.php?database=no');
    }

  2. What's with the semi-colons in the cases?

    session_start();
    switch ($_GET['lang']) {
    case 'Fr':
       $_SESSION['lang'] = "Fr";
       break;
    
    case 'En':
    default:
       $_SESSION['lang'] = "En";
    }
    

    Oops typo lol. Dunno why I did them all with a semi-colon and then with a colon for the default ??? lol
  3. should be:

            foreach($words as $key => $word)
       
             {
    
         
    
             //remove punctuation
    
             $word= str_replace($punc, "", $word);
           
             //make lowercase
    
             $word = strtolower($word);
    
    
             //remove stop words
    
             $result = array_diff($word, $stop);
    
             print_r($result);

  4. Hello,

     

    I am currently working with the Twitter API. Those of you who are familar with it will know that to update the background image on a given Twitter account, you need the submit the given image to the API in multipart form.

     

    This is really confusing me and any help would be appreciated.

     

    My code at the moment is:

    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    ini_set('memory_limit', '1600M');
    require("twitter.php");
    
    $twitter = new Twitter("///","////");
    
    
    // Set the content-type
    //header('Content-type: image/jpeg');
    
    // Create the image
    $im = imagecreatefromjpeg("background.jpg");
    $white = imagecolorallocate($im, 255, 255, 255);
    $grey = imagecolorallocate($im, 62, 51, 54);
    $black = imagecolorallocate($im, 95, 95, 95);
    
    // The text to draw
    // Replace path by your own font path
    $font = 'MyriadPro-SemiboldSemiExt.otf';
    
    // Add some shadow to the text
    
    
    // Add the text
    //imagettftext($im, 20, 90, 34, 500, $black, $font, $text);
    $text = 'Some random text';
    /*imagettftext($im, 20, 90, 78, 538, $grey, $font, $text);
    imagettftext($im, 20, 90, 74, 538, $black, $font, $text);*/
    imagettftext($im, 20, 90, 77, 536, $white, $font, $text);
    imagettftext($im, 20, 90, 74, 538, $black, $font, $text);
    imagejpeg($im, 'simpletext.jpg');
    //echo '<img src="simpletext.jpg" />';
    // Using imagepng() results in clearer text compared with imagejpeg()
    $mime_boundary=md5(time());
    $headers .= 'From: My Email <me@company.com>' . "\n";
    $headers .= 'MIME-Version: 1.0'. "\n";
    $headers .= "Content-Type: multipart/mixed; boundary=\"".$mime_boundary."\"". "\n";
    
    if	($twitter->updateProfileBackgroundImage("simpletext.jpg"))
    {
    echo "done";
    }
    else
    {
    echo "problem";
    }
    //imagejpeg($im);
    
    ?>

    But this is giving me this error:

    Fatal error: Uncaught exception 'TwitterException' with message 'Not Implemented' in /twitter.php:1230 Stack trace: #0 /process.php(42): Twitter->updateProfileBackgroundImage('simpletext.jpg') #1 {main} thrown in /twitter.php on line 1230

     

    Any help would be appreciated :'(

  5. Hello,

     

    I have a situation where I am wanting to access a class which is declared in my code from within another class.

    e.g

    class someRandomclass
    {
    function myName()
      {
       return "Andrew";
      }
    }
    $example = new someRandomclass();
    class anotherRandomclass
    {
    function bothNames()
      {
       echo $example->myName() . " randomer";
      }
    }
    $example2 = new anotherRandomclass();
    echo $example2->bothNames();
    

     

    Obviously this is a ridiculous example, but it demonstrates what I am trying to achieve, however it wont work.

    Any ideas?

  6. Hello,

     

    I am trying to search a string for a particular occurrence however I want it to work regardless of spaces.

     

    This is the code I have currently:

       $string = "Hello I am papa_face.";
    
       $pos = strpos($string, "I am papa_face");
       if ($pos !== false)
          echo "Contains the string.";
          else
          echo "Does NOT contain the string.";
    

    Obviously in this example the string does contain the search term so it returns "Contains the string."

     

    However if I change the string to:

       $string = "Hello I am                 papa_face.";
    
       $pos = strpos($string, "I am papa_face");
       if ($pos !== false)
          echo "Contains the string.";
          else
          echo "Does NOT contain the string.";

    The string is not found. How can I get around this?

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