help converting ASP to PHP

hello,

Can someone show me how to code the below ASP in PHP?
Thanks in advance.


<% page = Request.ServerVariables(“SCRIPT_NAME”) %>

  style="color: 000000;">
<%Else %>><% End if %>Home

We do not write scripts or convert one language to another. This is doing the work for you. I don’t work for you, you do not pay me. My work is not free. However, help is. So if you run into a problem, let us and we can help.

Here some suggestions…

Check the php manual. http://www.php.net
Use google. http://www.google.com

With these to sites you should be able to get everything you need to convert this.

thanks.

i know you don’t work for me, and i do not pay you. just asking for some help in the “beginners” forum.

see your description below? (i’m assuming you are a moderator)

A forum for beginning PHP programmers to ask questions. Please, no flames or put downs. There are no dumb questions only dumb answers and there probably are few truly dumb answers because they often lead to better ones.

your reply has a nasty tone. and you give me a the link to google?
do you really think i didn’t search google or php.net and try to see what i can figure out myself?

if you don’t want to help me just don’t reply. no need for your sarcastic reply. sounds like you don’t have patience to help… so don’t.

Ya this board has a very nasty tone… but hey they still help you out when needed. if they feel like it.

But i dont blame them to be like this.

I would be too if someone i didnt know showed up at my door and asked me to do something… well … depends on if its a hot girl.

anyway heres something that will help you out.
http://asp2php.naken.cc/

Heres another one
http://www.design215.com/toolbox/transl … _login.php

And remember i am not part of this group i only came to ask a simple question. and thought since i figured it out i might as well go look around and see if anyone needs help.

Simple questions simple answers. its not that big of a deal.

I am sorry you feel this way… But please consider being in my shoes.

I am here on a regular basis trying to help people that have problems that they have been working on for hours, days, or weeks. They tell us the problem show us some code we give them a solution if possible. They have put effort forth into solving this problem.

Then I have to troll through several posts a day with posts such as -

I need a script that does this and this OR can someone do this for me. It gets very old having to reply to these. I believe today there was at least 3 or 4 alone of these type of requests. So I am sorry that I am passing on knowledge just because I like to help others and then get a slight bit upset when I have to run through these.

My next question would be did you read the submission guidelines?
http://phphelp.com/forums/viewtopic.php?t=4089

If so you would have read under the section of How to Ask for Help number 2 the following:

Please do not post "Can you Make This" inquiries. Most of us here will help with existing problems that you have come across and will not create whole programs for you. You will receive help quicker if you show that you have gone to some effort toward a solution.

@Enockma:

We’re not malicious or snobby, but we do expect at least a little effort from you before you post your problem. Now, there’s only one way for us to see that you actually put in that effort: by posting what you’ve tried and why it didn’t work :slight_smile: That way, we don’t have to come up with possible solutions that you may or may not have already tried, but didn’t work.

On a sidenote: yes, Ragster is right, we’re doing this because we’re being good samaritans, really. We don’t have to help anyone, but we still volunteer to give up our free time to help others with their problems. I’d say that gives us the right to have an attitude :wink:

@Ragster00
@Zyppora

i hear you guys… and do appreciate the time and help you put in.

@Jenround

I am sorry if you feel that this board has a “Nasty Tone”, that certainly is not the intent. I agree that there are some that are a bit rough in their replies, but as been pointed out (several times in a variety of posts), many people come here to ask the question of “how do I write this script…” or similar questions. Many times without putting forth any effort.

When you see the apparently lazy mans request as frequently as people like Ragster and Zyppora (and other regulars) do, it does get old. Try to take their comments with a grain of salt and perhaps provide some clarifying information so that you can get an answer.

We try not to be nasty but we do try to be strict about the HELP and not the DO part. (i.e. phpHELP.com not phpDO.com)

I don’t really know ASP but I will take a crack at it.

For <% page = Request.ServerVariables(“SCRIPT_NAME”) %>
I think you want to look at http://us3.php.net/variables.predefined and particularly the section about $_SERVER. These variables are accesed from the Array. (there is also a $_REQUEST but it’s not as secure from what I understand).

The script name is in PHP_SELF

In PHP if and else statements are done differently. Also the equals comparison operator is == and assignment is =.

[php]
If ($SomeValue == $something ) {
// Do some code
} else {
// Do some other code
}
[/php]

PHP variables are prefaced by a $ so your PAGE would be $page

finally, php is open and closed by <?php and ?> respectively as opposed <% and %>

I hope this helps.

thanks everyone, i think i have it working now:
[php]

<? $thePage = $_SERVER["PHP_SELF"]; ?>
style="color: 000000;">
<? } else {?>><? } ?>Company
[/php]

Admin Edit: Added PHP Tags to for readablity! Please refer to http://phphelp.com/guidelines.php for posting guidelines

Check those Open and close tags around the IF statement. I think it will error.

Sorry if I came on a little harsh here (or anyone else did). It’s not like we’re trying to keep newbies away or anything, but it’s pretty much netiquette to read a forum’s rules … so yea … no hard feelings :slight_smile:

As for helping you out, I’d like to show you some of the ‘markup rules’ for PHP scripts. Right now, it looks like a bunch of jumble (no offense). First things first, let’s separate the HTML (presentation) code from the PHP (processing) code.

[php]

<?php $thePage = $_SERVER["PHP_SELF"]; ?>
"; echo "
"; echo "
"; } else { echo ">"; } ?> Company
[/php]

In my humble opinion however, this doesn’t look good. Splitting up an HTML tag (the anchor tag to be exact) by putting in PHP doesn’t look good at all. So here’s what I’d do:

[php]

<?php $thePage = $_SERVER["PHP_SELF"]; ?>
<?php if ($thePage == "/about.php") { echo ""; echo "
"; echo "
"; } else { echo "
"; } ?> Company
[/php]

But that’s just the way I’d do it :slight_smile:

@ Zyppora

thanks! i like how you separated the code. i kind of prefer your first example, because i like not having the about.php referenced twice in the code. what’s your opinion?

Well, you could also do it like this:

[php]

<?php $thePage = $_SERVER["PHP_SELF"]; ?>
<?php $extraAttrs = ""; $extraTags = ""; if ($thePage == "/about.php") { $extraAttrs = " style="color: 000000;""; $extraTags = "
"; $extraTags .= "
"; } echo "".$extraTags; ?> Company
[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service