|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On July 25 2013 05:54 Yoshi- wrote:Show nested quote +On July 25 2013 05:44 tofucake wrote: There are a bunch of php websocket libraries. socketo.me is probably the most well known. And even without that PHP still supports sockets (I made a bnet bot in php+ajax almost a decade ago). Yea I know I already realized that and removed that part. Show nested quote +On July 25 2013 05:43 fdsdfg wrote:
Isn't google chat (chat from the gmail web interface) done using ajax? Just did a quick check doesn't look like ajax, or at least the firebug console doesn't show any ajax request that could be related to it. Yea, they use long polling or httpstreaming for it: http://stackoverflow.com/questions/2440135/is-long-polling-the-most-efficient-way-to-create-a-web-real-time-app/2440150#2440150They arguably uses "Ajax", but not the same way how OP does Google Talk uses comet/long-polling/whatever you want to call it, and believe it or not, this *is* AJAX and its not really arguable Google Talk's usage of long-polling should by no means be seen as an endorsement of long-polling, as there are many factors at play in why they chose it, almost none of which probably apply to any personal project. Certainly websockets or server-sent events are more well-suited, if you don't need to support older browsers.
|
On July 25 2013 13:45 Fawkes wrote:Let me rewrite this to the simplest way possible. $sql = "select achievement from achievement_list"; $sql = $sql." where achievement_id = 1";
//$sql = $sql." where achievement_id = ".$achievementsel;
$sql = "select achievement from achievement_list"; //$sql = $sql." where achievement_id = ".$achievementsel; $sql = $sql." where achievement_id = 1";
These two chunks of code, are not doing the same thing for me and I have no idea why. + Show Spoiler [frustration x1000000000000] + //$sql = "select achievement from achievement_list"; //$sql = $sql." where achievement_id = ".$achievementsel; //$sql = $sql." where achievement_id = 1";
$sql = "select achievement from achievement_list where achievement_id = 1"; echo "$sql<br>";
$sql = "select achievement from achievement_list where achievement_id = 1";
//$sql = "select achievement from achievement_list"; //$sql = $sql." where achievement_id = ".$achievementsel; //$sql = $sql." where achievement_id = 1";
echo "$sql<br>";
The first chunk of code prints "select achievement from achievement_list where achievement_id = 1". Second does nothing. For the record, the code after these lines just perform the query using $sql. Wow this is so inconsistent, I don't even know what is going on anymore.
I'm a bit confused as to why you just don't use the first one if it is working the way you want (since they both appear to do the exact same thing). The only thing that stands out as a little weird is that the comments are ending in semi-colons; you don't need to do that for php comments. It shouldn't affect anything if they are commented out properly, though.
|
Code copy pasted from Oreilly textbook:
<?php // authenticate.php require_once 'login.php'; $db_server = mysql_connect($db_hostname, $db_username, $db_password); if (!$db_server) die("Unable to connect to MySQL: " . mysql_error()); mysql_select_db($db_database) or die("Unable to select database: " . mysql_error()); if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) { $un_temp = mysql_entities_fix_string($_SERVER['PHP_AUTH_USER']); $pw_temp = mysql_entities_fix_string($_SERVER['PHP_AUTH_PW']); $query = "SELECT * FROM users WHERE username='$un_temp'"; $result = mysql_query($query); if (!$result) die("Database access failed: " . mysql_error()); elseif (mysql_num_rows($result)) { $row = mysql_fetch_row($result); $salt1 = "qm&h*"; $salt2 = "pg!@"; $token = md5("$salt1$pw_temp$salt2"); if ($token == $row[3]) echo "$row[0] $row[1] : Hi $row[0], you are now logged in as '$row[2]'"; else die("Invalid username/password combination"); } else die("Invalid username/password combination"); } else { header('WWW-Authenticate: Basic realm="Restricted Section"'); header('HTTP/1.0 401 Unauthorized'); die ("Please enter your username and password"); }
function mysql_entities_fix_string($string) { return htmlentities(mysql_fix_string($string)); }
function mysql_fix_string($string) { if (get_magic_quotes_gpc()) $string = stripslashes($string); return mysql_real_escape_string($string); } ?>
When I run it, it asks for my Username and Password (in a windows security pop-up). Regardless of which username/pw combination I type, it just reloads when I click the ok button, and after the third time I click ok button, it exits and says "Please enter your username and password." on the webpage.
I used echo statements to discover that nothing in the outermost if loop runs.
Can anyone see what's wrong?
|
On July 24 2013 19:54 Arnstein wrote:Show nested quote +On July 24 2013 19:37 Morfildur wrote:On July 24 2013 19:34 Arnstein wrote:On July 24 2013 19:27 iaretehnoob wrote:On July 24 2013 18:32 Arnstein wrote:Since I don't have much to do this summer, I'm thinking of doing as many of these as I can: https://github.com/thekarangoel/ProjectsI just did the first number one, where you have to find pi to the nth digit, and this was my answer: #include <iostream> #include <math.h> #include <iomanip>
using namespace std;
int main() { int n; cout << "Enter how many digits you want to see: " << endl; cin >> n; cout << setprecision(n) << atan(1)*4 << endl; }
Is this a bad way to do it? Is it cheating in any way? (especially using the setprecision function, which basically does the task for you) I see two issues: a) it rounds. b) try it for n>15 or something. Wow, didn't see that before now. How come the 3-4 digits are wrong on n=20? If it rounds I would expect the last one to be wrong, but not the 3-4 last ones. Floating point numbers have limited precision, they don't work for these cases. Okay, I guess I will find a new way then 
Does anyone have an idea what the fuck I should do? I have to find a way to generate pi digit-by-digit, as I will get the wrong pi from the double anyways.
|
On July 25 2013 17:50 Arnstein wrote:Show nested quote +On July 24 2013 19:54 Arnstein wrote:On July 24 2013 19:37 Morfildur wrote:On July 24 2013 19:34 Arnstein wrote:On July 24 2013 19:27 iaretehnoob wrote:On July 24 2013 18:32 Arnstein wrote:Since I don't have much to do this summer, I'm thinking of doing as many of these as I can: https://github.com/thekarangoel/ProjectsI just did the first number one, where you have to find pi to the nth digit, and this was my answer: #include <iostream> #include <math.h> #include <iomanip>
using namespace std;
int main() { int n; cout << "Enter how many digits you want to see: " << endl; cin >> n; cout << setprecision(n) << atan(1)*4 << endl; }
Is this a bad way to do it? Is it cheating in any way? (especially using the setprecision function, which basically does the task for you) I see two issues: a) it rounds. b) try it for n>15 or something. Wow, didn't see that before now. How come the 3-4 digits are wrong on n=20? If it rounds I would expect the last one to be wrong, but not the 3-4 last ones. Floating point numbers have limited precision, they don't work for these cases. Okay, I guess I will find a new way then  Does anyone have an idea what the fuck I should do? I have to find a way to generate pi digit-by-digit, as I will get the wrong pi from the double anyways. The fastest way would most probably be, to have another text file with the numbers of pi and just taking them from there. If you want to generate pi on the fly, you should take a look at https://github.com/Mysticial/Mini-Pi or http://www.numberworld.org/y-cruncher/#Download Or to avoid the limited precision of float, you could use a library that can handle bigger numbers https://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic#Libraries
|
On July 25 2013 17:50 Arnstein wrote:Show nested quote +On July 24 2013 19:54 Arnstein wrote:On July 24 2013 19:37 Morfildur wrote:On July 24 2013 19:34 Arnstein wrote:On July 24 2013 19:27 iaretehnoob wrote:On July 24 2013 18:32 Arnstein wrote:Since I don't have much to do this summer, I'm thinking of doing as many of these as I can: https://github.com/thekarangoel/ProjectsI just did the first number one, where you have to find pi to the nth digit, and this was my answer: #include <iostream> #include <math.h> #include <iomanip>
using namespace std;
int main() { int n; cout << "Enter how many digits you want to see: " << endl; cin >> n; cout << setprecision(n) << atan(1)*4 << endl; }
Is this a bad way to do it? Is it cheating in any way? (especially using the setprecision function, which basically does the task for you) I see two issues: a) it rounds. b) try it for n>15 or something. Wow, didn't see that before now. How come the 3-4 digits are wrong on n=20? If it rounds I would expect the last one to be wrong, but not the 3-4 last ones. Floating point numbers have limited precision, they don't work for these cases. Okay, I guess I will find a new way then  Does anyone have an idea what the fuck I should do? I have to find a way to generate pi digit-by-digit, as I will get the wrong pi from the double anyways.
http://crd-legacy.lbl.gov/~dhbailey/dhbpapers/pi-quest.pdf
This looks like a fun way. While it's (probably) not the fastest way (since you have to use the algorithm for each digit) it's certainly interesting. Also you get to practice your Base16 math
|
Australia7069 Posts
On July 25 2013 15:40 Release wrote:Code copy pasted from Oreilly textbook: <?php // authenticate.php require_once 'login.php'; $db_server = mysql_connect($db_hostname, $db_username, $db_password); if (!$db_server) die("Unable to connect to MySQL: " . mysql_error()); mysql_select_db($db_database) or die("Unable to select database: " . mysql_error()); if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) { $un_temp = mysql_entities_fix_string($_SERVER['PHP_AUTH_USER']); $pw_temp = mysql_entities_fix_string($_SERVER['PHP_AUTH_PW']); $query = "SELECT * FROM users WHERE username='$un_temp'"; $result = mysql_query($query); if (!$result) die("Database access failed: " . mysql_error()); elseif (mysql_num_rows($result)) { $row = mysql_fetch_row($result); $salt1 = "qm&h*"; $salt2 = "pg!@"; $token = md5("$salt1$pw_temp$salt2"); if ($token == $row[3]) echo "$row[0] $row[1] : Hi $row[0], you are now logged in as '$row[2]'"; else die("Invalid username/password combination"); } else die("Invalid username/password combination"); } else { header('WWW-Authenticate: Basic realm="Restricted Section"'); header('HTTP/1.0 401 Unauthorized'); die ("Please enter your username and password"); }
function mysql_entities_fix_string($string) { return htmlentities(mysql_fix_string($string)); }
function mysql_fix_string($string) { if (get_magic_quotes_gpc()) $string = stripslashes($string); return mysql_real_escape_string($string); } ?> When I run it, it asks for my Username and Password (in a windows security pop-up). Regardless of which username/pw combination I type, it just reloads when I click the ok button, and after the third time I click ok button, it exits and says "Please enter your username and password." on the webpage. I used echo statements to discover that nothing in the outermost if loop runs. Can anyone see what's wrong? How do your if statements loop? that's probably the first problem you should investigate
|
On July 25 2013 19:06 Kiante wrote:Show nested quote +On July 25 2013 15:40 Release wrote:Code copy pasted from Oreilly textbook: <?php // authenticate.php require_once 'login.php'; $db_server = mysql_connect($db_hostname, $db_username, $db_password); if (!$db_server) die("Unable to connect to MySQL: " . mysql_error()); mysql_select_db($db_database) or die("Unable to select database: " . mysql_error()); if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) { $un_temp = mysql_entities_fix_string($_SERVER['PHP_AUTH_USER']); $pw_temp = mysql_entities_fix_string($_SERVER['PHP_AUTH_PW']); $query = "SELECT * FROM users WHERE username='$un_temp'"; $result = mysql_query($query); if (!$result) die("Database access failed: " . mysql_error()); elseif (mysql_num_rows($result)) { $row = mysql_fetch_row($result); $salt1 = "qm&h*"; $salt2 = "pg!@"; $token = md5("$salt1$pw_temp$salt2"); if ($token == $row[3]) echo "$row[0] $row[1] : Hi $row[0], you are now logged in as '$row[2]'"; else die("Invalid username/password combination"); } else die("Invalid username/password combination"); } else { header('WWW-Authenticate: Basic realm="Restricted Section"'); header('HTTP/1.0 401 Unauthorized'); die ("Please enter your username and password"); }
function mysql_entities_fix_string($string) { return htmlentities(mysql_fix_string($string)); }
function mysql_fix_string($string) { if (get_magic_quotes_gpc()) $string = stripslashes($string); return mysql_real_escape_string($string); } ?> When I run it, it asks for my Username and Password (in a windows security pop-up). Regardless of which username/pw combination I type, it just reloads when I click the ok button, and after the third time I click ok button, it exits and says "Please enter your username and password." on the webpage. I used echo statements to discover that nothing in the outermost if loop runs. Can anyone see what's wrong? How do your if statements loop? that's probably the first problem you should investigate
He runs PHP as CGI, so both PHP_AUTH_USER and PHP_AUTH_PWD are never set, you could work around this like this: http://www.sslcatacombnetworking.com/articles/http-authentication-php-cgi.html
|
Thanks people, but is this the point of the challenge? To learn to import outside libraries and use them to get the right answer, or is it a way to complete this thing with only the standard libraries?
Either way, those links gave me some interesting material!
|
On July 25 2013 19:42 Arnstein wrote: Thanks people, but is this the point of the challenge? To learn to import outside libraries and use them to get the right answer, or is it a way to complete this thing with only the standard libraries?
Either way, those links gave me some interesting material!
This should help you even more.
|
On July 25 2013 03:15 Denar wrote: This thread has one of the worst atmospheres in all TL, a lot of agressive tone, dick-waving, and other never-ending battles over trivial matters.
Do you guys think this is specific to the people interacting in here, or if it is a general character aspect of the programmer to be unable to exchange in a more civilised manner ?
This is an unfortunate reason why I don't generally participate in developer forums online. The atmosphere is always acidic for simple general discussion. Which is a shame since I've been in the industry a while and a complete expert on Java but no matter what I say it will go under the microscope and will always be argued. It simply isn't worth it to me.
|
This is kind of a double post from a blog I just made, so apologies there in advance. It was suggested I post here in the blog so here I am.
I'm currently unemployed, but have a MS in CS from a shitty school that didn't do much for my education. 90% of my professional development experience is in COBOL. I'm curious as to what, if any, certificates you may suggest looking into getting, and suggestions on training materials for these as well.
The area I live in has nothing available in COBOL programming, so staying in that language is not currently an option.
Blog Link if curious as it has a bit more info: Blog Link
|
For those PHP people that just posted: please use parameterized queries. It pains me to see those select statements...
|
Hyrule19173 Posts
On July 26 2013 00:08 CornMuscles wrote:This is kind of a double post from a blog I just made, so apologies there in advance. It was suggested I post here in the blog so here I am. I'm currently unemployed, but have a MS in CS from a shitty school that didn't do much for my education. 90% of my professional development experience is in COBOL. I'm curious as to what, if any, certificates you may suggest looking into getting, and suggestions on training materials for these as well. The area I live in has nothing available in COBOL programming, so staying in that language is not currently an option. Blog Link if curious as it has a bit more info: Blog Link Are you kidding? COBOL is used by basically every bank in the world. ECommerce backends are a lot of COBOL. All sorts of networking stuff is COBOL. Look in other areas for work.
|
On July 25 2013 19:42 Arnstein wrote: Thanks people, but is this the point of the challenge? To learn to import outside libraries and use them to get the right answer, or is it a way to complete this thing with only the standard libraries?
Either way, those links gave me some interesting material! In my opinion the point of every challenge is to learn and improve. My personal favourite is still http://projecteuler.net/ Since they are mathematical challenges you can try to solve them in as many languages as you want, learning the language. If from solving your challenge you learned how to import libraries and using them, well that's something learned. If you think there are ways to implement it with standard libraries only, give it a try. I'm sure you'll learn something new from that aswell.
|
|
|
On July 25 2013 23:33 Tenks wrote:Show nested quote +On July 25 2013 03:15 Denar wrote: This thread has one of the worst atmospheres in all TL, a lot of agressive tone, dick-waving, and other never-ending battles over trivial matters.
Do you guys think this is specific to the people interacting in here, or if it is a general character aspect of the programmer to be unable to exchange in a more civilised manner ?
This is an unfortunate reason why I don't generally participate in developer forums online. The atmosphere is always acidic for simple general discussion. Which is a shame since I've been in the industry a while and a complete expert on Java but no matter what I say it will go under the microscope and will always be argued. It simply isn't worth it to me.
Really I chalk it up to basically every programmer never getting the required amount of sleep, and eventually developing a habit of being grumpy and pretty unforgiving. Unfortunate you feel that way, but you're doing a bit of dick-waving yourself there you know.
|
|
|
On July 26 2013 00:50 tofucake wrote: Are you kidding? COBOL is used by basically every bank in the world. ECommerce backends are a lot of COBOL. All sorts of networking stuff is COBOL. Look in other areas for work.
In the current area I live, there is not much COBOL going on. Trust me I am still looking for COBOL jobs. I may be moving to Phoenix next year though and I know there is more COBOL in that area.
Thanks for the help though folks!
|
Edit: Sorry, thought this was high thread.
|
|
|
|
|
|