Canman2005 Posted March 12, 2007 Share Posted March 12, 2007 Hi all I have a simple sql statement that pulls a list of files from a sql table, I then print the name of each filename using print $rows[filename]; This works fine, unless a filename has a spae in it and then it reads everything up to the space. For example, a filename which prints ok looks like image1.jpg but if there is a space for example image 1.jpg then it prints image and forgets everything after the space. Is there a fix for this? Thanks Dave Quote Link to comment Share on other sites More sharing options...
papaface Posted March 12, 2007 Share Posted March 12, 2007 just do: $rows[filename] = preg_replace(" ", "_", $rows[filename]); That should work (it will put a _ where ever a space is), but im not an expert as regex and things like this. Quote Link to comment Share on other sites More sharing options...
Barand Posted March 12, 2007 Share Posted March 12, 2007 It would help if you showed us the code that is having this effect Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted March 12, 2007 Author Share Posted March 12, 2007 Hi My code looks like if ($rows[type] == 'application/pdf' || $rows[type] == 'text/plain') { print '<p style=margin-top:5px><strong><a href=file_uploads/'.$rows[filename].' target=_blank>View \ Download File</a></strong></p>'; } So if a filename has a space in it, then it ignore everything after the space Does that help? Quote Link to comment Share on other sites More sharing options...
papaface Posted March 12, 2007 Share Posted March 12, 2007 its your bad coding lol. should be: print '<p style=margin-top:5px><strong><a href="file_uploads/'.$rows[filename].'" target="_blank">View \ Download File</a></strong></p>'; Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted March 12, 2007 Author Share Posted March 12, 2007 oooppps Thanks Quote Link to comment 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.