Jump to content

Recommended Posts

Hi All,

 

I recently had to change all my embed code to get Quicktime Player to work in Windows. Unfortunately, now my php scripts are not working properly because a white space is getting added to the end of a field in the database (even though it doesn't appear to be this way in the database). So I am looking to use regex or something to take the database field and stop when the space begins; but I'm so far from understanding regex...I'm pretty newbie! So here is what I'm doing:

 

<?php
$id = $_GET["id"];

$video_rval = mysql_query( "SELECT a.title_num, a.filename, b.secondary_name, b.episode_name, c.series_name 
	FROM msn AS a LEFT JOIN
	mprogram_library AS b ON (a.title_num = b.title)
	LEFT JOIN series AS c ON (b.series_id = c.series_id)
	WHERE a.status = 'A' and a.program_type = 'DV File' AND b.title = '".$id."'" );

	$video_data = mysql_fetch_assoc( $video_rval );

// I need to remove any white space added to the end of this string after the $video_data variable
$filename = "http://myvideoserver.com/".$video_data["filename"];?>

 

Then from there, I plug in that variable to the Quicktime Javascript that embeds the code.

Is there an easy way to not allow a white space in the end of that variable? Help would be very, very appreciated!

Thanks,

sw

Link to comment
https://forums.phpfreaks.com/topic/53903-database-or-php-adding-a-space-help/
Share on other sites

Well, I woud try to figure out why that space is being added and fix that.

 

But, one question. Why are you grabbing so many variables from the query if you only need the filename? It would also be helpful to see how you are printing $filename into the page.

 

Anyway, no need to use regular expression. trim() should work just fine:

 

$filename = trim("http://myvideoserver.com/".$video_data["filename"]);

Thank you very much for this. I got so worked up over the errors and thinking I would have to use regex that I didn't even think of trim. I really appreciate it!

 

I am actually using the other fields I'm pulling from the DB later on in my page; I just didn't want to put up the full code. I guess I could have just put the one line up 8)

Thanks again!

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.