Jump to content

wantstolearnphp

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

wantstolearnphp's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Following Sams PHP 24hrs... Rewrote Example and it isn't working... I am not getting any syntax error just an error saying it cannot display the graph because there are errors in the image. I have went through it line for line looking for mispellings you name it making sure it was exactly as they wrote so I could follow along... but now its is not working and I believe its me.. not the book... can anyone help me out? <?php //Send content type header to browser so image will be rendered header ("Content-type: image/png"); class SimpleBar { private $xgutter = 20;//left/right margin private $ygutter = 20;//top/bottom margin private $bottomspace = 30;//gap at the bottom private $internalgap = 10;//gap between bars private $cells = array();//labels/amounts for bar charts private $totalwidth; private $totalheight; private $font; function __construct( $width, $height, $font ) { $this->totalwidth = $width; $this->totalheight = $height; $this->font = $font; } //Used to allow user to populate $cells[] property array function addBar( $label, $amount ) { $this->cells[ $label ] = $amount; } private function _getTextSize( $cellwidth ) { $textsize = (int)( $this->bottomspace );//Make $textsize equal to bottomspace if ( $cellwidth < 10 ) { $cellwidth = 10; } //Loop through the cells array and acquire dimension info for the labels using imageTTfbBox() foreach ( $this->cells as $key=>$val ) { while ( true ) { $box = imageTTFbBox( $textsize, 0, $this->font, $key ); $textwidth = abs ( $box[2] ); if ( $textwidth < $cellwidth ) { break; } $textsize--; } } return $textsize; } function draw() { $image = imagecreate( $this->totalwidth, $this->totalheight );//Create Image Resource //Create Color resources $red = imagecolorallocate( $image, 255,0,0 );//Red $blue = imagecolorallocate( $image, 0,0,255 );//Blue $black = imagecolorallocate( $image, 0,0,0 );//Black $max = max( $this->cells );//Cache the maxium value the $cells[] array has $total = count( $this->cells );//Cache the number of elements the $cells[] array contains $graphCanX = ( $this->totalwidth - $this->xgutter*2 );//Set up the canvas space on the X-axis for the graph $graphCanY = ( $this->totalheight - $this->ygutter*2 - $this->bottomspace );//Set up the canvas space on the Y-axis for the graph ( Have to allow room for our labels and margins ) $posX = $this->xgutter;//Store the starting point for drawing our bars on the X-axis $posY = $this->totalheight - $this->ygutter; - $this->bottomspace;//Store the starting point for drawing our bars on the Y-axis ( Have to allow room for our labels and margins ) $cellwidth = (int) ( ( $graphCanX -( $this->internalgap * ( $total - 1 ) ) ) / $total );//Calculate the cellwidth for each bar by taking the width of the graph canvas and subtracting the total distance bewteen the bars divided by the total amount of bars being used $textsize = $this->_getTextSize( $cellwidth ); foreach( $this->cells as $key=>$val ) { $cellheight = (int) ( ( $val/$max ) * $graphCanY );//Calculate height of each bars $center = (int) ( $posX + ($cellwidth/2) );//Calculate cener point of bars $imagefilledrectangle( $image, $posX, ($posY - $cellheight), ($posX+$cellwidth), $posY, $blue);//Draw the bars $box = imageTTFbBox( $textsize, 0, $this->font, $key ); $tw = $box[2]; imageTTFtext( $image, $textsize, 0, ($center-($tw/2) ), ( $this->totalheight-$this->ygutter), $black, $this->font, $key ); $posX += ( $cellwidth + $this->internalgap); } imagepng( $image ); } } $graph = new SimpleBar( 500, 300, "league_gothic-webfont.ttf" ); $graph->addBar("Really Liked" , 200); $graph->addBar("Liked" , 100); $graph->addBar("Kinda Like" , 300); $graph->draw(); ?>
  2. I have WAMP server 2.1 and am trying to access the DB.php that is part of PEAR but cannot... Also i cannot find anything named DB.php inside of my PEAR directory that got installed by the WAMP Server 2.1 easy installer...Do I need to download these and store them in the directory myself? I mean for that matter there isn't one .php file in the directory it installed... only a file named go-pear.phar. I can access MySQL and SQL Lite manually but want to utilize these functions because of the book I'm using to learn PHP. I also have seen that DB is deprecated and that MDB2 has replaced it... How do I get any of the two working properly?
  3. Ok so I'm not completely nuts... how am I to make it so I can work with dbm databases on my machine then? What do I have to do? How do I use php to manipulate the databases on a windows system? Download a compiler to compile what? PHP or php source? I'm so confused! Is there something I can add in my php scripts that will make the dba functions available?
  4. Is there a shell i'm supposed to be opening somewhere? I've got WAMP server 2.1 installed with PHP.5.3.5.. and if there is a shell so I can enter this command and set the switches or flags I've been reading about so I can manipulate dbm databases. The php manual talks about the things I should do but nothing tells me specifically where the hell I need to run these commands. I followed sever tutorials and nothing has been working for me. I've got a application I'm working on that currently saves customer information in files, outputs the info just added to the file, then allows you to delete them and I really want to keep learning but am having quite a bit of trouble finding where to enter these commands. What am I missing? I feel like its right in front of my eyes... I've tried going into the directory i have php and running the cli and cgi from there out of desperation. Just opens up a shell which I cannot do anything with... am i just stupid? and if I am please someone spell this process out for me so I use set dba handlers and create dbm database so I can move on to SQL after.
  5. I have WAMPSEVER 2.1 one installed and don't know how to set my php.ini file so that I can start following sams php in 24 hours section 12 on DBA and DBM databases. Its stalling my study big time. I was wondering if anyone could help with that or if I had to know dba or dbm if I have MySql? I got PHP 5.3.5 Details: http://www.php.net/manual/en/ref.dba.php I tried to use the function: --------------------------------- var_dump( dba_handlers() ); --------------------------------- which is supposed to give me a quick listing of available handlers. But when I run this, I get: ----------------------------------- Fatal error: Call to undefined function dba_handlers() in c:\wamp\www\dba_function.php on line 10 ---------------------------------- Thanks in Advance for help, I need to continue studying
  6. Please help me I have 5 months to get a grasp on this... please help
  7. :shrug:My PHP install didn't come with DBA or DBM or whatever... I have followed sams 24 hour php book 3rd edition and am at working with dba functions and cannot continue please someone help!
  8. Thank you very much... I've also ordered ... Sams PHP in 24 hours last night.... as well as a book on html and css but it was from a woman pretty well known... lol I can't even remember her name or the books at the moment.... i know i read quite a few reviews on it....because I want to make sure I have a good reference... I've learned my css knowledge and html knowledge from W3 schools and when I was in high school developed tic tac toe with c++ and actually have a copy of visual basic some where around here...but that was almost 6-7 years ago and i got into working and didn't realize for some reason the money I could have been making now if I'd just stayed in programming.... after reading some post in these forums i thought i'd better get a book with some good reviews for references and to make sure I have the tools to be successful. thank you very much again.. I will start reading today. . later
  9. I have a good working knowledge of html, xhtml, and css but New to php! Need to learn as quickly as possible. Using word press to develop sites and have started a web development company, oh yes lots of pressure! I am ready to take php head on so I can have full control. I've completed up to Sessions in the tutorials from w3 schools. Love MMA and am actually a Amateur MMA fighter... if you want to see me knock someone out or watch me get knocked out search "bob ruby dauntless mma" and "robert ruby vs johndelbrugge at absolute annihilation in va". Also some please tell me what are some good beginning programs to develop for practice in PHP. Thanks n i'll be on alot asking questions and when I come across something I feel I could answer with some research then I will but don't wish to give an uneducated answer.
×
×
  • 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.