html LINK tag <a href> </a> do not work fine

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

duk
Forum Contributor
Posts: 199
Joined: Wed May 19, 2004 8:45 am
Location: London

html LINK tag <a href> </a> do not work fine

Post by duk »

hy ppl

i have a litle form to post some news into a website... but when i try to sert a link to a web page with html tags... like this :

<a href="url?sapo.pt" > here </a>

the link not apear in the post...

i use just nl2br in the variable... nothing more...

why this happen ?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Do a 'view source' on the resulting page and see what the html around the word 'here' looks like.
duk
Forum Contributor
Posts: 199
Joined: Wed May 19, 2004 8:45 am
Location: London

Post by duk »

doesn't apear anything...

i try... <a href="page?sapo.pt" > here </a> the text "here" doesn't apear...

but if i use tags like <b> or <I> other tags works fine but this <a href=">?sapo.pt" </a> doesn't work...
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

I'm presuming you're storing it in a database first? Is it going into the db ok? If so, what does the text look lik in there?
duk
Forum Contributor
Posts: 199
Joined: Wed May 19, 2004 8:45 am
Location: London

Post by duk »

yes is stored in a mysql db,

in the table, the text apears fine...
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Weird, i can't see why pulling some text from a db then passing it via a nl2br() would remove an entire <a href="...">here</a> string unless there's some strip_tags() or quote escaping going on, even then it would leave you something and not remove the enitre string.
Maybe post the code you are using to pull/display the info from the database?
duk
Forum Contributor
Posts: 199
Joined: Wed May 19, 2004 8:45 am
Location: London

Post by duk »

i don't understand your question,

Maybe post the code you are using to pull/display the info from the database?

??? can you use other words...
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

On your news page where the link is dissappearing, post the code you are using that queries the database, does the nl2br() and displays the post.
duk
Forum Contributor
Posts: 199
Joined: Wed May 19, 2004 8:45 am
Location: London

Post by duk »

code in db:

see this pages ppl:

link1: <a href=url>here</a>
link1: <a href=url>here</a>

etc...

-----------------------------

to display

$news = nl2br("$news");

echo "$news";

just like this..
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Show us ALL your code and read this viewtopic.php?t=21171
duk
Forum Contributor
Posts: 199
Joined: Wed May 19, 2004 8:45 am
Location: London

Post by duk »

its very simple

Code: Select all

<?php

$post = $_POST["news"];

//$post have for example

//hy ppl see this
//<b><a href="url>here</a><b>?sapo.pt"



$insert = "insert into news (post) values ('$post')";

$exec = mysql_db_query("sb", $insert);

//ok at here, you have put the variable $post into the database


?>



now lets see the $post...

Code: Select all

<?php

//inside db we have

//hy ppl see this<br />
//<br />
//<b><a href="url>here</a><b><br?sapo.pt" />
//<br />


$cmd = "select post from news";
$exec = mysql_db_query("db", $cmd);

$get = mysql_fetch_row($exec);

$post_news = $get[0];


$post_news = nl2br("$post_news");

echo "

         <b>$post_news</b>

";

// the text "here" will not apear in the html 


?>
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

Code: Select all

<b><a href="url>here</a><b><br?sapo.pt" />
if thats how your making a link then no wonder its not working..

use this...

Code: Select all

<b><a href="URL HERE">display text</a></b>
duk
Forum Contributor
Posts: 199
Joined: Wed May 19, 2004 8:45 am
Location: London

Post by duk »

if you are saying, i miss the " "" ??? yes i miss it but just in this post, in the db is correct...

that is not the problem, sometimes i do not put any " " "[/b]
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

lol...ok, do us all a favor and...

1) paste the data from db....
2) paste your code to display the data..
3) paste your code to insert your data..
duk
Forum Contributor
Posts: 199
Joined: Wed May 19, 2004 8:45 am
Location: London

Post by duk »

i already put it...

is that the way, but in my code i just use other portuguese words...

and the data in the db is the same
Post Reply