107 Comments
- MasterThief117, on 01/19/2008, -0/+53As easy as 3.141592653589793238462643383...
- LysolSCG, on 01/19/2008, -2/+34So it automatically assumes you have Cpanel...
Easy as pie.... With a Cpanel $900 license. - jswoods7, on 01/19/2008, -1/+21Link is not working for me. Getting "Error establishing a database connection"
- Speck, on 01/19/2008, -0/+19I guess you're an expert, then, in Actionscript, Ruby, Python, PHP, ASP.Net, Javascript, Photoshop layers and effects, XML, XSLT, SQL, CSS, XHTML, etc.?
Everyone at one time or another is a noob at something. Should they be prevented from posting to Digg?
You were a noob once, too, and if people looked down their nose the same way you are now, you wouldn't be *****.
I'd take 20 noobs over one arrogant prick any day. - bubbles19518, on 01/19/2008, -1/+15Or you bought a $5 shared hosting account on one of hundreds of servers...
- nitsnipe, on 01/19/2008, -0/+14 No, it automatically assumes you got it illegaly but for educational purposes.
- guytoronto, on 01/19/2008, -1/+13Step 1: Get a server that can handle real traffic.
- ShouldBeStudyin, on 01/19/2008, -1/+11Ironic that there would be a database error ("Error establishing a database connection") when trying to read an article about MySQL.
- sensor, on 01/19/2008, -0/+10That code is so bad...
- NeMoD, on 01/19/2008, -1/+10or if you have any host worth a damn
- Firehed, on 01/19/2008, -0/+9It's done just as easily with PHPMyAdmin, which IS free.
But this guide is really aimed at people who are using the above-mentioned $5 shared hosting that includes Cpanel. - Error601, on 01/19/2008, -0/+8Ironic getting a "Error establishing a database connection" on an article about using a database?
In any case, the problems I find are not people that know how to use a DBMS but people that don't know how the design a database. Constraints are not novelties that you don't really need. - FatLoser, on 01/19/2008, -0/+7I ran into a few people who could recite pi to the x-hundredth digit. I was all like... who gives a *****? And they were all like... you just don't understand; it's cool to be able to recite completely random digits that have no pattern whatsoever, and the recitation of which ensures delayed loss of virginity. And I was all like... whatever!
- seantubridy, on 01/19/2008, -0/+6Oooohhhh I get it. Ha ha.
- pudly, on 01/19/2008, -1/+6how ironic: "Error establishing a database connection"
edit: i should probably read other posts prior to my attempt at being witty - jcaino, on 01/19/2008, -0/+5yea, really. don't use cPanel here, but creating a database is just as easy - just input the database name, click the button, and viola! done. phpMyadmin is available right there too.
- duniyadnd, on 01/19/2008, -0/+4That is your first lesson. What is "error establishing a database connection".. too bad they didn't explain it. :)
Why can't folks just use documentation provided by mysql.com itself?? - fate3, on 01/19/2008, -0/+4turns out its not so easy after all
- SpookyET, on 01/19/2008, -1/+5Easy-As-Pie:
"Error establishing a database connection"
That's the shortest MySQL tutorial ever;-) - rzermatt, on 01/19/2008, -0/+4Step 2: Put your junk in that server.
- JoeRW, on 01/19/2008, -0/+3The order by rand() is not so great for very large 5000+ row tables because it assigns a random number to every record in the database and then orders them. It's much faster to get the random row via programming code ie
SELECT COUNT(*) AS num FROM quotes
generate a random number $rnd between 0 and num-1 in code then do
SELECT quote FROM quotes LIMIT $rnd, 1 - bradleyland, on 01/19/2008, -0/+3WRONG!
- eighties, on 01/19/2008, -1/+4He uses $htmlentities to prevent possible XSS attempts when echoing out database values, but never bothers to sanitize the input in the first place, leaving the whole system wide open for SQL injection. That's a great way to have your data compromised and/or DROPed.
- surge1, on 01/19/2008, -0/+3easy as Irony
- dpierce, on 01/19/2008, -0/+3What would your improved code look like?
- borez, on 01/19/2008, -0/+3Error establishing a database connection
- Niubai, on 01/19/2008, -0/+3It would be pretty cool to hit F5 several times after that form submit ...
- an8kid, on 01/19/2008, -0/+3sadly i know pi to about 27 dec places in my head. I know i cant prove it, but its true!
..the next number is a 5 - SteaminTmann, on 01/19/2008, -1/+4Ohhh the irony..
- unversed, on 01/19/2008, -0/+2*****, I can't believe I clicked on that. You suck!
- guytoronto, on 01/19/2008, -0/+2Step 3: Have her open that server.
- AmazingAndrex, on 01/20/2008, -0/+2Step 3: Make them open the server.
And that's the way you do it. - stuckinOK06, on 01/19/2008, -0/+2mirror, please?
- eighties, on 01/19/2008, -0/+2The code that you posted was added _after_ the original article was dugg. If you check the google cache (in the comment by dwalker above), the original query was :
$query="INSERT INTO `quotes` (`quote`,`author`) values ('" . $quote . "','" . $author . "')";
Which does nothing to prevent SQL injection. The modified code at least attempts to prevent such problems. Good of him to change the code, as well. It shows that he reads the comments on his own article. - themoosejuice, on 01/19/2008, -0/+2SITE DEAD - 403 Forbidden - Digg strikes again.
- Tippis, on 01/19/2008, -0/+2(define improved-code (lambda (improver code) (improver (improved-code improver code))))
- tgc1, on 01/19/2008, -0/+2Or you could just learn how to do it yourself. ***** people are lazy. PHP/MySQL ain't hard.
- jorge1087, on 01/19/2008, -0/+1sooooooooo good
- EXreaction, on 01/19/2008, -0/+1Or you can check out the Session Manager I've built. Lets you easily register/login/track sessions, even hashes the passwords with phpass.
http://www.lithiumstudios.org/forum/viewtopic.php? ... - vibrokatana, on 01/19/2008, -0/+1Working via the GUI tools supplied via the MySQL website is easier IMO. Especially when you are designing your database schema and setting up stored procedures/functions. This only really helps for those without root on their server (I run my own VPS). Even then it is pretty much common sense and in the ***** manual for cPanel...
- Niubai, on 01/19/2008, -1/+2Two words for the new at *SQL: Stored Procedures. Take note.
- noinput, on 01/21/2008, -0/+1pie has never been that easy for me to make.
- jonester, on 01/19/2008, -0/+1Database error? I want to learn SQL from you!
- Scriptor, on 02/04/2008, -0/+1Is it that hard to get a good book and read it? Oh, sorry, it actually costs money, paying money to learn a language that you're unfamiliar to from the ground up, and then try to build production websites with, pshh.
Go find a place with reviews for tech books (Amazon for example), get one, read it. Then start some projects to practice with, and use the docs for reference and to learn the details. Once you're used to the language, find some well-written code and study it (PHP frameworks for example). PHP/MySQL is simple, sure, but it takes alot more than knowing "working with a database" to build a database-driven site. - RTPMatt, on 01/19/2008, -0/+1I only know the SQL i have taught myself, so im hoping someone can give me a little help. Reading the code, it seems to me their SELECT line is odd to me:
$query="SELECT `quote`, `author` FROM `quotes` ORDER by rand() LIMIT 1";
It seems a very odd use of ORDER By to me, i would have had an auto incrementing key field, and done a SELECT * WHERE key=rand() type thing.
What do you guys think? - stutimandal, on 01/19/2008, -0/+1The random quote generator algorithm, using rand() function in mysql, works really slow on large database tables.
You should count the number of rows (or use the max-primary key id) and then generate a Uniform Random row to be drawn using Php/scripting language. - joelhardi, on 01/20/2008, -0/+1Also, "SELECT *" is generally considered bad programming practice. From a pure database server-performance perspective there's no difference between enumerating all the columns and using * (provided you actually *need* to select all the columns in your table ... usually you don't in which case it's a waste to select the extra fields). However, "SELECT *" makes your program harder to read, and what happens when you change your schema or your query? Here, this guy with cool haircut will explain more. http://searchoracle.techtarget.com/ateQuestionNRes ...
- tempusrob, on 01/20/2008, -0/+1Why do people still not use PDO? :(
- inactive, on 02/21/2008, -0/+1Step 3: Cut a hole in the box...
- oyuncambazi, on 11/22/2008, -0/+0http://www.oyuncambazi.com
-
Show 51 - 100 of 106 discussions




What is Digg?
Browsing Digg on your phone just got easier with our enhancements to the