Search found 19 matches

by KenHorse
Fri Mar 23, 2018 3:20 pm
Forum: mySQL & php coding
Topic: Help with INNER JOIN and aliases
Replies: 1
Views: 1053

Help with INNER JOIN and aliases

I'm taking over existing code from someone else but I am kind of a newbie with MySQL. Not a complete newbie but not overly experienced either. One of the php files calls a database table named "config" and loads a webpage with the info, using the following code: SELECT m.sub , m.cdata , m.descriptio...
by KenHorse
Sat Aug 05, 2017 1:12 pm
Forum: PHP coding => General
Topic: Looking for a simple timer, so why doesn't this work?
Replies: 4
Views: 1091

Re: Looking for a simple timer, so why doesn't this work?

Thanks for the info (which of course fixed the problem!)

As for the 59 second rollover issue, I'm aware of that issue. Now that I can get the result from my code that I need, onward and upward!
by KenHorse
Fri Aug 04, 2017 6:28 pm
Forum: PHP coding => General
Topic: Looking for a simple timer, so why doesn't this work?
Replies: 4
Views: 1091

Re: Looking for a simple timer, so why doesn't this work?

It's a simple elapsed timer I want to use for incoming (via serial port) timeout. For example if no data is received within 4 seconds, abort. So my code was to try the concept of using date(s) as a simple seconds timeout Here's what I get when I run it. I don't see the error causing the results root...
by KenHorse
Fri Aug 04, 2017 2:22 pm
Forum: PHP coding => General
Topic: Looking for a simple timer, so why doesn't this work?
Replies: 4
Views: 1091

Looking for a simple timer, so why doesn't this work?

Code: Select all

$start = intval(date(s));
echo "Start " . "$start\r\n";
Sleep(1.0);
$stop = intval(date(s));
echo "Stop " . "$stop\r\n";

echo "Elapsed time is " . $stop - $start . "\r\n";
by KenHorse
Tue Jun 27, 2017 12:41 pm
Forum: PHP coding => General
Topic: 4 bytes to float (single)
Replies: 1
Views: 646

4 bytes to float (single)

Take the following 4 bytes, stored in the order shown: 0, 0, 220, 66 The above bytes represent the number 110.0, stored as (from the compiler I use for embedded processor work) as a "single", which they define as a "signed 32 bit binary number". I take that to be the same as a float How can I conver...
by KenHorse
Mon Jun 26, 2017 5:02 pm
Forum: PHP coding => General
Topic: Exracting the high and low nibble of a byte
Replies: 2
Views: 1107

Re: Exracting the high and low nibble of a byte

The use of this is to store two bytes (each one is never greater than a value of 15) into the space of one byte in memory. I did find my problem however - as I took this code over from someone else, they neglected to tell me it was used to store DTMF digits so any DTMF digit > 0 needed to be convert...
by KenHorse
Fri Jun 16, 2017 7:11 am
Forum: PHP coding => General
Topic: Exracting the high and low nibble of a byte
Replies: 2
Views: 1107

Exracting the high and low nibble of a byte

