#garfield Logs
Dec 11 2022
#garfield Calendar
02:50 AM polprog: https://www.youtube.com/watch?v=QH2-TGUlwu4
07:56 PM BloodMoon: https://paste.debian.net/1263739/
08:05 PM rue_mohr: hey
08:06 PM BloodMoon: ;)
08:06 PM rue_mohr: polprog, are you ok?
08:06 PM rue_mohr: BloodMoon, ah!
08:07 PM BloodMoon: :D
08:07 PM rue_mohr: hmm
08:08 PM rue_mohr: you shouldn't need to parse out whitespace tho.. should you?
08:08 PM BloodMoon: dont think so.
08:09 PM rue_mohr: server runnig...
08:10 PM rue_mohr: how does that go
08:10 PM rue_mohr: localhost:7890/?
08:13 PM rue_mohr: cant connect to it, why?
08:16 PM rue_mohr: http://www.localhost.com:7890/
08:16 PM rue_mohr: wtf web browsers
08:16 PM rue_mohr: BloodMoon, you still here?
08:17 PM rue_mohr: why did it work and then do a redirect?
08:18 PM rue_mohr: I see what you mean tho, cute
08:18 PM rue_mohr: https://www.charset.org/url-encode
08:28 PM rue_mohr: I think you got de-allocated...
08:28 PM BloodMoon: back.
08:28 PM BloodMoon: localhost:7890
08:29 PM rue_mohr: it shows the page, then redirects to localhost.com for the unforsaken reason
08:29 PM BloodMoon: hmmm. never seen that before
08:30 PM rue_mohr: so, the question is, how complex can a php object be to stuff into json?
08:30 PM BloodMoon: no doubt. that is a question
08:32 PM rue_mohr: so, whats javascript code to print out a json object...
08:34 PM rue_mohr: [{"0":null,"title":null,"1":"0","childof":"0","2":"19","uidn":"19"},{"0":null,"title":null,"1":"0","childof":"0","2":"20","uidn":"20"},
08:34 PM rue_mohr: the database result is a mess
08:35 PM rue_mohr: each field is in there twice, once as a numberical index, then again as a named index
08:35 PM rue_mohr: I dont know how to remove the extra copy
08:36 PM BloodMoon: JSONstringify () or somehting
08:37 PM rue_mohr: so, I wonder how I pass it to the page
08:37 PM rue_mohr: the page is pretty simple
08:38 PM rue_mohr: maybe if I make a javascript variable in the page and assign that string to it?
08:38 PM BloodMoon: blah. innerHTML = JSONFuckifystrug();
08:38 PM rue_mohr: oh
08:38 PM rue_mohr: how can I put that in a .... <thing>
08:39 PM rue_mohr: thing.innerhtml
08:39 PM BloodMoon: getElementBYId("muydivID");
08:39 PM rue_mohr: div!
08:39 PM BloodMoon: <div id="mydivID">
08:39 PM BloodMoon: or image
08:39 PM rue_mohr: yea that
08:39 PM BloodMoon: or anything
08:40 PM BloodMoon: giv it an id atribute
08:41 PM rue_mohr: <div id="mydivID"></div>[{"0":null,"title":null,"1":"0","chi
08:41 PM rue_mohr: there is an option for a script tag, like
08:41 PM rue_mohr: execute on load or something
08:44 PM BloodMoon: yeah kinda
08:44 PM BloodMoon: something like document.page.onload()
08:45 PM rue_mohr: echo "<script>";
08:45 PM rue_mohr: echo "data = \"";
08:45 PM rue_mohr: echo $JSON;
08:45 PM rue_mohr: echo "\"";
08:45 PM rue_mohr: echo "</script>";
08:47 PM BloodMoon: not sure on what your doing exactly :P
08:47 PM rue_mohr: so, replace the inner html of mydivID with the json data as a string
08:48 PM rue_mohr: then later I'll parse it with json.parse
08:49 PM BloodMoon: seems a strange way.
08:49 PM rue_mohr: <body onload="fetchDB()">
08:49 PM rue_mohr: to run the javascript
08:49 PM rue_mohr: I just want to see if the json makes it to the other side
08:50 PM rue_mohr: so if I 'print' it by doing a text replace, then later parse it and have it printed out by javascript
08:50 PM rue_mohr: small steps?
08:51 PM BloodMoon: ok, man I need a phone call for all this BIZ
08:51 PM BloodMoon: i will call you in a bit
08:55 PM rue_mohr: <body onload="JSMain()>
08:56 PM rue_mohr: <body onload="JSMain()">
08:56 PM rue_mohr: <script> function JSMain() {
08:56 PM rue_mohr: data = '[{"0":null,"title":null,"1":"0","childof":"0","2":"19","uidn":"19"},{"0":null,"title":null,"1":"0","childof":"0","2":"20","uidn":"20"},{"0":null,"title":null,"1":"0","childof":"0","2":"21","uidn":"21"},{"0":null,"title":null,"1":"0","childof":"0","2":"22","uidn":"22"},{"0":null,"title":null,"1":"0","childof":"0","2":"23","uidn":"23"},{"0":null,"title":null,"1":"0","childof":"0","2":"24","uidn":"24"},{"0":null,"title":null,"
08:56 PM rue_mohr: 1":"0","childof":"0","2":"25","uidn":"25"},{"0":null,"title":null,"1":"0","childof":"0","2":"26","uidn":"26"},{"0":null,"title":null,"1":"0","childof":"0","2":"27","uidn":"27"},{"0":null,"title":null,"1":"0","childof":"0","2":"28","uidn":"28"},{"0":null,"title":null,"1":"0","childof":"0","2":"29","uidn":"29"},{"0":null,"title":null,"1":"0","childof":"0","2":"30","uidn":"30"},{"0":null,"title":null,"1":"0","childof":"0","2":"31","ui
08:56 PM rue_mohr: dn":"31"},{"0":null,"title":null,"1":"0","childof":"0","2":"32","uidn":"32"},{"0":null,"title":null,"1":"0","childof":"0","2":"33","uidn":"33"},{"0":null,"title":null,"1":"0","childof":"0","2":"34","uidn":"34"},{"0":null,"title":null,"1":"0","childof":"0","2":"35","uidn":"35"},{"0":null,"title":null,"1":"0","childof":"0","2":"36","uidn":"36"},{"0":null,"title":null,"1":"0","childof":"0","2":"37","uidn":"37"},{"0":null,"title":null,
08:56 PM rue_mohr: "1":"0","childof":"0","2":"38","uidn":"38"},{"0":null,"title":null,"1":"0","childof":"0","2":"39","uidn":"39"},{"0":null,"title":null,"1":"0","childof":"0","2":"40","uidn":"40"},{"0":null,"title":null,"1":"0","childof":"0","2":"41","uidn":"41"},{"0":null,"title":null,"1":"0","childof":"0","2":"42","uidn":"42"},{"0":null,"title":null,"1":"0","childof":"0","2":"43","uidn":"43"},{"0":null,"title":null,"1":"0","childof":"0","2":"44","u
08:56 PM rue_mohr: idn":"44"},{"0":null,"title":null,"1":"0","childof":"0","2":"45","uidn":"45"},{"0":null,"title":null,"1":"0","childof":"0","2":"46","uidn":"46"},{"0":null,"title":null,"1":"0","childof":"0","2":"47","uidn":"47"},{"0":null,"title":null,"1":"0","childof":"0","2":"48","uidn":"48"},{"0":null,"title":null,"1":"0","childof":"0","2":"49","uidn":"49"},{"0":null,"title":null,"1":"0","childof":"0","2":"50","uidn":"50"},{"0":null,"title":null
08:57 PM rue_mohr: ,"1":"0","childof":"0","2":"51","uidn":"51"},{"0":null,"title":null,"1":"0","childof":"0","2":"52","uidn":"52"},{"0":null,"title":null,"1":"0","childof":"0","2":"53","uidn":"53"},{"0":null,"title":null,"1":"0","childof":"0","2":"54","uidn":"54"},{"0":null,"title":null,"1":"0","childof":"0","2":"55","uidn":"55"},{"0":null,"title":null,"1":"0","childof":"0","2":"56","uidn":"56"},{"0":null,"title":null,"1":"0","childof":"0","2":"57","
08:57 PM rue_mohr: uidn":"57"},{"0":null,"title":null,"1":"0","childof":"0","2":"58","uidn":"58"},{"0":null,"title":null,"1":"0","childof":"0","2":"59","uidn":"59"},{"0":null,"title":null,"1":"0","childof":"0","2":"60","uidn":"60"},{"0":null,"title":null,"1":"0","childof":"0","2":"61","uidn":"61"},{"0":null,"title":null,"1":"0","childof":"0","2":"62","uidn":"62"},{"0":null,"title":null,"1":"0","childof":"0","2":"63","uidn":"63"},{"0":null,"title":nul
08:57 PM rue_mohr: l,"1":"0","childof":"0","2":"64","uidn":"64"},{"0":null,"title":null,"1":"0","childof":"0","2":"65","uidn":"65"}]';
08:57 PM rue_mohr: mydivID.innerHTML = data;
08:57 PM rue_mohr: } </script>
08:57 PM rue_mohr: oops
08:57 PM rue_mohr: it worked tho
09:00 PM rue_mohr: https://paste.debian.net/1263746/
09:19 PM BloodMoon: https://paste.debian.net/1263747/
09:26 PM rue_mohr: $result = GetAll( "SELECT * FROM schematics");
09:27 PM rue_mohr: $result = GetAll( "SELECT * FROM schematics");
09:27 PM rue_mohr: $JSON = json_encode($result);
09:28 PM rue_mohr: "0":null,"title":null
09:28 PM rue_mohr: ,"1":"0","childof":"0"
09:28 PM rue_mohr: ,"2":"65","uidn":"65"
09:29 PM rue_mohr: function GetAll( $sql ) {
09:29 PM rue_mohr: $result = array();
09:29 PM rue_mohr: global $db_conn;
09:29 PM rue_mohr: $query = pg_exec ($db_conn, $sql);
09:29 PM rue_mohr:
09:29 PM rue_mohr: while( ($data = pg_fetch_array ($query)) !== FALSE ) {
09:29 PM rue_mohr: array_push($result, $data);
09:29 PM rue_mohr: }
09:29 PM rue_mohr:
09:29 PM rue_mohr: return $result;
09:29 PM rue_mohr: }
09:30 PM rue_mohr: https://www.php.net/manual/en/function.pg-fetch-array.php
09:30 PM rue_mohr: pg_fetch_array() is an extended version of pg_fetch_row(). In addition to storing the data in the numeric indices (field number) to the result array, it can also store the data using associative indices (field name). It stores both indices by default.
09:32 PM rue_mohr: An optional parameter that controls how the returned array is indexed. mode is a constant and can take the following values: PGSQL_ASSOC, PGSQL_NUM and PGSQL_BOTH. Using PGSQL_NUM, the function will return an array with numerical indices, using PGSQL_ASSOC it will return only associative indices while PGSQL_BOTH will return both numerical and associative indices.
09:33 PM rue_mohr: while( ($data = pg_fetch_row ($query, mode = PGSQL_ASSOC )) !== FALSE ) {
09:35 PM rue_mohr: while( ($data = pg_fetch_row ($query, null, PGSQL_ASSOC )) !== FALSE ) {
09:42 PM rue_mohr: console.dir(object):