Jump to content

Kurrel

Members
  • Posts

    70
  • Joined

  • Last visited

    Never

Everything posted by Kurrel

  1. I have tried to circumvent the problem by putting the variables into a database, only to find that any sql work apparently also breaks gd. What use is a graphic set if it can't be used for anything but 100% static, isolated instances? Is there ANY way (besides _GETting through the URL) to get variables into this?!
  2. Nope, the session is the first thing set in the whole process. The image is drawn when the <img> flag is referenced, without prior work. The session exists before and after, but I begin to think that since it's referencing linegraphdrawer.php directly it is using it as an external resource, in which the current variables of index.php are not visible.
  3. It all works at the moment, I have hard coded values inside linegraphdrawer.php that I am using to render the image. It works, and displays the graph using the hard data, but I need to replace that hard data with a variable data set stored in the session. the ?test=12 inside the <img> tag was to check whether _GET worked... it does, the _GET is visible when passed this way. Still no session, though. With or without the session, the .php renders the image... unless I include linegraphdrawer.php in index.php. I can then see the session, but am unable to utilize gd to draw the graph, the purpose for which it was created in the first place. Blowing my mind.
  4. Absolutely. the print("<pre style='font-family:verdana;font-size:13'>"); print_r($_SESSION); print("</pre>"); displays every value contained in the session, but they are not available inside linegraphdrawer.php. Hence, my confusion.
  5. <?PHP // Preperation { session_start(); ob_start(); First thing in index.php, $_SESSION["data"] = "TEST"; print("<pre style='font-family:verdana;font-size:13'>"); print_r($_SESSION); print("</pre>"); print("<img src='".BASE."/basefunctions/maxgraphs/linegraphdrawer.php?test=12' alt='test'>"); Is then run, and the pre details the session fully, but the image that is presented on the next line does not have session referenced inside it.
  6. If I include linegraphdrawer.php in index.php the drawer bombs as the headers are redeclared. The only way I was able to get GD to work was this fashion, and now it seems that it's functionality is compromised by an inability to pass data... Seems a database reference may just be the only way to go, unless there's yet another way to reference the session?
  7. I have the session_start() in the original file, index.php. Just in case, I've just added it to the linegraphdrawer.php. It declared a new session, rather than plugging the existing one.
  8. Hey Freaks, I have created a .php file that creates a line graph. With variables declared inside that file, it draws the graph but I now need to pass data to it. After an earlier post $_SESSION seemed the way to go, but it doesn't appear to be visible inside that .php file. I use the file thus : print("<pre style='font-family:verdana;font-size:13'>"); print_r($_SESSION); print("</pre>"); print("<img src='".BASE."/basefunctions/maxgraphs/linegraphdrawer.php' alt='test'>"); and inside the function foreach ($_SESSION as $sesskey=>$sessval) { imagettftext($im, $linefontsize, 0, 200, 50, $black, $font, "TEST ".$sessval); } which breaks the file because, as far as I can tell, $_SESSION is empty. :-\ As far as I was aware, $_SESSION is variable to all functions called throughout the process... or is the <img> reference bypassing that? If so, how do I make the variable available inside the file? Kurrel.
  9. Hey Freaks, I have noticed that even if the first thing I declare is a coloured table, <table bgcolor='RED' width=100% height=100% cellspacing=0 cellpadding=0> that there is white space surrounding it. Is that a meta-table into which code-declared ones get placed, or a tag for the table I've declared that I'm not setting? I've looked through the tags on PHP help but none seems to do the job! Kurrel
  10. Databasing it or using the session, as needs, does seem to be the answer. The databasing is frustrating as regards 2d arrays but we'll see. Thanks for suggesting the alternatives.
  11. So using Session extensively is not a bad thing? I've been using it just to store user and 'logged on' details, thus far. I was taught a dislike for persistent variables. After setting the session variables, how would I destroy those variables without destroing that whole session and thus the user and duration variables previously stored (Apologies, my working knowledge of sessions is limited)? The number of variables could vary dramatically, from 3 or 4 to... width, height, 4 sets of 12 variables, 4 colours... maybe 100 pieces? If I can refine the functioning of these GD tools the range of use in my systems are extensive! AJAX graphs for our stocks, updating score boards for sales on the office flat overhead screens, etc.
  12. Hi freaks, I have been working with the gd functions in PHP to render an image. I was able to solve the (apparently) usual header problems and such like via searching through this page and help documentation, such that I am now able to produce an image by doing the following : print("<img src='".BASE."/basefunctions/sandbox/mydrawer.php' alt='drawertest'>"); which references a .php file with the following : <?php // get details { // Set 1 { $height = 400; $width = 750; $rows = 5; $barwidth = 15; $bargap = 10; $bar3d = 1; $barshadow = 0; $topval = 600; $bottomval = 100; $text = "My Drawer 1"; // } // } // Preparations { $maxheight = 0; foreach ($values as $divkey=>$divval) { foreach ($divval as $barkey=>$barval) { if($barval > $maxheight) { $maxheight = $barval; } } } // } // create image { $im = imagecreate($width+1, $height+1); // } // set style (colours, fonts, etc) to be used { // Font { $font = "verdana.ttf"; if($width < 200) { $linefontsize = 6; $headerfontsize = 10; } else if($width < 450) { $linefontsize = 8; $headerfontsize = 14; } else { $linefontsize = 10; $headerfontsize = 18; } // } // Colours { $white = imagecolorallocate($im, 255, 255, 255); //$bg = imagecolorallocate($im, hexdec('0x' . $colour{0} . $colour{1}), hexdec('0x' . $colour{2} . $colour{3}), hexdec('0x' . $colour{4} . $colour{5})); $bg = imagecolorallocate($im, 200, 200, 200); $black = imagecolorallocate($im, 0x00, 0x00, 0x00); $red = imagecolorallocate($im, 255, 0, 0); $yellow = imagecolorallocate($im, 255, 255, 0); $green = imagecolorallocate($im, 40, 150, 40); $blue = imagecolorallocate($im, 90, 90, 255); $colourlist = array("1"=>$green, "2"=>$yellow, "3"=>$red, "4"=>$blue, "5"=>$black); $barcolor = imagecolorallocate($im, 0xFF, 0x00, 0x00); // Fore colour // } // } // draw backdrop { //imagerectangle($im, 0,0,$width+1,$height+1,$black); imageline($im, 5, 0, $width-5, 0, $black); // Top imageline($im, 0, 5, 0, $height-5, $black); // Right imageline($im, $width, 5, $width, $height-5, $black); // Left imageline($im, 5, $height, $width-5, $height, $black); // Bottom imagearc($im, 4, 4, 10, 10, 181, 269, $black); // Top left imagearc($im, $width-4, 4, 10, 10, 271, 359, $black); // Top right imagearc($im, 4, $height-4, 10, 10, 91, 179, $black); // Bottom left imagearc($im, $width-4, $height-4, 10, 10, 1, 89, $black); // Top left // imagearc(resource, x, y, height, width, degree start, degree end, colour) imagefill($im, 20, 20, $bg); // } // Title { // Add show beneath text imagettftext($im, $headerfontsize, 0, 11, 21, $black, $font, $text); // Add text imagettftext($im, $headerfontsize, 0, 10, 20, $blue, $font, $text); // } // send image header and png image { header("content-type: image/png"); imagepng($im); imagedestroy($im); // } ?> This all works, the problem comes in now that I want to start expanding this to a useable object, possibly for drawing graphs or presenting data in a single downloadable image. I can pass data via print("<img src='".BASE."/basefunctions/sandbox/mydrawer.php&x=500' alt='drawertest'>"); and then using _GET... however, I hope there is a better way than this, as the URL becomes too long too quickly. I have with just a little expansion on the function already maxed out the maximum length of the URL. One thing I have also used is session variables, but that seems entirely messy... is it the way to go, or is there a better alternative? I don't know whether it is possible to post data to this .php file, but that would seem the best way to pass the number of variables I am planning on working with (x dimension, y dimension, several dozen coordinates, colour lists, etc). Hoping there's a smooth operator way to do this.
  13. While not quite the answer, what you posted ended up solving the problem by making me think a different way. I've read up on some inner join functions and restarted the whole affair. The premise of what I was doing was flawed, and the different format of joins means my data comes out as I need it, rather than needing to be further manipulated. Thanks!
  14. I have no control over the original MSSQL database. I am having to pull from it, not insert into. I tried to work the datediff statement into it. It compiles but then stops at the first run through the foreach loop.
  15. Hi everyone, I am writing a birthday input for a user management system. At this point in time the code looks like this print("<select style='width:40%;'>"); for ($day=1; $day < 32; $day++) { print("<option>"); print($day); print("</option>"); } print("</select>"); print("<select style='width:60%;'>"); for ($month=1; $month < 13; $month++) { print("<option>"); print(date("F", mktime(0, 0, 0, $month, 01, 2000))); print("</option>"); } print("</select>"); I don't like having the full 31 days for every month, including February and 30 day months. I am trying to develop an onchange for the month select that will repopulate the day select but can't find javascript functions that can (a) depopulate elements from a select and (b) insert elements into a select. So far, I've managed to get a hack by creating strings $28day, $30day and $31day of hardcoded text '<select><option>1</option>...</select> and replacing as needs, but it seems a truly clumsy and laborious workaround. Can anyone point me to commands for manipulating selects or to a cleaner workaround? ~Kurrel
  16. Hi everyone, I am tasked with ripping from an MSSQL database to then insert into a MYSQL database. In the process I want to display a date from each record on the page. The date is currently stored a Unix time stamp and I need to display it in hours:minutes day/month/year. Normally I'd use PHP to convert but I need to draw straight from the DB in as much detail as possible. Are there MSSQL commands for converting UNIX dates to string format and, if so, how may I use them? ~Kurrel
  17. Hi everyone, Is there an SQL query that pulls back a list of tables from the database? I am connected to the database I need to work with, but the table name we were supplied with is incorrect. I'm not sure if it's plural or just misspelt, but am sure the data table. ~K
  18. Thanks a bunch!! That worked a treat, and has resolved my issues. ~K PS : If you still want, I can post the code?
  19. Hi everyone, I'm using WAMP5 (1.6.6) for the first time, trying to do some small-time home development. This comes with Apache, MySQL and PHP5 all bundled together. I already develop for a PHP company, but everything's already set up in that arena and my problem is the 'getting everything going' phase. I've set up a database called 'testdb' with the SQLiteManager that comes bundled with the WAMP and written a query to fetch the data from a table 'testtable'. my query is '$query = "SELECT * FROM testtable WHERE 1=1";' and '$result = mysql_query($query) or die(mysql_error());'. On execution, I get 'Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\wamp\www\FirstRun\index.php on line 9 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\wamp\www\FirstRun\index.php on line 9 Access denied for user 'ODBC'@'localhost' (using password: NO)' I suspect it's a database selection problem and am going through notes to try remedy this myself... but if someone can answer in the time it takes me to fix it, I'd appreciate it! ~K
×
×
  • 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.