What's better, PERL/cgi or PHP/my_sql?

I need to design a website heavily relying on a database and was wondering what would do the job better, and why

from what i have seen php is great for designing web pages as long as you know the code

We’ve used both on ChiefDelphi.com

I’d have to say that using PHP/mySQL has been a whole lot easier. I don’t know if its because I do it at work [well, with oracle and php] also, or if its becuase ive been using php/mysql longer and know it better…

either way, i like php/mysql better.

what kind of database system do I hook up to PERL/cgi? my webhoster doesn’t offer my_sql (unfortunately) but I might be able to get telnet access for a limited time.

I learned perl before I learned php, and though they are very similar, I think php is much easier. It’s less learning syntax and more just programming (for example perl has 3 different symbols: one for a string/number ($), an array (@), and an assossiative array (%) while php only has one, $).

You can connect to any kind of database (postgre, oracle, mysql) using perl, you just have to find the right module (http://search.cpan.org/doc/JWIED/DBD-mysql-2.1017/lib/DBD/mysql.pod). I know php can work with postgre and mysql, and it probably would work with all the others, but I’m not sure because I’ve only used it with mySQL.

Also, you can connect to any mysql server from in your script so your database doesnt need to be on the same server as the script. If your host doesn’t offer it you might be able to find someone else who does.

First of all, PEARL/CGI vs. PHP/mySQL are not exactly the same. mySQL is the database, and PHP is the programming language. CGI (Common Gateway Interface) is a specification how to pass information between an HTTP server and a program that will do something with the request. Pearl is the language that this program would be written in. A few years ago, Microsoft wrote ASP which is basically Microsoft’s server-side language and response to CGI’s faults. ASP is also a way to proccess the requests, and the actuall programs in ASP, like in CGI, are written in other languages - Javascript, VBScript, Pearl, Python, etc. Meanwhile, PHP is the whole package in one - the instructions for interacting with the HTTP server and a programming language in one. MySQL is just a database, so whichever way you go, you’re going to have to learn MySQL. Technically (yeah yeah, I’m being anal here, but I just thought you’d like to understand what you’re considering better), your title should be “CGI/Pearl/MySQL vs. PHP/MySQL”

I’m just learning php/mysql right now (so far I can post to a database some information and view it/arrange it nicely, go me! :)). My expierience is that php/mysql are pretty easy to pick up. That and I suggest php/mysql for a simple reason - it’s newer.

My book on ASP has a little description about CGI and why Microsoft made ASP. The server needs to create a new CGI process for every CGI request. If the site is under a lot of stress, this severly limits performance. So Microsoft did something called ISAPI (Internet Server Application Programming Interface). Basically, ISAPI allows it so DLLs are loaded into the same memory space as the server. The server processes requests by executing code from the DLL, which, because is in the same memory as the server, results in no additional process overhead. Basically, “ISAPI applications execute exponentially faster than CGIs, while at the same time making less demands on the server’s memory.”

Now that was from my ASP book. It didn’t really mention anything about PHP, but I’m assuming PHP is also an ISAPI application. What it comes down to is PHP is newer than CGI, and so, was designed with CGI’s faults in mind (looking at it the other way, why make something completely new (PHP) when the old way (CGI) isn’t broken?). If the differences really don’t matter to you (you’re site isn’t going to be under that much stress), look at it this way - are you going to learn something old, or learn something new? Obviously, the old way is going to die out eventually, so my way of thinking is you might as well learn whats going to be used longer - PHP.

