franknu Posted January 24, 2007 Share Posted January 24, 2007 i have a code that upload multiple pictures they go to the database fine my problems is that when they are call to display they dont show but when i look in the source code i noticed that they are being call in a single quote<img src='home/images/picture.jpg' width='150' height='125'>that is the example of what i am getting in my source code please help Link to comment https://forums.phpfreaks.com/topic/35515-why-my-picture-are-being-display-with-single-quote-instead-of-doble-quote/ Share on other sites More sharing options...
redbullmarky Posted January 24, 2007 Share Posted January 24, 2007 can you provide the relevent code and perhaps explain the issue a little more? Link to comment https://forums.phpfreaks.com/topic/35515-why-my-picture-are-being-display-with-single-quote-instead-of-doble-quote/#findComment-168069 Share on other sites More sharing options...
franknu Posted January 24, 2007 Author Share Posted January 24, 2007 i am uploading my pictures path with this code [code=php:0]print "<pre>"; print_r($_FILES); print "</pre>"; define ("UPLOADDIR", "/home/townsfin/public_html/business_images/"); // All POST vars to vars.. $BusinessName = mysql_real_escape_string($_POST['BusinessName']); $Slogan = mysql_real_escape_string($_POST['Slogan']); //etc... IF ($_FILES['Picture1']) : $moved1 = false; $moved2 = false; IF (is_uploaded_file($_FILES['Picture1']['tmp_name'])) : $uploadfile1 = $_FILES['Picture1']['name']; $fullpath1 = UPLOADDIR . $uploadfile1; $filename1 = $_POST['name']. "1"; IF (move_uploaded_file($_FILES['Picture1']['tmp_name'], UPLOADDIR .$filename1)) : $moved1 = true; echo "picture $fullpath1 uploaded"; ENDIF; ENDIF; IF (is_uploaded_file($_FILES['Picture2']['tmp_name'])) : $uploadfile2= $_FILES['Picture2']['name']; $fullpath2 = UPLOADDIR . $uploadfile2; $filename2=$_POST['name']. "2"; IF (move_uploaded_file($_FILES['Picture2']['tmp_name'], UPLOADDIR .$filename2)) : $moved2 = true; echo "picture $fullpath2 uploaded"; ENDIF; ENDIF; IF ($moved1 and $moved2) : $sql = "INSERT INTO `business_info` "; $sql .= "SET `BusinessName`= '$BusinessName', "; $sql .= " `Slogan`= '$Slogan', "; $sql .= " `Business_Address`= '$Business_Address', "; $sql .= " `Tel`= '$Tel', "; $sql .= " `Website`= '$Website', "; $sql .= " `Email`= '$Email', "; $sql .= " `Fax`= '$Fax', "; $sql .= " `type`= '$type', "; $sql .= " `make`= '$make', "; $sql .= " `Categories`= '$Categories', "; $sql .= " `Keyword`= '$Keyword', "; $sql .= " `Picture1`= '$fullpath1', "; $sql .= " `Headline`= '$Headline', "; $sql .= " `Slogan2`= '$Slogan2', "; $sql .= " `Description1`= '$Description1', "; $sql .= " `Description2`= '$Description2', "; $sql .= " `Description3`= '$Description3', "; $sql .= " `Picture2`= '$fullpath2', "; $sql .= " `Picture3`= '$fullpath1', "; $sql .= " `User_Name`= '$User_Name', "; $sql .= " `Password` = '$Password' "; mysql_query($sql)or die("SQL Error: $sql<br>" . mysql_error()); ENDIF; ENDIF; ?> [/code]my problem is that when i call the pictures that i uploaded they are not being display because they are being call in single quotes instead of double quotes. i was wondering how i can fix thatthank u Link to comment https://forums.phpfreaks.com/topic/35515-why-my-picture-are-being-display-with-single-quote-instead-of-doble-quote/#findComment-168077 Share on other sites More sharing options...
redbullmarky Posted January 24, 2007 Share Posted January 24, 2007 surely it's more of a HTML problem? where's the code that actually displays the image? (ie, that writes the < img > tag ? Link to comment https://forums.phpfreaks.com/topic/35515-why-my-picture-are-being-display-with-single-quote-instead-of-doble-quote/#findComment-168082 Share on other sites More sharing options...
franknu Posted January 24, 2007 Author Share Posted January 24, 2007 this is my display code [code=php:0]$image = preg_replace('#^.*/public_html#', '', $row['Picture1']); echo "<img src='$image' width='150' height='125'>"; [/code] Link to comment https://forums.phpfreaks.com/topic/35515-why-my-picture-are-being-display-with-single-quote-instead-of-doble-quote/#findComment-168109 Share on other sites More sharing options...
redbullmarky Posted January 24, 2007 Share Posted January 24, 2007 then change this line like this:[code]echo '<img src="' . $image . '" width="150" height="125">'; [/code] Link to comment https://forums.phpfreaks.com/topic/35515-why-my-picture-are-being-display-with-single-quote-instead-of-doble-quote/#findComment-168117 Share on other sites More sharing options...
redbullmarky Posted January 24, 2007 Share Posted January 24, 2007 in addition, the preg_replace seems like it's writing the wrong path. try this instead:[code]<?php$filename = basename($row['Picture1']);$image = '/business_images/' . $filename;echo '<img src="' . $image . '" width="150" height="125">';?>[/code] Link to comment https://forums.phpfreaks.com/topic/35515-why-my-picture-are-being-display-with-single-quote-instead-of-doble-quote/#findComment-168124 Share on other sites More sharing options...
ted_chou12 Posted January 24, 2007 Share Posted January 24, 2007 would double quotes work? like this:echo "<img src=\"$image\" width=\"150\" height=\"125\">"; Ted Link to comment https://forums.phpfreaks.com/topic/35515-why-my-picture-are-being-display-with-single-quote-instead-of-doble-quote/#findComment-168172 Share on other sites More sharing options...
redbullmarky Posted January 24, 2007 Share Posted January 24, 2007 Ted, yeah of course - I personally just avoid escaping quotes myself because i find it clearer and easier to debug without them, but yes it'd work your way too. Link to comment https://forums.phpfreaks.com/topic/35515-why-my-picture-are-being-display-with-single-quote-instead-of-doble-quote/#findComment-168184 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.