Ashoar Posted April 10, 2009 Share Posted April 10, 2009 I have a small area where users can add an image tags for their signature images: e.g: <img src="image url here"> This is done through a forum, you can add whatever you want, text, links or images. There is one problem. When i add an image into this form to test it, when i echo it after fetching it from the database it does not show up, instead it just has the liee broken image icon. What happens is that the code adds my website address to the beginning of the code and then the img tag does not work. Here is the code to add the image: <?php session_start(); if($_SESSION['s_logged_n'] == 'true'){ $username = $_SESSION['s_username']; include 'config.php'; if(isset($_POST['submit'])) { $sig = addslashes(trim($_POST['sig'])); $addsig="Update Users set signature='$signature' WHERE Username=$username"; } ?> <html> <head> <title>Change your signature</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="wrapper"> <div id="head">Signature</div> <br> <div id="main"> <p>Change your signature</p> <form action="<?= $_SERVER['PHP_SELF'] ?>" method="post"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr class="firstRow"> <td width="50%">Signature</td> <td width="50%"><input name="sig" type="text" class="textBox" id="sig"></td> </tr> <tr class="firstRow"> <td>Submit</td> <td><input name="submit" type="submit" class="textBox" value="Submit"></td> </tr> </table> </form> </div> </div> </body> </html> <? } mysql_close($l); ?> And i use this to fetch and output: $postcount="SELECT * from Users where Username='$username'"; $postcount2=mysql_query($postcount) or die("Could not get postcount"); $postcount3=mysql_fetch_array($postcount2); The output is then just added as an echo or a print. e.g: $postcount3[signature] If it is just text, this works just fine, but it won't work for images. Any solution? Link to comment https://forums.phpfreaks.com/topic/153469-output-image/ Share on other sites More sharing options...
Axeia Posted April 10, 2009 Share Posted April 10, 2009 Could you post an example of the <img> tag being outputted? Would help making the problem more clear. Link to comment https://forums.phpfreaks.com/topic/153469-output-image/#findComment-806305 Share on other sites More sharing options...
Ashoar Posted April 10, 2009 Author Share Posted April 10, 2009 http://mywebsite.com/forum/%5C%22http://i43.tinypic.com/ip0eag.jpg%5C%22 Link to comment https://forums.phpfreaks.com/topic/153469-output-image/#findComment-806307 Share on other sites More sharing options...
Axeia Posted April 10, 2009 Share Posted April 10, 2009 That link just gets me to an error page, redirecting to http://mywebsite.com/ (which looks an awful lot like a hijacked domain site type of design) Link to comment https://forums.phpfreaks.com/topic/153469-output-image/#findComment-806309 Share on other sites More sharing options...
Ashoar Posted April 10, 2009 Author Share Posted April 10, 2009 Im sure you would of noticed that mywebsite.com is just a dummy domain in the script i added. My proper domain is being added to the front of the image URL and the <img> tags don't work. I wanted to know if there was a way of stopping the web url being added to the front of the image. Link to comment https://forums.phpfreaks.com/topic/153469-output-image/#findComment-806310 Share on other sites More sharing options...
Stephen68 Posted April 10, 2009 Share Posted April 10, 2009 could you show the php code that you are using to echo out the img tag? I guessing it would look something like this <?php echo "<img src='".$postcount3['db_sig_value']."'>"; ?> Link to comment https://forums.phpfreaks.com/topic/153469-output-image/#findComment-806330 Share on other sites More sharing options...
Ashoar Posted April 10, 2009 Author Share Posted April 10, 2009 No i am actually fetching it straight from the database, seeing as the image tags are already on the image when they are entered into the input field. "$postcount3[signature]" I couldn't do it like that as if a user wanted to use text instead of an image that would put img tags around their text. Link to comment https://forums.phpfreaks.com/topic/153469-output-image/#findComment-806335 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.