Welcome to Distributed Social Network Testing

Community

Waitman Gobble
5 hours ago
hmm the catholic girls i've been with are freaky, i can't imagine the person is implying the double negative is true?
J David Eisenberg
13 hours ago
Seen on Reddit:
Q: How does marriage between an Athiest man/woman work?
A: "I do," big party, cake, sexy time, honeymoon, more sexy time.
tony baldwin
2 days ago
Aha!. but yes!


Waitman wrote:
Click to open/close
also i recommend specifying the form action


That's it!

The form that is working had <form action="index.php" method="post">
and the other one did not!

Fixed and now working!

Thanks @Waitman Gobble
tony baldwin
2 days ago
I have forms on several other pages using $_POST, and they work fine, in fact, one of them on this page.
Also, all the configs for friendica plugins have $_POST, so that can't be it.
Waitman Gobble
2 days ago
I think that's it... the default method is GET so there's nothing in $_POST

also i recommend specifying the form action, i have a vague recollection about some browsers doing nothing without action - but that could be dated info.. anyway i just always do it anymore.

this seems to work:

<?php $q=$_POST['q']; foreach ($q as $k=>$v) { $q[$k]=htmlspecialchars($v); } echo ' <h4>Search</h4> <form method="post" action="test.php"> <input type="text" name="q[first_name]" size="15" value="'.$q['first_name'].'" /> First Name<br /> <input type="text" name="q[last_name]" size="15" value="'.$q['last_name'].'" /> Last Name<br /> <input type="submit" name="awfea" value="Submit" /> </form> '; ?>
Waitman Gobble
2 days ago
does a form default to 'post' method? i'm going to try, i can't remember. for some reason i think it defaults to GET and you won't get any data in $_POST. (i always use $_REQUEST anyway, lol)
tony baldwin
2 days ago
Yeah, I put in all the quotes around the variables in the form code.

No change in behavior, though.
tony baldwin
2 days ago
I have not used quotes on the table or column names on any other mysql query, so I don't think that's the problem.

I'm going to go look for missing quotation marks, now, but the pages load correctly, don't give any html or php errors.
I'm not sure, Tony, but from your copy-paste there are two things I noticed, but I haven't coded in years so allow me to be wrong. :-)

1. You are missing some quotation marks in your HTML, and this might cause trouble.
2. You could try to write your SQL query like this

$lquery = "SELECT * FROM `providers` WHERE `srclangs`='$slang'";
tony baldwin
3 days ago
I'm really stumped here.
tony baldwin
3 days ago
Why doesn't this work?
<h4>Search by language pair:</h4> <form> <input type=text name=slang size=10 value="source language"></input> <input type=text name=tlang size=10 value="target language"></input> <input type="hidden" name="lact" value="post"></input> <input type=submit name="lsubmit" value="Submit"></input> </form> <?php $lact = $_POST['lact']; if($lact == "post") { $slang = $_POST['slang']; $tlang = $_POST['tlang']; mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error()); mysql_select_db("$dbname") or die (mysql_error()); $lquery="SELECT * FROM providers WHERE srclangs = \"$slang\" and natlang=\"$tlang\""; $lresult = mysql_query($lquery); if(mysql_num_rows($lresult)==0) { echo "<h4>Search Results:</h4><p>no such provider...sorry</p>"; mysql_close(); } else { echo "<h4>Search Results:</h4><ul>"; while($row = mysql_fetch_assoc($lresult)) { $id = $row['id']; $name = $row['name']; $country = $row['country']; $email = $row['email']; $website = $row['website']; $natlang = $row['natlang']; $srclangs = $row['srclangs']; echo "<li>$name, $country, $srclangs to $natlang, <a href=\"mailto:$email\">$email</a>, <a href=\"$website\">$website</a>, <a href=\"editprov.php?name=$name\">edit $name</a>, <a href=\"listproj.php?name=$name\">list $name projects</a></li>"; } echo "</ul>"; mysql_close(); } }

