Re: help with link from mysql

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Nov 7, 2007 5:22 PM, Joey <Joey@xxxxxxxxx> wrote:
> I have a situation where I am storing data to a blob field. Everything works
> in respect to in and out of the DB, however when we type in a link like so
>
> HYPERLINK
> "http://www.abc.com/subfolder/folder2/"http://www.abc.com/subfolder/folder2/
>
>
> the link stops at the domain, so the subfolder/folder2 is merely text at the
> end of the url, and not part of the link.
>
>
> When I write the data to the table I do this:
>
> $body = addslashes($HTTP_POST_VARS['body']);
>
>
> When I read the data from the table I am doing this:
>
> 'body'                  => stripslashes(nl2br(makeLinks($row['body']))),
>
>
> Can someone let me know what I'm doing wrong, or how to work around this?

It's hard to tell very precisely just from what you've said, but here
are some general things you can check.

1) If magic_quotes are on for your server, the value you read from the
POST will already be escaped so using addslashes() would be redundant.

2) In any event, you'll find plenty of posts around here explaining
why you should use mysql_escape_string() instead of addslashes().
Note, if #1 above is a problem, you will want to unescape the string
with stripslashes() before you pass it into mysql_escape_string().

3) It's quite possible your makeLinks() function is not quite right.
I've found that given the allowable characters in a complete URL it
can be pretty challenging to get a function to find and convert all
the URLs in a string without converting too many or too few. Your
problem sounds like this sort. After it has converted the full URL to
a link, the pattern then finds the domain name as a URL within the
HREF attribute of your anchor (A) tag and then converts THAT to a link
so that the HTML ends up looking something like this (with angle
brackets substituted for the square ones below:

[a href="http://www.abc.com/"]subfolder/folder2/"]http://www.abc.com/subfolder/folder2/[/a]

4) If you needed to use stripslashes() on the value that you read from
the database you should probably do that before you pass the value to
makeLink(). However, if you've dealt successfully with #1 and #2 above
I doubt stripslashes() is necessary. Using addslashes() or
mysql_escape_string() does not mean the value is stored with the extra
escape characters, so there are no extra characters to remove when you
select it from the database.

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux