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
boondox
Forum Newbie
Posts: 20 Joined: Wed Oct 08, 2008 4:58 am
Post
by boondox » Wed Oct 15, 2008 1:13 am
Ok what is supposed to happen is the clan leaders in the game can enter the link to their clans website..
Then the link shows on the main page of the game..
However when the link is clicked it tries to open the website as a subdomain of the games site instead resulting in a page not found error..
Here is the code as I have it..
anyone have a solution?
Code: Select all
if ($users[alliance]) {
$dba = mysql_db_query($dbname,"select * from $allydb where name=\"$users[alliance]\";");
$alliance = mysql_fetch_array($dba);
}
if ($alliance[flag] && $alliance[url]) {
print "<div align=center><a href=\"$alliance[url]\" target=_blank><img src=\"$alliance[flag]\" border=0></a></div><br>\n";
}
else {
if ($alliance[flag]) {
print "<div align=center><img src=\"$alliance[flag]\" border=0></div><br>\n";
}
if ($alliance[url]) {
print "<div align=center><a href=\"$alliance[url]\" target=_blank>
$alliance[alliance]'s Home Page</a></div><br>\n";
}
}
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Wed Oct 15, 2008 2:41 am
The URLs need to start with http:// or even just //.
Use
strncmp or
substr to check it it starts with "http://" - if not make the code add it.
boondox
Forum Newbie
Posts: 20 Joined: Wed Oct 08, 2008 4:58 am
Post
by boondox » Fri Oct 17, 2008 12:56 am
tasairis wrote: The URLs need to start with http:// or even just //.
Use
strncmp or
substr to check it it starts with "http://" - if not make the code add it.
Forgive me when I say I have NO Idea what you are talking about.. I am a complete n00b at coding after all...
Anyway I changed my code to this......
Code: Select all
$users = mysql_fetch_array(mysql_db_query($dbname,"select * from $playerdb where username=\"$cookie[usernamecookie]\" and password=\"$cookie[passwordcookie]\";"));
$dba = mysql_db_query($dbname,"select * from $allydb where name='$users[alliance]';");
$alliance = mysql_fetch_array($dba);
if ($users[alliance] != "" && $users[alliance] != "0") {
print "<font size=2 face=Arial><center>";
if ($alliance[flag] && $alliance[url]) {
print "<a href='http://$alliance[url]' target=_blank>
<img src=\"$alliance[flag]\" border=0></a>
<br>
\n";
} else {
if ($alliance[flag]) {
print "<img src=\"$alliance[flag]\" border=0><br>\n";
}
if ($alliance[url]) {
print "<a href='http://$alliance[url]' target=_blank>
$alliance[alliance]'s Home Page</a><br>\n";
}
Ok now this code works if they have a www. clan site...
However If they enter their site beginning with http:// it will double up the http:// part and still get a page not found error..
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Fri Oct 17, 2008 1:16 am
So only add the http:// if it isn't there already.
I posted a couple links before that will help you do that.
boondox
Forum Newbie
Posts: 20 Joined: Wed Oct 08, 2008 4:58 am
Post
by boondox » Fri Oct 17, 2008 1:23 am
yeah I checked those links already and suffice it to say that is quite a bit more advanced than my current knowledge of PHP..
At my current knowledge of php when I checked those links I felt dislexic...
oh and by the way Just so you know I am teaching myself I have no schooling other than studying the code itself...
and the few beginner sites that I have browsed...