Page 1 of 2
redirecting[SOLVED]
Posted: Mon Sep 28, 2009 5:50 am
by mayanktalwar1988
location.php
Code: Select all
<?php
include("mysql_connect.php");
$id =$_GET['id'];
$sql=mysql_query("SELECT * FROM topics WHERE id='".$id."'");
if($row=mysql_fetch_array($sql))
header("Location:{$row['webpage']}");
mysql_close($con);
?>
with the above scrpt it is redirecting me to
http://localhost/pro1/facebook.com istead of facebook.com
the link with which this script get intiated is like this localhost/pro/location.php?id=21
there is a corresponding webpage in the table coresponding to that particular unique id...how to make this script go to
http://www.domain.com
instead of localhost/pro/domain.com
Re: redirecting
Posted: Mon Sep 28, 2009 10:55 am
by requinix
Your links have to say "
http://facebook.com". You can probably add the "http://" automatically with
Code: Select all
header("Location: http://{$row['webpage']}");
Re: redirecting
Posted: Mon Sep 28, 2009 12:59 pm
by mayanktalwar1988
still no luck
similar result
http://localhost/pro1/facebook.com
i am now clueless..i am providing facebook.com from database but it is ending in
http://localhost/pro1/facebook.com
Re: redirecting
Posted: Mon Sep 28, 2009 2:03 pm
by uyewq
Hi,
not sure, only an idea but, in your db, maybe you should keep your url with double quotes or vice versa...
You can ask your IT consultant for sure, he/she may be can tell something about server config..
Check your code (extracts from db) if PHP_% variable exist before it.
if these doesn't solve you can retouch your echo with string replacing functions to crop unwanted part(s) of course.
Bye
Re: redirecting
Posted: Mon Sep 28, 2009 2:06 pm
by Ollie Saunders
Replace:
Code: Select all
header("Location:{$row['webpage']}");
with:
Code: Select all
var_dump(error_reporting(), headers_sent(), $row);
What output do you get?
Re: redirecting
Posted: Mon Sep 28, 2009 2:10 pm
by mayanktalwar1988
ok wait doing it
Re: redirecting
Posted: Mon Sep 28, 2009 2:12 pm
by mayanktalwar1988
it ends up with
object not found page 404 error
with this url
http://localhost/pro1/facebook.com
on one of links i am testing out
Re: redirecting
Posted: Mon Sep 28, 2009 2:26 pm
by Ollie Saunders
OK, then you're not even running the code that you posted. Does it help to know that? If not, I'm not sure what else I can suggest. If you don't know what files are being run, where, I can't help you. I wonder if you're using frames, which are complicating things.
Re: redirecting
Posted: Mon Sep 28, 2009 2:31 pm
by mayanktalwar1988
ollie i have coded every bit myself of the scripts ..which are in pro1 folder
i dont know what is happing with this just with this i used similar thing in other scripts
i dont know why it is addind locahost/pro1 in directing links
Re: redirecting
Posted: Mon Sep 28, 2009 2:44 pm
by Ollie Saunders
What OS are you running?
What web server are you running?
Re: redirecting
Posted: Mon Sep 28, 2009 2:44 pm
by mayanktalwar1988
now it is getting serious window xp server xxamppp on localhost
Re: redirecting
Posted: Mon Sep 28, 2009 2:53 pm
by Ollie Saunders
OK, that means your web server is Apache. If you can, try and find out what the document root of Apache is configured to. I guess, there'll be some configuration system for XAMPP where that is set, so, you can find out from there.
Also, what is the full path of the PHP script?
Re: redirecting
Posted: Mon Sep 28, 2009 2:55 pm
by mayanktalwar1988
full path is localhost/pro1 i think you are asking for this under htdocs
Re: redirecting
Posted: Mon Sep 28, 2009 3:08 pm
by Ollie Saunders
I'm after the full path of the script, as it is stored on your filesystem. You should be able to find that by right-clicking on the file in explorer, choosing properties, and copy-pasting the path from that properties dialog. The path should include the file's name as well, if it doesn't, please tell me that too.
Also, could you give me the sam (full path), for that htdocs directory.
Finally, now that I think of it, I should ask if you know if you're doing any mod_rewrite stuff?
Re: redirecting
Posted: Mon Sep 28, 2009 3:11 pm
by mayanktalwar1988
hey ollie
i got it it was mine mistake actuallyyyy
i enetred
http://www.facebook.com previously it was just facebook.com obiviously with www ahead of it now its fine thank you everyone who responded to my pm