inferium Posted January 21, 2009 Share Posted January 21, 2009 I'm using the following code to generate a flyer-template output on the page based on values in a table. The actual page is at http://clearfrontmarketing.com/createflyer/or/ So, when I select one of these flyers from the dropdown list, the image name sometimes has a space in it. This makes it a bit tough to use the flyer on sites such as craigslist without going in and manually putting a %20 in every post. Is there a way to autofill the spaces with %20 on the output code? Or, better yet, is there a way I can have the spaces taken out of the image filename when it is uploaded? <?php include('common/dbconnect.php'); $theID = $_POST['cID']; if($theID != '') { $sql = mysql_query("SELECT * FROM tblcars WHERE cID = $theID"); $row = mysql_fetch_array($sql); $cbody = $row['cbody']; $sql3 = mysql_query("SELECT btype FROM tblbody WHERE bID = $cbody"); $row3 = mysql_fetch_array($sql3); $cdrive = $row['cdrive']; $sql4 = mysql_query("SELECT dtype FROM tbldrive WHERE dID = $cdrive"); $row4 = mysql_fetch_array($sql4); } echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Language" content="en-us" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Car Website</title> <link rel="stylesheet" href="common/style.css" type="text/css" /> </head> <body> <------------snipsnipsniplet'sskipsomeofthis-----------> <TABLE WIDTH="600" HEIGHT="20" BORDER="0" CELLPADDING="0"> <TR> <TD style="color:#f0f0f0;background-color:#000000"> <FONT SIZE="5"><b>'.$row['ctitle'].'</b></FONT></TD> </TR> <TR> <TD> <FONT SIZE="4"><b>'.$row['cslogan'].'</b></FONT> </TD> </TR> </TABLE> </TD> </TR> <TR> <TD> <TABLE> <TR> <TD WIDTH="310" ALIGN="center"> '; if($row['cphoto'] == '') { echo '<img src="http://www.clearfrontmarketing.com/createflyer/or/images/nophoto.gif" />'; } elseif($row['cphoto'] != '') { echo '<img src="http://www.clearfrontmarketing.com/createflyer/or/images/cars/'.$row['cphoto'].'" style="width: 300px;" />'; } echo ' </TD> Thanks a bunch Link to comment https://forums.phpfreaks.com/topic/141858-solved-autofill-spaces-in-filename-outputtext/ Share on other sites More sharing options...
sasa Posted January 21, 2009 Share Posted January 21, 2009 look <?php echo rawurlencode('s a s a'); ?> Link to comment https://forums.phpfreaks.com/topic/141858-solved-autofill-spaces-in-filename-outputtext/#findComment-742751 Share on other sites More sharing options...
inferium Posted January 21, 2009 Author Share Posted January 21, 2009 look <?php echo rawurlencode('s a s a'); ?> Ah, sweet. So how would I use that in this phrase? EDIT: namely, the part where cphoto is being used. '; if($row['cphoto'] == '') { echo '<img src="http://www.clearfrontmarketing.com/createflyer/or/images/nophoto.gif" />'; } elseif($row['cphoto'] != '') { echo '<img src="http://www.clearfrontmarketing.com/createflyer/or/images/cars/'.$row['cphoto'].'" style="width: 300px;" />'; } echo ' Link to comment https://forums.phpfreaks.com/topic/141858-solved-autofill-spaces-in-filename-outputtext/#findComment-742759 Share on other sites More sharing options...
sasa Posted January 21, 2009 Share Posted January 21, 2009 [/code]... er/or/images/cars/'.rawurlencode($row['cphoto']).'" style="width: ...[/code] Link to comment https://forums.phpfreaks.com/topic/141858-solved-autofill-spaces-in-filename-outputtext/#findComment-742765 Share on other sites More sharing options...
inferium Posted January 21, 2009 Author Share Posted January 21, 2009 Ah sweet, I understand now. Thank you very much! I was sitting there messing with the code for a while and kept getting errors, but that example clears up everything Link to comment https://forums.phpfreaks.com/topic/141858-solved-autofill-spaces-in-filename-outputtext/#findComment-742767 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.