jeppers Posted July 10, 2011 Share Posted July 10, 2011 what i have at the moment is a upload page which uploads text to a database, which works well. the only issue is that it is adding back slashes which i don't want. this becomes a problem when i am trying to output the text as it still has the back slashes. my question is how do i upload the text with out it being manipulated at all. thanks in advance Link to comment https://forums.phpfreaks.com/topic/241566-slashes-help/ Share on other sites More sharing options...
Andy11548 Posted July 10, 2011 Share Posted July 10, 2011 Use the stripslashes() function. Link to comment https://forums.phpfreaks.com/topic/241566-slashes-help/#findComment-1240784 Share on other sites More sharing options...
jeppers Posted July 10, 2011 Author Share Posted July 10, 2011 i added the stripslashes function around my variable but it still seems to be putting the slashes in. what i am doing is creating a page so that a user can embed a youtube video. so some slashes are needed. when i upload the form it adds the slashes in to the database creating the output page to display an error but when i cut and paste the code directly into the database it works fine. so as you can see the problem is defiantly in the upload . any more advice would be great. <textarea name="video_text" cols="60" rows="8" class="widebox" id="video_text"><?php echo stripslashes($video_text); ?></textarea> Link to comment https://forums.phpfreaks.com/topic/241566-slashes-help/#findComment-1240794 Share on other sites More sharing options...
Andy11548 Posted July 10, 2011 Share Posted July 10, 2011 Hmm, that is strange. So, the code you're trying to put into the site looks like: <iframe width="560" height="349" src="http://www.youtube.com/embed/h3cE9iXIx9c" frameborder="0" allowfullscreen></iframe> correct? Link to comment https://forums.phpfreaks.com/topic/241566-slashes-help/#findComment-1240796 Share on other sites More sharing options...
jeppers Posted July 10, 2011 Author Share Posted July 10, 2011 thats correct any ideas Link to comment https://forums.phpfreaks.com/topic/241566-slashes-help/#findComment-1240797 Share on other sites More sharing options...
Andy11548 Posted July 10, 2011 Share Posted July 10, 2011 Try doing something like this: echo '<iframe width="560" height="349" src="'.$url.'" frameborder="0" allowfullscreen></iframe>'; So, insted of storing the whole code, just store the url for it. Try that. Link to comment https://forums.phpfreaks.com/topic/241566-slashes-help/#findComment-1240800 Share on other sites More sharing options...
jeppers Posted July 10, 2011 Author Share Posted July 10, 2011 i no what you are saying but the user has to be able to just copy and paste the code in. and thats it. there skills are very limited. so its still trying to find a relevant function which will not change the code at all. so if you or anyone has any other ideas please suggest. thank Link to comment https://forums.phpfreaks.com/topic/241566-slashes-help/#findComment-1240804 Share on other sites More sharing options...
Andy11548 Posted July 10, 2011 Share Posted July 10, 2011 Just create a box saying: Video URL: [__________________] then all they have to do is post the video URL into the box and then use querys to grab it and display it. It'd make it easier for them to just embedd it then, because they just go to thier web browser, get the URL and paste it in and bam, its done. Link to comment https://forums.phpfreaks.com/topic/241566-slashes-help/#findComment-1240806 Share on other sites More sharing options...
jeppers Posted July 10, 2011 Author Share Posted July 10, 2011 that's what i am trying to achieve but I seem to done it incorrectly. is there any chance you could write me some example code. i have just got lost in this solution also if i just have it as you suggested would it not be the same and automatically put the back slashes in Link to comment https://forums.phpfreaks.com/topic/241566-slashes-help/#findComment-1240810 Share on other sites More sharing options...
Andy11548 Posted July 10, 2011 Share Posted July 10, 2011 It shouldn't do, I'll write some example code now: Upload: <?php include 'connect.php'; if(isset($_POST['submit'])) { if(!empty($_POST['url'])) { // Success $uploadVQ = mysql_query("INSERT INTO `video` VALUES ('', '".$_SESSION['username']."', '".$_POST['url']."')"); echo 'Your video has been uploaded'; exit; } else { echo 'Please enter a URL.'; } } ?> <form action="example.php" method="POST"> Video URL: <input type="text" name="url" /> <input type="submit" name="submit" value="Add Video" /> </form> Retrieve: <?php include 'connect.php'; //Getting the URL from the DB $urlQ = mysql_query("SELECT * FROM `video` WHERE `username`='$username'"); $urlF = mysql_fetch_assoc($urlQ); echo '<iframe width="560" height="349" src="'.$urlF['url'].'" frameborder="0" allowfullscreen></iframe>'; ?> I have NOT tested this code, however, it looks like it'd work. ~Andy Link to comment https://forums.phpfreaks.com/topic/241566-slashes-help/#findComment-1240815 Share on other sites More sharing options...
jeppers Posted July 10, 2011 Author Share Posted July 10, 2011 thanks and i will try it now Link to comment https://forums.phpfreaks.com/topic/241566-slashes-help/#findComment-1240819 Share on other sites More sharing options...
Andy11548 Posted July 10, 2011 Share Posted July 10, 2011 Let me know any errors you get and if you still need help. You will need to make the $username variable yourself as I can't see your database etc so I don't know what it'd equal. Good Luck, Andy. Link to comment https://forums.phpfreaks.com/topic/241566-slashes-help/#findComment-1240821 Share on other sites More sharing options...
jeppers Posted July 10, 2011 Author Share Posted July 10, 2011 that works well but there is another problem and that is when you go to you tube you can't just copy the selected embedded text you want ie the addrress. so it becomes a copy, cut and then upload. i will try my best to explain when you go to youtube you have 2 options one the address of the video which is http://youtu.be/rm2D7-PCTa Which is just the link to the page but as we want it embed it. this method wont work option 2 is a we have been working but with a difference. http://www.youtube.com/embed/rm2D7-PCTaw as you can see the address are just about the same but the only difference is "embed". no you can see the problem. what do you think we can do. is there a way of splitting the address string so we can add the word embed. i am not sure what do you think Link to comment https://forums.phpfreaks.com/topic/241566-slashes-help/#findComment-1240824 Share on other sites More sharing options...
Andy11548 Posted July 10, 2011 Share Posted July 10, 2011 2 minuets, let me go a do some work and see if I can work the problem out with the whole code. I'm not advanced enough to cutting the string up, but I know it can be done. 2 minuets mate. Link to comment https://forums.phpfreaks.com/topic/241566-slashes-help/#findComment-1240825 Share on other sites More sharing options...
jeppers Posted July 10, 2011 Author Share Posted July 10, 2011 wow you have been very helpful thanks so much Link to comment https://forums.phpfreaks.com/topic/241566-slashes-help/#findComment-1240826 Share on other sites More sharing options...
Andy11548 Posted July 10, 2011 Share Posted July 10, 2011 Right, I've got a perfectly working code for me (poorly write as it took 2 seconds) uploading works, and so does retriving. Video shows up aswell. Post your 'upload.php' or what ever page it is on here please. Thanks, Andy. Link to comment https://forums.phpfreaks.com/topic/241566-slashes-help/#findComment-1240829 Share on other sites More sharing options...
jeppers Posted July 10, 2011 Author Share Posted July 10, 2011 i have cracked it!!!!!!! i have edited this line of code echo '<iframe width="560" height="349" src="'.$row['video_text'].'" frameborder="0" allowfullscreen></iframe>'; ?> to this echo '<iframe width="560" height="349" src="http://www.youtube.com/embed/'.$row['video_text'].'" frameborder="0" allowfullscreen></iframe>'; ?> so all the user has to do is add the name of the file. no address just the file. it works... hope you can see what i mean Link to comment https://forums.phpfreaks.com/topic/241566-slashes-help/#findComment-1240834 Share on other sites More sharing options...
Andy11548 Posted July 10, 2011 Share Posted July 10, 2011 Yeah, I see what you mean, but it could cause other problems because if the person copies the full URL, not knowing that you mean the "wfoijlfjasdf" part after it, it could just cause errors on your page. When I get back, if you're still on, I'll re-search on how to Split Strings and do it for you, or work out a solution. Regards, Andy. Link to comment https://forums.phpfreaks.com/topic/241566-slashes-help/#findComment-1240835 Share on other sites More sharing options...
the182guy Posted July 10, 2011 Share Posted July 10, 2011 Andy, you shouldn't be using if(isset($_POST['submit'])) to test if a form has been submitted because it's not compatible with Internet Explorer and possibly other browsers. For more info see http://www.crosscode.co.uk/php/why-using-isset-post-submit-is-not-compatible-with-internet-explorer/ Link to comment https://forums.phpfreaks.com/topic/241566-slashes-help/#findComment-1240909 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.