gammaman Posted July 7, 2012 Share Posted July 7, 2012 I am trying to strip a url submitted via a form, down to the base address and then insert it into a database. So assuming the url submitted reads www.abc.com/123/456/789/111 The url submitted to the database should be www.abc.com I am trying to use the explode function to achieve this. When I echo after doing the explode, the echo contains what I want. However when I try to write to the database, nothing gets written. <?php include("connect.php"); session_start(); connect(); // session_register('link'); $_SESSION['link'] = explode("/", $_POST['link']); echo $_SESSION['link'][0]; $insertQuery = "insert into sites(address)values(('".$_SESSION['link'][0]."'))"; mysql_query($insertQuery); ?> Quote Link to comment https://forums.phpfreaks.com/topic/265353-help-stripping-url/ Share on other sites More sharing options...
Pikachu2000 Posted July 7, 2012 Share Posted July 7, 2012 What does echo mysql_error show you? Quote Link to comment https://forums.phpfreaks.com/topic/265353-help-stripping-url/#findComment-1359899 Share on other sites More sharing options...
gammaman Posted July 7, 2012 Author Share Posted July 7, 2012 Never mind. Got it working. Turns out it was writing to the DB. On my testing page where the links are displayed is where the problem lied. Quote Link to comment https://forums.phpfreaks.com/topic/265353-help-stripping-url/#findComment-1359901 Share on other sites More sharing options...
Pikachu2000 Posted July 7, 2012 Share Posted July 7, 2012 OK. Mark it solved, if that's the case. Quote Link to comment https://forums.phpfreaks.com/topic/265353-help-stripping-url/#findComment-1359902 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.