aircool Posted January 10, 2009 Share Posted January 10, 2009 Right this is going to be hard to put. Outline: Basically i'm attempting to build a basic CMS, using parts of code created by your truly and parts/plugins from other sources (Tiny MCE for example). Now the problem I have now is when I am in editor, the links to say off site or even in some cases on site links usually have an odd bit of URL added to them. For example, http://localhost/%22http://www.google.co.uk/%22 . The bolded text is where its going wrong, from what I've been playing with if I remove the the "\" 's database (MySql) the link works correctly. In the base the link is saved as: <p><a title=\"12\" href=\"http://www.google.co.uk\" target=\"_blank\">Google</a></p> But removing the \\'s fixes it: <p><a title="12" href="http://www.google.co.uk" target=\"_blank\">Google</a></p> I struggling to see where I'm going wrong. Link to comment https://forums.phpfreaks.com/topic/140341-problem-with-links-and-how-the-are-stored-and-pulled-from-a-database/ Share on other sites More sharing options...
aircool Posted January 11, 2009 Author Share Posted January 11, 2009 Bump, really would like a splash of help Link to comment https://forums.phpfreaks.com/topic/140341-problem-with-links-and-how-the-are-stored-and-pulled-from-a-database/#findComment-734865 Share on other sites More sharing options...
trq Posted January 11, 2009 Share Posted January 11, 2009 Can we see some actual code where you attempt to display these links? Link to comment https://forums.phpfreaks.com/topic/140341-problem-with-links-and-how-the-are-stored-and-pulled-from-a-database/#findComment-734874 Share on other sites More sharing options...
aircool Posted January 11, 2009 Author Share Posted January 11, 2009 Can we see some actual code where you attempt to display these links? All links/content come up to the index.php, where its displayed. <?php session_start(); ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>www.BeforeDark.co.uk</title> <?php include("includes/config.php"); ?> <style type="text/css"> <!-- #header { position:absolute; left:15%; top:86px; width:70%; height:121px; z-index:1; text-align: center; background-color: #333333; } #menubar { position:absolute; left:15%; top:199px; width:70%; height:42px; z-index:2; background-color: #666666; text-align: center; color: #FFF; margin: 0px; padding: 0px; border-top-width: thin; border-right-width: thin; border-bottom-width: thin; border-left-width: thin; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; } --> </style> <script src="css/SpryMenuBar.js" type="text/javascript"></script> <link href="css/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- #maincontent { position:absolute; left:15%; top:239px; width:70%; height:499px; z-index:20; visibility: visible; background-image: url(components/images/bkgroundcontent.png); font-weight: bold; color: #FFF; font-family: Verdana, Geneva, sans-serif; font-size: 12px; text-align: center; } #apDiv1 { position:absolute; left:15%; top:678px; width:70%; height:58px; z-index:21; background-color: #999999; text-align: center; } #footer { position:absolute; left:15%; top:748px; width:70%; height:42px; z-index:21; background-color: #999999; } body { background-color: #FFF; } --> </style> </head> <body> <div id="header"><img src="components/images/beforedarkheader.png" width="600" height="121" /></div> <div id="menubar"><?php include('includes/menubarv2.php'); ?></div> <div id="maincontent"> <p>Welcome to <?php echo "$sitename"; ?>'s new website.</p> <p><? include("includes/common.php"); $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : ''; $seoname = isset($_REQUEST['seoname']) ? $_REQUEST ['seoname'] : ''; if( !empty($seoname) ){ $seoname = explode("-",$seoname); $seoname = end($seoname); } ?> <table width=100%> <tr> <td width=180 bgcolor="#666666"> <? $leftMenu = getPages('parent','0'); foreach($leftMenu as $id=>$page){ echo "<a href='{$page['seoname']}.html'>{$page['title']} </a><br/>"; } ?> </td> <td width="739"> <? if( !empty($seoname) ){ $page = getPage('seoname',$seoname); }else{ $page = getPage('id','1'); } ?> <h1><?=$page['title']?></h1> <p><?=nl2br($page['body'])?></p> <? $kids = getPages('parent',$page['id']); if( count($kids) > 0 ){ foreach($kids as $id=>$kid){ echo "<a href='{$page['seoname']}-{$kid['seoname']}.html'> {$kid['title']}</a><br/>"; echo "<p>{$kid['summary']}</p>"; } } ?> </td> </tr> </table> </p> </div> <div id="footer"><?php include('includes/footer.php'); ?></div> </body> </html> Would it be easier to upload the entire thing as a ZIP folder? Link to comment https://forums.phpfreaks.com/topic/140341-problem-with-links-and-how-the-are-stored-and-pulled-from-a-database/#findComment-734900 Share on other sites More sharing options...
RestlessThoughts Posted January 11, 2009 Share Posted January 11, 2009 "%22" means there's a space in the URL. I'm not totally sure I understand your problem, but here's my guess at a solution. Before you insert the links into the database, strip the slashes (ie: stripslashes($link). You don't need the slashes in a MySql database, it seems to handle quote marks just fine, only when using php (and you can add the slashes back with addslashes($link) if need be). So yes, keep taking out the slashes from the database and the links will hopefully work correctly. Link to comment https://forums.phpfreaks.com/topic/140341-problem-with-links-and-how-the-are-stored-and-pulled-from-a-database/#findComment-734932 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.