Now, I mentioned ASP. ASP is newer than PHP, so by my logic, ASP should be learned over PHP, which is why I got the ASP book instead of the PHP book (if you’re curious, the improvement over PHP in ASP is “sessions” - these guys store information about unique users in the server’s memory rather than external sources, like cookies or files on the server. The way I see it, unless you need that kind of tracking ability (i.e. commercial sites), there is no real difference between ASP and PHP). After some expirience with ASP, I’m liking PHP better. I like PHP better mainly because it’s more flexible. I’ve found that you can do more with variables easier in PHP than you can in ASP (atleast using Javascript to make ASP pages, which is how the book taught it). However, the biggest reason why I prefer PHP over ASP is the fact that PHP is more broadly used. The reason why I kept on saying Microsoft made ASP is because ASP isn’t supported on non-Microsoft platforms (I’m almost certain this is true). PHP on the other hand runs on almost every platform - Windows, Unix, Linux, etc. And if you know anything about the internet, you’ll know most hosts don’t use Windows. Because of this, it’s very hard to find a provider that hosts ASP. PHP is also open-source, meaning it’s undergoing constant revisions (open-source is also probably the reason why it’s available on every platform). In conclusion, PHP is the way to go :slight_smile:

DISCLAIMER: All of these facts are what I’ve learned (or atleast think I’ve learned) in my expierience with server-side languages. If you know something I said is complete bs, please tell me. I’d like to know :slight_smile:

*Originally posted by Jay Lundy *
I know php can work with postgre and mysql, and it probably would work with all the others, but I’m not sure because I’ve only used it with mySQL.

We’ve hooked PHP to Oracle at work…

Oh, and here is a good article comparing PHP vs PERL

*Originally posted by SuperDanman *
**
Now, I mentioned ASP. ASP is newer than PHP, so by my logic, ASP should be learned over PHP, which is why I got the ASP book instead of the PHP book (if you’re curious, the improvement over PHP in ASP is “sessions” - these guys store information about unique users in the server’s memory rather than external sources, like cookies or files on the server.
**

I don’t know if im reading this sentence wrong, but PHP does have very good session handling…

Hmmm, you’re right. I read somewhere that one of the main difference between ASP and PHP is how they handle sessions. I thought it said that PHP doesn’t do it (atleast without using cookies, but from my ASP-centric viewpoint (cause I learned ASP first), thats not really ‘session-handling’ as I learned it), but apparently I’m wrong on that one.

I read over the PHP manual on sessions, and yeah, I did find a difference. "A visitor accessing your web site is assigned an unique id, the so-called session id. This is either stored in a cookie on the user side or is propagated in the URL. " If I’m understanding it correctly, PHP leaves storing the session information up to the user. ASP, on the other hand, when a page is requested, it somehow determines if the user is unique, and based on that information, assigns that user’s “unique information” a session ID - but all this is stored on the server. The PHP manual was kinda vague about whether the variables are stored on the server or the client, but all session information in ASP is stored on the server. The advantages of having it all on the server is that you have total control of the information. In PHP, a user can deny a cookie, and if their browser is closed, they loose the url-encoded information. In ASP, since everything is on the server, every request automatically has a session ID, and keeping this session ID reliable is now part of the server’s job - not the client’s. Now someone can view a page, reboot their computer, go back to the page, and (assuming it’s within the session timeout limit) they’re still using the same session. This gives you a bit more control. Long-term data is still stored in cookies. But again, unless you’re going to use session-specific data in your website and you need this data to be accurate, you’re probably not going to see a major difference in what you can do with ASP as opposed to PHP.

As far as databases go, MySQL is the way to go in my opinion. It is free and it is awesome. I know that some people use Perl scripts to access MySQL databases as well as PHP.

If you need somewhere to host a PHP/MySQL powered website, I would highly recommend http://www.tripod.lycos.co.uk. You get free PHP/MySQL, 50 megs and no advertisements with PHP files. I don’t know if this is a fluke in their advertising system or what, because they do appear on files ending in .htm or .html.

For some reason, PHP/MySQL support is not available on the American Lycos but it is there on the Italian, UK, and some other versions. At least the UK version is in english :wink:

*Originally posted by Greg McCoy *
You get free PHP/MySQL, 50 megs and no advertisements with PHP files.

Wow. Thats pretty nice of them.

**I don’t know if this is a fluke in their advertising system or what, because they do appear on files ending in .htm or .html. **

SHHHHH :slight_smile: