Links being cut off due to ? symbols

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

Post Reply
mattpointblank
Forum Contributor
Posts: 304
Joined: Tue Dec 23, 2008 6:29 am

Links being cut off due to ? symbols

Post by mattpointblank »

Hi all,

Working with an MSSQL database (ugh) and my page dies before finishing the output. The data is a text field and contains a long URL with multiple parameters. I've verified that it works fine in the database - if I manually copy the row contents into a new HTML page, it displays properly.

The generated code ends like this:

Code: Select all

 <p><a href="http://i.WEBSITE.com/portal/server.pt/gateway/PTARGS_32_0_1851_0_-1_47/http;/i-collab.WEBSITE.com;7001/collab/do/document/overvie</body>
Whereas the code in the database is like this:

Code: Select all

 <p><a href="http://i.WEBSITE.com/portal/server.pt/gateway/PTARGS_32_0_1851_0_-1_47/http;/i-collab.WEBSITE.com;7001/collab/do/document/overview?projID=881618&folderID=872460">http://i.WEBSITE.com/port...</a></p> 
It's ending at the overview?projID= part - is this a special character or something?

Any tips? Thanks.
Matt
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Links being cut off due to ? symbols

Post by pickle »

? is a special character in that it denotes the beginning of the query string part of a URL. It's hard to say if it's relevant to your problem or not without seeing some code. Are you doing any regular expression matching that might be getting caught up on the '?' ?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
mattpointblank
Forum Contributor
Posts: 304
Joined: Tue Dec 23, 2008 6:29 am

Re: Links being cut off due to ? symbols

Post by mattpointblank »

Yeah, I knew it was special in that sense but there's other links on the page using that format that work fine... possibly because they're not at the end? Anyway, I was using this regex: viewtopic.php?f=1&t=94730&p=517340#p517340 but for testing I've disabled it, so it shouldn't make a difference - I'm literally just echoing out the database output.
mattpointblank
Forum Contributor
Posts: 304
Joined: Tue Dec 23, 2008 6:29 am

Re: Links being cut off due to ? symbols

Post by mattpointblank »

If it helps, my code is as basic as this:

Code: Select all

 
$query = "SELECT convert(text, Content) as Content FROM tblContent WHERE ContentID = '25'";
$result = mssql_query($query) or die;
$row = mssql_fetch_row($result);
$content = $row[0];
 
//$content = preg_replace('~<a href="([^"]*)">([^<]{26}).+?</a>~is', '<a href="$1">$2...</a>', $content);
// not using this function for now, to ensure it's working
 
echo $content;
 
This produces the code in my first post.
mattpointblank
Forum Contributor
Posts: 304
Joined: Tue Dec 23, 2008 6:29 am

Re: Links being cut off due to ? symbols

Post by mattpointblank »

Never mind, fixed it. Added this code before any output:

ini_set("mssql.textlimit", "120000");

and this just before the query:

mssql_query("set textsize 76800");

Damned MS SQL...
Post Reply