sw9 Posted June 1, 2007 Share Posted June 1, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/53903-database-or-php-adding-a-space-help/ Share on other sites More sharing options...
Psycho Posted June 1, 2007 Share Posted June 1, 2007 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"]); Quote Link to comment https://forums.phpfreaks.com/topic/53903-database-or-php-adding-a-space-help/#findComment-266501 Share on other sites More sharing options...
sw9 Posted June 1, 2007 Author Share Posted June 1, 2007 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 Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/53903-database-or-php-adding-a-space-help/#findComment-266508 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.