There are two forms on the page, and the other search query works.
Each form has its own process, and the post and submit are named differently.
It doesn't seem to matter if I change the order.
If I put this query into a page by itself, in fact, it still doesn't give any result, either positive or negative, so here is my problem.
Also, a procedure very similar to this works on another page, the only difference being the query has no WHERE (just SELECT * FROM providers, but with the same while($row blah blah blah after it, listing all rows in the providers table thus).
Also, this gives no php syntax errors, and no errors show in /var/log/apache2/error.log pertinent to submission of the form for this query.
Also, I have tried the same query directly in mysql (SELECT * FROM providers WHERE srclangs = "$slang" and natlang = "$tlang";), and I get results.

Here, I get neither the "no such provider...sorry" message for 0 results, nor do I see the results. The page just reloads.
This is part of TransProCloud.

@Foss Hackers @Lazy Admin
Simon L'nu
4 days ago
/me args at short tags
Emmanuel Revah
4 days ago
@tony baldwin

In that case, before getting into arrays, perhaps you could break things down a big into tasks so you needn't reload the page, and do things an a more optimised order let's say for example:


// Deal with POSTed data first: if ($_POST) { // A user posted data -> check data, and update mysql // BTW, you may want to verify data and escape it too. } // Now simply get the data from the DB $query = "SELECT * FROM clients where name = \"$name\""; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { // You get the picture } // Display it using html echo "<h4>Client Links:</h4>; // etc etc // Display a form using the same variables that the user may want to edit/update // stop php and swithc to mostly html ?> <form action="editclient.php" method="post"> <input type="text" name="name" value="<? echo $name; ?>" /> <!-- etc etc --!>


hope this helps. : ]
Waitman Gobble
4 days ago
if you are using transactions is update/insert committed? just a thought. also maybe sticky form fields or cache, (?) :)
Thomas Willingham
4 days ago
We're very much a translation agency - I do proof reading, but actual translation is beyond me. If I was capable of actually translating stuff, I'd go to work more often and earn myself a decent income.

I use OpenERP for most stuff, but there's no reason I couldn't try this, and at least offer some constructive criticism.
tony baldwin
4 days ago
I just made a link, when user submits, a link appears
[code]<p>Client updated: <a href="editclient.php?name=$name">refersh page to verify result</a>.</p>[code]

You refresh the page, and the new values show.
But I find it weird, all the same.

Probably using arrays would be more efficient than what I'm doing...almost certainly, but, as I am a noob, I'm just getting the basics working, first. Then I will work on factoring the code and stuff. Maybe some other translator+hackers will take an interest in the project and work with me. Who knows...

I don't know too many hacker+translators, but we do exist. Most I know are working on OmegaT or Anaphraseus. We do have one within our ranks, being @Thomas Willingham . Or, at least, I do not know if he does translation work, himself, but I do know he runs a small LSP (Language Services Provider), so outsources such work, and a client/provider db with project management stuff might be of interest to him...hmmmm...
Emmanuel Revah
4 days ago
Tis looks like a classic issue regarding the order in which you are processing stuff. You might be retrieving vars from DB, then dealing with the new posted variables and then outputting the previous vars via html. Ajaxscript is not needed here. : ]


A method I use when doing php/mysql/html is separate in 2 parts:

1. Php/Mysql, do all the stuff that I need, put values into organised arrays etc etc.

2. Template the output -> use some php to get values from the above arrays and output to html.
tony baldwin
4 days ago
yeah, last night I fixed value=$name, etc., in the form. My initial question was about why the db data wasn't in the form, and that was, of course, why (doh).

It's weird how when I submit, after entering new values, the values revert, but if I refresh the page, the new values show. I probably need to work some ajax magic, or something.
Emmanuel Revah
4 days ago
<input type="text" name="name" value="<? echo $name; ?>" />
tony baldwin
4 days ago
Huh...it IS updating the DB, just not refreshing the data in the form.
tony baldwin
4 days ago
Oh, did that last night already, indeed.
So I am grabbing that.
while($row = mysql_fetch_assoc($result)) { $id = $row['id']; $name = $row['name']; $street = $row['street']; $city = $row['city']; $country = $row['country']; $zip = $row['zip']; $email = $row['email']; $website = $row['website']; $provsys = $row['provsys']; $notes = $row['notes']; $state = $row['state']; }
tony baldwin
4 days ago
ID is the auto-incremented whenever a row is added to the clients table, ah...but I did not set it above when grabbing that info.
Hmmm, but I was using "WHERE name = '$name'" and that wasn't working either.
But let me fix that with the id and see what happens.

