Jump to content

Database or PHP adding a space -- HELP!


sw9

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.