webgyrl Posted April 3, 2004 Posted April 3, 2004 So, I've been doing some further research into CGI and PHP scripting, trying to make sense of it all! Big task! The thing that got me into doing deeper research was the whole issue of databases, specifically SQL. It seems that PHP and SQL are mentioned frequently together and that writing scripts to call actions from the database in PHP is what the trend is. Now, I am totally new to a lot of this harder-core scriptng, programing and database stuff. I am trying to do a lot of reading up on the matter... but I figure it is always best to go to those who have had 'real world' experience in the matter. For those here who do script writing, what makes you choose to write one over the other as it pertains to CGI/Perl or PHP? Is it a security issue that prods you to use one over the other or an end user issue? And for those who have databases set up here using mySQL- how does that work and do you know of any tutorials that would help me learn how to set up a database. I'm interested in simple database type things and when you would use an SQL database and how you would link it to web interactivity. For isnstance, a lot of message boards seem to run off databases... they store info and generate passwords and the user can select a user name etc. On the 'back end', how does this work. Sorry if this is a question with too huge a scope. I'm open to book suggestions that cover these topics... so if you know of any good ones... holla! Thanks, Nat Quote
HCSuperStores Posted April 3, 2004 Posted April 3, 2004 I've noticed that your questions are never a "Yes" or "No" answer ... and you've probably noticed that I don't usually write small responses either! In any case, I'll do my best to explain as much as possible. If you still have questions, or I missed something, either I or someone else can fill in the gaps. Ok, first Perl and PHP. These are, in a way, one in the same. They are both programming languages. More finely put, they are interpretive types of languages, which means the computer has to translate them first and then it can run the code. This is opposed to languges like C, C++, Cobol, Pascal and many, many others that are compilied languages. Compiled languages take less work because they are already in a code that the computers under stand. Interpretive code requires a compile and then it can be run. PHP is more popular on the web than Perl for script writing. There is also Visual Basic, shell/scripts (corn, born, bash), Python, and also many more here too. Personally I've noticed over the last 10 years a migration from compiled languages to interpretive languages as interpretive languages are easier to write code in (usually) so it allows you to write more in less time. Maybe this is really just because of the web. Another reason is that compiled languages, which perform better with the CPU, are not as necessary because machines are just so much faster than they were 10 years ago. There are more technical details about the way interpretive languages do compiles which can afford huge processing efficiencies ... but I'm just not going to get into that much detail. BTW - I don't think that Perl is more secure than PHP, or likewise for PHP, but you can write very insecure code. Just a couple of resources: Perl Resource PHP Resource CGI is not a language, but rather an interface, thus the name of Common Gateway Interface. For instance, when you go to buy a car, generally you're not worried about IF you can drive a car. You expect things to be in certain places like the gas and break pedals, steering wheel, etc. These things are the way you interface with the car. In the same way, CGI is an interface. There is a standard way that information travels from the server to a person's web page and back again. When you use CGI as the interface, you will know exactly how to send and receive this information no matter what machine the server is or what machine your customer is using. It's all expected to work the same way. So, when you make a form on a web page and send that form to a script, via "action=yourscript.pl" then you automatically know how to retrieve the information in your script. MySQL is a relational database structure, although you don't have to use it that way, but it is meant to work this way. It's just a convenient way to store and retrieve information in an organized fashion. You could store everthing you need in plain old data files, but then you would have to build programming tools and figure out how to access your data. Even then, you would never be as efficient as a true database, designed to receive, update, and send data quicly and easily. You usually communicate with MySQL using SQL statements. These are simple statements that allows you to communicate with this, and many other databases. So if you want to add a "white Corvette" to your database it might look something like "INSERT make, color INTO cardatase VALUES 'Corvet','white'"; My syntax may be off just a little here, but it's the basic idea. You retrieve records by using a SELECT statement and you specifiy something like "SELECT * FROM cardatabase WHERE color='whie'"; The language is pretty simple, but with knowledge comes efficiency. The more you know the faster you can make it go. See MySQL Information With all this I just wrote, it's just an overview. There's so much more to know and learn. Pick up some good books and prepare to do some research. If this is your first stab at writing programs, instead of HTMLish code then things might take a little longer, but it's never impossible. We all started where you are at one point. If you really get into this and need someone who's been down the road for years, PM me and we can talk. Maybe we can work out some OJT (on the job training) if this is an area where you really want to learn. I've always learned best by doing myself and I could help you with that. In any case ... good luck to you!!! Quote
btrfld Posted April 3, 2004 Posted April 3, 2004 In my experience, PHP and MySQL together are a very clean way to build pages from dynamic content. PHP itself I find fairly intuitive once you learn a few basic concepts, and it has built-in functions for working with MySQL. Here are a couple of resources I have found very helpful, in addition to the ones HC mentioned. PHP/MySQL Book from Sitepoint SQL Queries for Mere Mortals And of course, keep asking questions; we love to share. Quote
TCH-Don Posted April 4, 2004 Posted April 4, 2004 Nat, Sams publishing has a 'PHP in 24 hours' book Quote
webgyrl Posted April 4, 2004 Author Posted April 4, 2004 HC! You are right... I ask rather multi-part questions that never seem to suffice a simple yes or no! I have SO many questions! I appreciate your very detailed and thoughtful answers to my queries! I have learned a lot by gleaning the info from your postings here on the forums and I am glad you are around to share your insight and knowledge! Thanks Thanks for clarifying that CGI is strictly an interface.... Perl is the coding language... I wasn't 100% sure what the CGI part was, though I knew it stood for Common Gateway Interface. I was a tad confused... especially considering when PHP is mentioned it is not mentioned in conjunction with CGI. Does CGI still factor in when working with PHP coding? Is the code just a matter of personal preference? From what I have read, the PHP advantage is that it is server-side code and more browsers can interpret it. Please correct me if I am wrong in my assumption. I went to my local bookstore yesterday and found a few books. One was on Perl/CGI and PHP... it seemed to list a lot of coding excersizes, but didn't get too much into explaining WHEN to use either code or the advantages of one over the other. I am still perusing the books to see which ones are worthy of a purchase. As far as SQL goes... I have never used a database in my web designs. I really want to learn how to do this in case I am ever asked to desing a site that requires a database. I have just stepped up my web design and started my own little side-business. I come from a more Graphic Design/Visual background and am not a hard core coder/programmer. I am terribly unversed in how code works and what it all means, but I am very interested in the science behind the codes I currently plop into my designs. The whole database world and interactivity on the web interests me very much. I think a practice project is something I need to do to learn. Like you, I learn best by doing. I will PM you and take you up on your offer to help. I am not even sure where to start with building a database and being able to use it via a web interface. I feel that it is something I must learn, and I am a sponge for information and practice. Thanks for your great summation and for offering your wisdom to me. I appreciate it. Thanks, Nat Quote
webgyrl Posted April 4, 2004 Author Posted April 4, 2004 Nat, Sams publishing has a 'PHP in 24 hours' book Ahhhh! I just found SAMS CSS book... will look into the PHP one. SAMS seems to have an excellent series. Thanks for the suggestion! Nat Quote
webgyrl Posted April 4, 2004 Author Posted April 4, 2004 In my experience, PHP and MySQL together are a very clean way to build pages from dynamic content. PHP itself I find fairly intuitive once you learn a few basic concepts, and it has built-in functions for working with MySQL. Here are a couple of resources I have found very helpful, in addition to the ones HC mentioned. PHP/MySQL Book from Sitepoint SQL Queries for Mere Mortals And of course, keep asking questions; we love to share. Thanks for those links Jim! Quote
webgyrl Posted April 4, 2004 Author Posted April 4, 2004 I've been perusing the links above. Question: How would one set up a site like the http://www.phpfreaks.com site? They seem to have a login process where you give your username and they autogenerate a password. This is a database driven site. How would one set up something like this? I know... it's probably a HUGE question. Sorry Nat Quote
Budman Posted April 6, 2004 Posted April 6, 2004 first off, I believe they hand coded all of that site, which to be truthful, IMO anyway. To get a site of that quality, it would take months to go from a newbie to building a site like that. If you are serious in doing that I recommend it, as you would probably get a much better knowledge in doing that then doing this next part. The Easy Way. if you want a site like that there are many GNU (open source) projects out there that do the exact same thing. Best examples are www.postnuke.com, and www.phpnuke.com . Anyway, that is what I made www.teamsick.us out of, and plan to make www.i-needhelp.com out of. You still learn PHP and CSS by moding it, you just don't learn how to code specifically. You know your an html freak when your <head> starts with coffee to get ready for the <body> of the day, and you can't wait for the </body> Quote
webgyrl Posted April 8, 2004 Author Posted April 8, 2004 Budman, Thanks for the links to those OS projects. I have checked them out. HC has taken on the challenge of tutoring me in the area of databases and coding. I am working on the project now. Once it's done I'll come back and post a link. Thanks again for the suggestions. Natalie Quote
HCSuperStores Posted April 8, 2004 Posted April 8, 2004 ... and so far she's been a very good student! Her excitement reminds me of why I got into this business ... to be creative in yet another way! She's doing all the work ... so even I will be interested to see how it turns out! I wonder if something like this could be done in a larger scale ... student/teacher or mentor/mentee kind of thing. There's lots of people looking to learn these days. There are so many projects to do!!!!! Later! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.