[code]while($row = mysql_fetch_assoc($result)) {
//need to add this next line
$id = $row['id'];
$name = $row['name'];
$street = $row['street'];
$city = $row['city'];
$country = $row['country'];
$zip = $row['zip'];
$email = $row['email'];
$website = $row['website'];
$provsys = $row['provsys'];
$notes = $row['notes'];
$state = $row['state'];
}
Waitman Gobble
4 days ago
1) does $act = 'post' ?
2) where is $id set?
tony baldwin
4 days ago
Hmmm...I've got the data into the form, now, but when I submit the form, it does not update the table.

I've got
<?php $act = $_POST['act']; if($act == "post") { $name = $_POST['name']; $street = $_POST['street']; $city = $_POST['city']; $zip = $_POST['zip']; $state = $_POST['state']; $country = $_POST['country']; $website = $_POST['website']; $email = $_POST['email']; $provsys = $_POST['provsys']; $notes = $_POST['notes']; mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error()); mysql_select_db("$dbname") or die(mysql_error()); $query="UPDATE clients SET name='$name', street='$street', city='$city', country='$country', zip='$zip', email='$email', website='$website', provsys='$provsys', notes='$notes', state='$state' WHERE id = '$id'"; mysql_query($query) or die('Error, insert query failed'); mysql_close(); } ?>
tony baldwin
4 days ago
this is part of TransProCloud, which is slowly but surely coming together.

I have successfully made scripts to add the tables the db, and to add clients to the db, but having trouble getting the data into a form to edit a client entry.
tony baldwin
4 days ago
why data from db doesn't populate form?
In this:

<?php // this name var is set in the url, coming to page from link set on another page // like $url/editclient.php?name=$name. that much works $name = isset($_GET['name']) ? htmlentities($_GET['name']) : false; mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error()); mysql_select_db("$dbname") or die(mysql_error()); if (isset($name)) { $query = "SELECT * FROM clients where name = \"$name\""; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $name = $row['name']; $street = $row['street']; $city = $row['city']; $country = $row['country']; $zip = $row['zip']; $email = $row['email']; $website = $row['website']; $provsys = $row['provsys']; $notes = $row['notes']; $state = $row['state']; } // here, I'm getting the links I want, so I know I'm getting the data from the db echo "<h4>Client Links:</h4> <ul><li>website: <a href=\"$website\">$website</a></li> <li>provider portal: <a href=\"$provsys\">$provsys</a></li> <li>projects: <a href=\"$url/projects/clist.php?name=$name\">$name projects</a></li> </ul>"; mysql_close(); } else { echo "<p>You have not made a valid query.</p>"; echo "<p>return to <a href=\"$url\">home</a> or <a href=\"$url/clients/\">clients</a></p>"; } ?> <!-- but the variables do not appear in the form...why? --!> <h4>Edit Client:</h4> <form action="editclient.php" method="post"> <input type=text name=name value="client name"></input> <input type=text name=street value="street name"></input> <input type=text name=city value="city"></input> <input type=text name=state value="state or province"></input> <input type=text name=country value="country"></input> <input type=text name=zip value="zip or postal code"></input> <input type=text name=website value="website"></input> <input type=text name=email value="email"></input> <input type=text name=provsys value="provider portal"></input> <input type=text name=notes size=100 value="notes"></input> <input type="hidden" name="act" value="post"></input> <input type=submit name="submit" value="Submit"></input> </form>

I set $name in the url, ($url/editclient.php?name=$somename), and that works, because I'm getting the links I want in the top part.
But, I expect the form to be populated with the same data, and it isn't.
Why?

I know this is a little different, but in others when I include a file, clearly, I can get data from said file into a form in similar fashion,
but why not from querying the db to set the variables?
Or, clearly, from the top part, I AM setting the variables from the dbquery...so why do they not populate the form?

@Foss Hackers
#php #mysql
Michael Große
5 days ago from Links
Dieser Palmer nervt. Wenn es schon eine 3er Koalition im Bund geben muss, dann doch eher mit SPD+Linken oder SPD+Piraten, aber nicht mit dieser FDP.
SMH

Verhältnis zur SPD: Grünen-Politiker Palmer greift Parteichefin Roth an - SPIEGEL ONLINE on Spiegel
www.spiegel.de

In NRW reichte es für Rot-Grün zur gemeinsame Mehrheit - aber klappt das auch bei der Bundestagswahl? Bei den Grünen sorgt diese Frage für heftige Differenzen: Realo-Kopf Palmer greift Parteichefin Roth an, weil sie die Grünen im Bündnis mit der SPD einmauern würde.

