Jump to content

Kurrel

Members
  • Posts

    70
  • Joined

  • Last visited

    Never

Everything posted by Kurrel

  1. I found that it might be possible to use fopen to access the port directly, but I don't think my linux knowledge is up to the task. I get the following : "Warning: fopen(/dev/ttyS1) [function.fopen]: failed to open stream: Permission denied in /var/www/LinuxTest/tindex.php on line 89" It's progress, and I'm trying to find out if there's further headway here or if I'm going the wrong way. Any help appreciated!
  2. Hi everyone, I built a nifty code set that took a reading from a scanner and fed it into a database... this worked great, until I found the server was Linux (Ubuntu) and the code I was using would not co-operate on that. Is there any way to open the browser and click a button, having the local machine access it's com port 1 and read data from the device connected before feeding that back to the central database? Essentially, a web-driven monitoring system.
  3. Blast! I don't suppose you know any alternatives that can get details from a serial port, that would then work on Linux?
  4. Will simply renaming it work? What would the command then be to use it in the php.ini? 'extension=php_ser.so'? hardly seems likely, or is it just rare?
  5. Further information : The file in question is 'extension=php_ser.dll'. Are .dll files absolutely unique to windows, or is there a way to implement it in Linux?
  6. Hi everyone, Is there any way to get a windows extension located in the php/ext directory of my php to run off the linux side I'm trying to migrate to?
  7. That got me on the right track! My understanding was a little mistaken on the manner in which joins are done, but seeing a working version got me going. This is what the sql query eventually ended up being : SELECT tlist.tagid AS tagid, MAX( slist.date) AS date FROM taglist AS tlist LEFT JOIN tagscans AS slist ON slist.tagid=tlist.tagid GROUP BY tlist.tagid The MAX function was also new to me. Thank you very much!
  8. Hi everyone, I've created a report that displays a list of tags and their last read-time. The list of tags is kept in table 'taglist' while the reads are in a table 'tagscans'. The primary key, 'tagid' of 'taglist' is the foreign key of 'tagscans'. The current way I'm doing it is to pull the list of tags from 'taglist' and then, inside a foreach loop, pulling the most recent scan with a second SQL query. I am almost certain that this process can be reduced to a single joined SQL query, but my efforts so far have resulted in records in 'taglist' that do not have any related records in 'tagscans' not appearing. I need all the records in 'taglist' and the single, most-recent record (if any) related in 'tagscans'. My current SQL query, that drops the unmatched records, SELECT * FROM taglist JOIN tagscans ON taglist.tagid=tagscans.tagid EDIT : I originally started with a LEFT JOIN from taglist to tagscans, believing it would pull the full list therein regardless of tagscans contents... same problem as above. I've tried searching the forum but my search-fu has not revealed a relevant thread, just lots of interesting reading. The darn thing works the long-way around, but I'm sure it can work better this way!
  9. Hi everyone, I have been given a receiver that (so far ) outputs data to Hyperterminal (9600Bps 8bits) on Com port. What I've been asked is whether I can make it so that PHP or, indeed, any workaround can be found so that a system can read this as an ID and interact with a DB on a case-by-case reading. The device reads the ID from the tag, then dumps it to Hyperterminal. At best I'd like to have an applet or system running that dumps it to an HTTP reference that has the tag id inset (http://test.com/index.php?mode=test/index&action=test&id=1010101010). I'm searching for wrappers and data feed tutorials but hope that someone here knows of such or even that PHP has commands for such a thing. Any pointers, info, clue-by-fours?
  10. Hi everyone, I've got a list of input boxes into which only numeric values and a decimal point should be allowed. I've managed to get what the key being pressed is, but exactly how to disallow it seems to be eluding me. Returning false on the event doesn't stop the keypress. What would you recommend in order to stop this? (Or, more easily, is there a input type I am unaware of that already fills this role?)
  11. What format is your time stored in the column?
  12. Okay, that should mean that the function get_games returned an array of data to the variable 'getgames'. Try this include('functions.php'); $getgames = get_games(); print("<pre>"); print_r($getgames); print("</pre>"); $temps = array( 'GAMESLIST' => $getgames ); print("<pre>"); print_r($temps); print("</pre>"); $file = "themes/default/index_body.tpl"; $setindex = set_template($file, $temps); print("<pre>"); print_r($setindex); print("</pre>"); echo $setindex; This won't fix the code but will show you the data structure you've pulled back into the variables 'getgames', 'temps' and 'setindex'. I'm not certain what set_template function does, but you should have an array of all the results passed from one variable to the next, from there you can write a foreach loop and display the data. If 'setindex' is a 2d array, foreach ($setindex as $sikey=>$sival) { print($sival."<br>"); } should work, otherwise try foreach ($setindex as $sikey=>$sival) { foreach ($sival as $singlekey=>$singleval) { print($singleval); } print("<br>"); }
  13. Thank you. I'm going to set the topic as solved because, despite remaining curious, the original problem is finished.
  14. Using $_SESSION works, bit of an akward workaround though. I am still wondering why the form and hidden variables only exist after some text has been printed by the function. If I don't print anything, the form doesn't submit and the data isn't prepped.
  15. Hey everyone, I have a system wherein different scores can be entered by month. The details for the selected month are displayed, and with a calendar box or by left and right arrows the user can move the form to different months. I've done this via resubmitting on-clicks that load $_POST with the desired month and year. When details are entered and the 'Save' button is pressed, javascript changes the form action to another PHP function and then submits the page. In this function, CommitScores function commitScores() { if($_POST["conf"]) { $conf = $_POST["conf"]; } $data["month"] = $conf["month"]; $data["year"] = $conf["year"]; $data["deptid"] = $conf["deptid"]; if($conf["deptid"] > 0) { foreach ($conf["scores"][$conf["deptid"]] as $scorekey=>$scoreval) { $data["catid"] = $scorekey; $data["score"] = $scoreval; clearScore($data); createScore($data); } } print("<form id=postform action='index.php?mode=test/index&action=scoresys' method=post>"); print("<input name=conf[month] value=".$conf["month"].">"); print("<input name=conf[year] value=".$conf["year"].">"); print("<input name=conf[deptid] value=".$conf["deptid"].">"); print("<pre style='font-family:verdana;font-size:13'>"); print_r($conf); print("</pre>"); print("</form>"); // JavaScript { print("<script> document.getElementById('postform').submit(); </script>"); // } } It removes the old score and enters the new one... and is then meant to return the scoresys function and display that month and year with the the new scores. I can just redirect to that function, but it returns to the default month and year (Last month, this year) whereas I need it to be the recently edited one. This way works, but only if I print something to the screen (in this case, the <pre>$conf set). I suspect this is because of headers, but stand to be corrected. If I don't print something, the $_POST is not loaded, not does the form submit, leaving the user on a blank page after the DB stuff is done. It's not slick to have to print text in a back-end function between submissions and I'm hoping there's another way to load $_POST and return it to the original function.
  16. You've taken quite a different tack, but I think I can see what might be the cause. Original Code function get_games(){ $query = mysql_query("SELECT gameID,gameTitle,gameDescription FROM games ORDER BY gameID"); while($fetch=mysql_fetch_array($query)){ $gameID=$fetch["gameID"]; $gameTitle=$fetch["gameTitle"]; $gameDescription=$fetch["gameDescription"]; $temps = array( 'GAMEID' => $gameID, 'GAMETITLE' => $gameTitle, 'GAMEDESC' => $gameDescription ); $buildtemp = file_get_contents("themes/default/game_list.tpl"); foreach($temps as $template_var => $replacement_var){ $buildtemp = str_replace($template_var, $replacement_var, $buildtemp); } return $buildtemp; } } You're filling buildtemp with the details of one record, and then returning it. Here's my take on it. function get_games(){ $query = mysql_query("SELECT gameID,gameTitle,gameDescription FROM games ORDER BY gameID"); while($fetch=mysql_fetch_array($query)){ $gameID=$fetch["gameID"]; $gameTitle=$fetch["gameTitle"]; $gameDescription=$fetch["gameDescription"]; $temps = array( 'GAMEID' => $gameID, 'GAMETITLE' => $gameTitle, 'GAMEDESC' => $gameDescription ); $buildtemp = file_get_contents("themes/default/game_list.tpl"); foreach($temps as $template_var => $replacement_var){ $data[] = str_replace($template_var, $replacement_var, $buildtemp); } } return $data; }
  17. Wuhtzu illustrated the point perfectly. Expanding on it in your example, you could do the following (If I'm reading you right) include.php <?php function pull_games($where) { $sql = "SELECT * FROM games_table WHERE ".$where; if ($resultset = mysql_query($sql)) { while ($line = mysql_fetch_array($resultset, MYSQL_ASSOC)) { $key = ""; $key = $line["id"]; $resultlist[$key] = $line; } return $resultlist; } else { echo 'Error pulling from SQL Database: ' . mysql_error() . "\n"; } } ?> The above should query a database and return the results to the caller through $resultset. And then in code.php <?php include('include.php'); echo "Games List"; $gameslist = pull_games("1=1"); ?> $gameslist will then have all the results in it, and you can display it's contents in-function rather than through include.php. Just use a foreach and run through the array to spew the data.
  18. At first glance, it appears you need to precede the dollar symbol with a \. I think what's happening is that it's seeing that price as a newly declared PHP variable without any data in it.
  19. I was able to solve this by creating a .png file and writing all the graphics to it, using a passed name as well. In the next line of the calling function I presented the <img> with the name that had been sent through to the graphdrawing class functions. I am able to bypass the head issues this way and it's been clean sailing thus far.
  20. Okay. I know that I need to prepare or create the gd resource before or outside the headers. I think that classes could be used to do it, but I cannot figure out how to do this via PHP. I believe it an be allocated to a object resource, but I have not been able to create that effect. What I have is a working piece of code that I want to expand on but cannot. Several tutorials have referenced what to do inside the php file, but not then how to call it leaving me in the same boat I was in when I could call it but not pass data to it. I don't want to give up on developing my own understanding of PHP graphics and graphing, but I cannot make further progress myself. I would appreciate even a new tutorial that is clearer than the ones I have been able to find as I begin to believe there is a flaw in my understanding that I cannot grasp.
  21. By wrapping the linegraphdrawer.php in this <?php class drawlinegraph { function drawLineGraph($data) { I am able to pass data, and get the spewed image in ascii by commenting out //header("content-type: image/png"); I feel I'm close, and if I can just work the data and header / image drawing apart into different classes, I might meet with success. Please, help.
  22. Hi Freaks, I've tried to figure this one out through asking pertinent questions and reading up on material as much as possible but I have run up against a brick wall around which my experience cannot get me. Here is the whole sale file linegraphdrawer.php : <?php // get details { // Set 1 { $values[1]["Jan"] = 500; $values[1]["Feb"] = 200; $values[1]["Mar"] = 260; $values[1]["Apr"] = 330; $values[2]["Feb"] = 210; $values[2]["Mar"] = 330; $values[2]["Apr"] = 340; $values[2]["May"] = 320; $values[2]["Jun"] = 280; $values[2]["Jul"] = 285; $values[3]["Jan"] = 295; $values[3]["Feb"] = 130; $values[3]["Mar"] = 240; $values[3]["May"] = 220; $values[3]["Jun"] = 180; $values[3]["Jul"] = 200; $values[4]["Jan"] = 205; $values[4]["Feb"] = 150; $values[4]["Mar"] = 245; $values[4]["Apr"] = 280; $values[4]["May"] = 310; $values[4]["Jun"] = 360; $values[4]["Jul"] = 415; $baselinevalues[] = "Jan"; $baselinevalues[] = "Feb"; $baselinevalues[] = "Mar"; $baselinevalues[] = "Apr"; $baselinevalues[] = "May"; $baselinevalues[] = "Jun"; $baselinevalues[] = "Jul"; $baselinevalues[] = "Aug"; $height = 400; $width = 750; $rows = 5; $barwidth = 15; $bargap = 10; $bar3d = 1; $barshadow = 0; $topval = 600; $bottomval = 100; $text = "Line Graph Example 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); // } // Behind-the-scenes data { /* imagettftext($im, $linefontsize, 0, 350, 25, $black, $font, "Topval : ".$topval.", Bottomval : ".$bottomval); imagettftext($im, $linefontsize, 0, 350, 40, $black, $font, "Graph height : ".$height); */ $basecount = count($baselinevalues)+1; // The number of lines, + 1 so a row set is not presented at the final coordinate of x; $valrange = $topval - $bottomval; // The range of values, as from least (bottom of graph) to most (top of graph) $ratio = $height / $valrange; $difinc = round(($width / $basecount), 2); // The pixel increment between each division of $baselinevalues; // } // Draw dividing lines { $valinc = ($topval - $bottomval) / $rows; // The value increment between each line; $pixinc = $height / $rows; // The pixel increment between each line; //imagettftext($im, $linefontsize, 0, 350, 80, $black, $font, "Rows : ".$rows.", Valinc : ".$valinc.", Pixinc : ".$pixinc); for ($linecount=0; $linecount < $rows; $linecount++) { $linepos = $height - (($linecount * $pixinc)); $linetext = ($linecount * $valinc) + $bottomval; imagettftext($im, $linefontsize, 0, 5, ($linepos-1), $black, $font, $linetext); if($linecount != 0) { imageline($im, 0, $linepos, $width, $linepos, $black); } } // } // Draw the base values across the graph bottom { $basecount = 1; foreach ($baselinevalues as $basekey=>$baseval) { imagettftext($im, $linefontsize, 0, $basecount*$difinc, ($height - 1), $black, $font, $baseval); $basecount++; } // } // { if($_REQUEST) { imagettftext($im, $linefontsize, 0, 400, 20, $black, $font, "TEST"); $reqcount = 2; foreach ($_REQUEST as $reqkey=>$reqval) { imagettftext($im, $linefontsize, 0, 400, ($reqcount*20), $black, $font, "TEST ".$reqkey." ".$reqval); $reqcount++; if($reqkey=="test") { $blahcount = 150; //foreach ($reqval as $rkey=>$rval) { imagettftext($im, $linefontsize, 0, 400, $blahcount, $black, $font, "TEST"); $blahcount += 20; //} } } } // } // draw the data lines { //imagettftext($im, $linefontsize, 0, 600, 20, $black, $font, $basecount." ".$difinc); $linecount = 1; foreach ($values as $linekey=>$lineval) { $oldx = "x"; $oldy = "x"; $pointcount = 1; foreach ($baselinevalues as $pointkey=>$pointval) { if($lineval[$pointval]) { $ypos = $height - (($lineval[$pointval] - $bottomval) * $ratio); $xpos = $pointcount*$difinc; imagefilledarc($im, $xpos, $ypos, 7, 7, 1, 360 , $colourlist[$linecount], IMG_ARC_PIE); if($oldx != "x") { imageline($im, $oldx, $oldy, $xpos, $ypos, $colourlist[$linecount]); } $oldx = $xpos; $oldy = $ypos; } else { $oldx = "x"; $oldy = "x"; } $pointcount++; } $linecount++; } // } // 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); // } ?> It works, but that is the sum of it. I cannot pass any data to it except via the URL and $_GET, which is too short if I am to pass even a few sets of 12, along with dimensions. It cannot view sessions, as it is not included, nor $_REQUEST. If I write it to database and pass the reference, the attempt at pulling data throws the code... possibly because it sends a header to the DB. I have run through what I feel I can do, and if anyone can help by making it work for them and explaining how, I would be very grateful.
  23. Utterly perfect! The first part did the trick, the only real reason I made the bg red was to make sure myself that I wasn't imagining it was there. Thanks a bunch.
  24. Still has the white bit around it. Even if the sum total of my php is <?PHP print("<table width=100% height=100% bgcolor='RED' cellspacing=0 cellpadding=0 style='margin:0px; padding:0px;'>"); print("<tr><td>"); print("TEST"); print("</td></tr>"); print("</table>"); ?> !
  25. If by this you mean print("<img src='".BASE."/basefunctions/maxgraphs/linegraphdrawer.php?a=".$_SESSION["blah"]."' alt='test'>"); I can only extend it so far... if I'm drawing a graph comparing 6 data sets across a year thats 72 variables before I've even passed the actual graph details. The string length passable in the URL becomes a problem.
×
×
  • 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.