Web Hosting Talk







View Full Version : PHP GURU needed


DigitalXWeb
03-30-2002, 08:02 PM
I am in need of assistance with a PHP issue. Since I am not a coder I have no clue how to accomplish this. I would think it is rather simple. Here is my problem , I am trying to merge two variable values together as one. Example :

$avalue = 'subdomain';
$bvalue = 'testdomain.com';
$cvalue = "$avalue" + "$bvalue";

I think this is possible in PHP 4 (at least that is what the book I have says) the problem is this is needed for PHP 3. Anyone know how to accomplish the above in PHP3?

Any help would be greatly appreciated..

Fr£d
03-30-2002, 08:06 PM
$cvalue = $avalue.$bvalue;

I think :rolleyes:

The Prohacker
03-30-2002, 11:15 PM
Originally posted by DigitalXWeb
I am in need of assistance with a PHP issue. Since I am not a coder I have no clue how to accomplish this. I would think it is rather simple. Here is my problem , I am trying to merge two variable values together as one. Example :

$avalue = 'subdomain';
$bvalue = 'testdomain.com';
$cvalue = "$avalue" + "$bvalue";

I think this is possible in PHP 4 (at least that is what the book I have says) the problem is this is needed for PHP 3. Anyone know how to accomplish the above in PHP3?

Any help would be greatly appreciated..


Originally posted by Fr£d
$cvalue = $avalue.$bvalue;

I think :rolleyes:


I'm guessing you want it so it comes out like this:
subdomain.testdomain.com?


If so:

$cvalue = '$avalue.$bvalue';

Would prolly be your best bet, but since its late, I may not know what i'm talking about :P


With the '' it might just merge the two togather and output it without the dot in the center...

Woody
03-31-2002, 03:03 AM
The following would not work. That would simply print $avalue.$bvalue.
$cvalue = '$avalue.$bvalue';



This would be the code you want..

$avalue = 'subdomain';
$bvalue = 'testdomain.com';

$cvalue = "$avalue." . $bvalue;

print $cvalue;

Which will print subdomain.testdomain.com

DjPaj
03-31-2002, 03:35 AM
This is the same as the post above, just a different way to look at it:

$avalue = 'subdomain';
$bvalue = 'testdomain.com';
$cvallue = $avalue . "." . $bvalue;
print("The URL is: $cvalue");

kunal
03-31-2002, 04:29 AM
DigitalXWeb, what do you want the output to look like??

DigitalXWeb
03-31-2002, 11:50 AM
Thanks for the help and suggestions so far!

What I am trying to do is this:

$a = 'the path of a shared application' ex: /shared/app
$b = 'the hostname making the request' ex: domain.com:port
$c = "$a.$b" ex: domainname.com:port/shared/app

I have tried all the methods posted above and keep getting the same results see the following for what is happening :

if I call just the $a it will output the following:

http:///shared/app (this is correct)

if I call just the $b it will output the following:

domainname.com: (Notice it drops the http:// and the port number after the colon)

If I call the c$ it will output this :

domainname.com: (The same as just calling the $b)

For giggles I tried something and this is strange:

if I do the following
c$ = "&$a.$b" it outputs the following:

"http://&domainname.com:port/shared/app" without the quotes.

Judging by this it does add the variables correctly but when they are passed to a browser they dont seem to hold their values and are cut off unless I add the & but then obviously it doesnt work.

If anyone would like to see the actual code snippet PM me and I will mail it to you. Perhaps you can find the problem that way?

Keep in mind I am not trying to print these variables I am trying to pass the value of c$ to a browser which will call up the requested page with the domains permissions/authentication. Not sure if that makes a difference or not as I have said I am not a coder and know nothing about it. Again this is for PHP3.

Thanks for the help so far!!!

Woody
03-31-2002, 12:02 PM
$a = 'domain.com:port';
$b = '/shared/app';
$c = $a . $b;

print '$a is ' . $a;
print '$b is ' . $b;
print '$c is ' . $c;

DigitalXWeb
03-31-2002, 01:34 PM
Originally posted by Woody
$a = 'domain.com:port';
$b = '/shared/app';
$c = $a . $b;

print '$a is ' . $a;
print '$b is ' . $b;
print '$c is ' . $c;

Thanks but I am not trying to print these :).

Also the domainname.com entry is not static it is pulled from the requesting host header and changes for each host. Perhaps that might create the problem as well??

Woody
03-31-2002, 02:19 PM
I think I understand now. Let me know if I still got this wrong.. :P

$b = $HTTP_SERVER_VARS['SCRIPT_NAME'];
$a = $HTTP_SERVER_VARS['HTTP_HOST'] . ":" . $HTTP_SERVER_VARS['REMOTE_PORT'];
$c = $a . $b;

print '$a is ' . $a;
print '$b is ' . $b;
print '$c is ' . $c;

I was just printing them out for testing. You can do whatever you want with the vars. $a contains the host and port. $b is the script path, and $c is the two combined.

A sample print out is the following..
domain.com:4429/test/test.php

Is this what you want?

DigitalXWeb
04-01-2002, 03:55 PM
That is the output I am looking for yes. However I still cant seem to get it to work properly. It keeps cutting off everything after domainname.com?

It works if I add the & before it but drops everything if not? Might be something in the script itself. I will check this out and see if I can find the issue. Thanks for the help!!