Image/photo
Image/photo  
tony baldwin
1 week ago
Oh, and to view .djvu, I use Djview4 (get it from http://djvu.sourceforge.net or, it's in debian repos).
They can also be viewed with evince.
I can also view them in my browser; the FF plugin comes with djview4.
tony baldwin
1 week ago
elinks also supports gopher.
w3m does not apparently (just tried)
tony baldwin
1 week ago
I use the command line gopher client to view gopher, primarily. Lynx also supports gopher, and, if all else fails, you can use the Over-Bite FF plugin to view gopher in firefox or seamonkey.
michael_md
1 week ago
I'm sure I remember browsing a gopher site with Firefox only a couple of years ago ... looks like they dropped support for it since then
Rove Monteux
1 week ago
Tons of stuff in this one too,

gopher://gopher.std.com/11/The%20Online%20Book%20Initiative

Rove Monteux
1 week ago
Just using Veronica 2 now as well, not only Netscape uses half the memory of any other modern browser, as the gopher content, including massive text files, jump in the screen in seconds - and I also found there lots of interesting stuff, and not only in English, but also in German.
Bob Mottram
1 week ago
Interesting. The last time I used gopher was approximately 1995. I'm tempted to add some gopher content to my web site.
Rove Monteux
1 week ago
I'm using Tony's gopher with Netscape 9 for Mac, it is actually quite nice to use, that and a newsreader and I am sorted really.

gopher://tonybaldwin.me/0/whygopher

4) Nobody is policing the gophersphere like they are the Internet.

You can possibly publish it as a Tor Hidden Service, will be just as fast, and well, as no one knows where is it in the first place unless they get clues for an investigation about the person running it, it is pretty much impossible to shut it down, and does not matter what is in it really.
Paul Taylor
1 week ago
@tony baldwin What piece of software are you using to view #djvu?
michael_md
1 week ago
lynx still fetches it but doesn't look like it renders properly
michael_md
1 week ago
when did browsers stop supporting gopher?
(gopher link didn't work in Chrome, Firefox, Opera or IE!)
tony baldwin
1 week ago
And, among many reasons why DjVu is superior to pdf, epub, and other file formats, just look at this:


full size

Do you see that left column?
You can navigate the book by the table of contents. You can see thumbails of each page, and you search the text.

And the djvu weighs less than half.
The pdf file of this book is 26mb.
The djvu is only 9mb.

http://djvu.sourceforge.net
tony baldwin
1 week ago
What happens if I use a url tag with a gopher link? Let's see:

Debian Handbook, Gopher Version
tony baldwin
1 week ago
The Debian Administrator's Handbook can also be read

over #gopher
gopher://tonybaldwin.me/1/library/debhandbook.txt

and as #djvu

http://tonybaldwin.me/books/debian-handbook.djvu
tony baldwin
1 week ago from fren.tcl
Debian Administrator's Handbook
Read the Debian Administrator's Handbook online

Written by two Debian developers — Raphaël Hertzog and Roland Mas — the Debian Administrator's Handbook started as a translation of their French best-seller known as Cahier de l'admin Debian (published by Eyrolles). It's a fantastic resource for all users of a Debian-based distribution. Accessible to all, this book teaches the essentials to anyone who wants to become an effective and independant Debian GNU/Linux administrator.
It covers all the topics that a competent Linux administrator should master, from the installation and the update of the system, up to the creation of packages and the compilation of the kernel, but also monitoring, backup and migration, without forgetting advanced topics like SELinux setup to secure services, automated installations, or virtualization with Xen, KVM or LXC.

Buy a hard copy



This
(and don't forget to see who contributed! Hmmm...indeed, that Anthony Baldwin of Baldwin Linguas mentioned does look familiar...I learned a lot working on this project, and had fun, too.)

#debian #sysadmin
@Lazy Admin @Linux-Group @Foss Hackers
tony baldwin
1 week ago
got it
preg_match('/"site_id":(\d+)/', $result, $matches); $siteid = $matches[0];

with help from Wiseguy on stackoverflow.

With the caveat, of course, that this returns the FIRST site_id in the json response.
If a user has multiple sites, this might not be the data they want...

For most users with a single, personal posterous, this is sufficient.