Take the following code that reads in the following lines from a text file: 1,161 2,169 3,1 4,0 5,117 Each value after the comma is a byte that contains 2 bytes (with a value of 0 - 15) that were stored by shifting a 1st byte to the left. You get the idea... $myfile = fopen("test.mem", "r") or die("...
by KenHorse
Tue Jun 13, 2017 6:48 am
Forum: PHP coding => General
Topic: Why doesn't this work under PHP 7?
Replies: 2
Views: 758

Re: Why doesn't this work under PHP 7?

Duh......thanks so much! Amazing what a 2nd set of eyes will see!
by KenHorse
Mon Jun 12, 2017 7:00 pm
Forum: PHP coding => General
Topic: Why doesn't this work under PHP 7?
Replies: 2
Views: 758

Why doesn't this work under PHP 7?

Code: Select all


<?php

$sub = "12";
if(strlen($sub < 3)){$sub = "0" . $sub;}
echo "$sub\r\n";
?>
I'd expect the result to be 012 but it's 12
by KenHorse
Tue Jan 26, 2016 8:21 am
Forum: JavaScript
Topic: $.get call not working
Replies: 2
Views: 1496

Re: $.get call not working

Console shows:
ReferenceError: myFunction is not defined
(MyFunction is defined correctly, yes?)

Networks does show the call
by KenHorse
Mon Jan 25, 2016 5:01 pm
Forum: JavaScript
Topic: $.get call not working
Replies: 2
Views: 1496

$.get call not working

The python script works fine and should return HTML. I don't see the output of the python script on the calling HTML page. <HEAD> <link rel="stylesheet" type="text/css" href="stylesheet.css"> </HEAD> <body style="text-align:center" onload="myFunction()"> <H3>Your firmware is being loaded. Please sta...
by KenHorse
Tue Jan 12, 2016 3:51 pm
Forum: JavaScript
Topic: Why doesn't this call the php file I think it should?
Replies: 5
Views: 2839

Re: Why doesn't this call the php file I think it should?

doesn't make a difference but good catch!
by KenHorse
Tue Jan 12, 2016 8:05 am
Forum: JavaScript
Topic: Why doesn't this call the php file I think it should?
Replies: 5
Views: 2839

Re: Why doesn't this call the php file I think it should?

None. It just doesn't seem to load the called file
by KenHorse
Mon Jan 11, 2016 4:33 pm
Forum: JavaScript
Topic: Why doesn't this call the php file I think it should?
Replies: 5
Views: 2839

Why doesn't this call the php file I think it should?

This is just test of something but it should work, right? (yes, jquery.js in the same directory as this php file. And this is also on Linux if that matters) <script src="jquery.js"></script> <script> function myFunction() { $.GET("otherphpfile.php"); return false; } </script> <?php print" <script> m...
by KenHorse
Sat Jan 02, 2016 2:39 pm
Forum: PHP coding => General
Topic: Reading serial port doesn't work if called from function
Replies: 3
Views: 853

Re: Reading serial port doesn't work if called from function

Ahhh.. I think I get it now. The following seems to work ok <?php include "php_serial.class.php"; $serial = new phpSerial; $serial->deviceSet("/dev/ttyS0"); $serial->confBaudRate(9600); $serial->confParity("none"); $serial->confCharacterLength(8); $serial->confStopBits(1); $serial->deviceOpen(); che...
by KenHorse
Sat Jan 02, 2016 2:07 pm
Forum: PHP coding => General
Topic: Reading serial port doesn't work if called from function
Replies: 3
Views: 853

Re: Reading serial port doesn't work if called from function

Ahh I see, thanks Now let's take this a step further. When using the php_serial.class, the following doesn't work: <?php include "php_serial.class.php"; $serial = new phpSerial; $serial->deviceSet("/dev/ttyS0"); $serial->confBaudRate(9600); $serial->confParity("none"); $serial->confCharacterLength(8...
by KenHorse
Sat Jan 02, 2016 1:01 pm
Forum: PHP coding => General
Topic: Reading serial port doesn't work if called from function
Replies: 3
Views: 853

Reading serial port doesn't work if called from function

I posted about having problems calling a class from within a function a few weeks ago. As it turns out, the problem seems to be more that of accessing hardware from a function. The following code DOES echo the value of read /dev/ttyS0 for me (Debian): <?php $read= fopen("/dev/ttyS0", "r") or die("Un...
by KenHorse
Sat Dec 26, 2015 5:00 pm
Forum: PHP General
Topic: Calling a class from a function?
Replies: 2
Views: 896

Re: Calling a class from a function?

My experience in programming has been mostly VB and I'm used to using sub routines for often used operations (such as reading and writing to a physical device such as a serial port). The class I'm using (php_serial.class.php) is used to communicate with a serial port and I need to have many repetiti...
by KenHorse
Sat Dec 26, 2015 12:25 pm
Forum: PHP General
Topic: Calling a class from a function?
Replies: 2
Views: 896

Calling a class from a function?

I'm having problems with the below code in that if I call the class from a function, it doesn't work. However if I comment out the function call and call the class from the code directly (you can see the commented out call), it does indeed send out the correct stuff to the serial port. Is it a matte...