Jump to content

slashes help


jeppers

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.