Need help with converting cgi to php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jminscoe
Forum Newbie
Posts: 2
Joined: Mon Jan 19, 2004 11:58 am

Need help with converting cgi to php

Post by jminscoe »

does anyone know how I can convert from this format http://www.jodeewebhosting.com/ask/index.php to this format http://www.jodee.biz/scgi-bin/rlinks/rlinks.cgi?m=index but keep it as php
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

your subject says from cgi to php, your message indicates the other way around?

cgi is not comparable to php, cgi is an interface for executing server side executables on the server, php is a script-engine.

normally (most cases) when processing .php files with apache, it uses a built in module, mod_php, to process the file with the php engine.

A cgi script can be any executable, and the webserver simply executes it and returns the output, executable scripts have an intepreter locator in the first line, like #!/path/to/php

So, in cas of converting a cgi to php, it depends.. if it is a php script it should be as simple as removing the first line that references the php intepreter..

Creating a cgi script from a PHP file is very simple, simply add the intepreter reference at the top of the file, rename and make the file executable.
User avatar
lazy_yogi
Forum Contributor
Posts: 243
Joined: Fri Jan 24, 2003 3:27 am

Post by lazy_yogi »

Stoker wrote:cgi is not comparable to php, cgi is an interface for executing server side executables on the server, php is a script-engine.
Haha .. php IS cgi.

Read up on what cgi actually is. It is where a request is sent to the server to be executed and then sends back the result. That is, it's run server-side. Which is php. Which is CGI.


So jminscoe, it works the same, just doesnt need to be run in a different cgi directory like the older languages like perl do.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Add this line on top of your phpfile:
#!/path/to/php

To find out where php is, you could do:
which php

Done ;)
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

lazy_yogi wrote:Read up on what cgi actually is.... it's run server-side. Which is php. Which is CGI.
I have read that specification a couple of times, CGI stands for Common Gateway Interface, and specifies what environment variables should be set and how the webserver sends POSTed data to STDIN of a local executable and requires a content header before returning the rest of STDOUT back to the client.
PHP can of course be exeuted through a CGI interface, just as well as any other executable program or script, but PHP is not comparable.. An intepreter vs an Interface/Spec.
jminscoe
Forum Newbie
Posts: 2
Joined: Mon Jan 19, 2004 11:58 am

Clarification

Post by jminscoe »

I think what I should have asked is how can I make my cgi db a php db as I want to keep my link db that is cgi now but convert it to a php one as I don't like the looks of the one that is now php to I just make tables or what?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

That's the nice part of a database.

You can query it with any language that has an interface to that database.

I don't know in what language your blah.cgi script is written, but i suspect it is written in perl. Meaby you need to have a look at Perl DBI ?
Post Reply