Sunday 15 September 2013

My image in my database is not posting on my site (PHP MySQL) -



My image in my database is not posting on my site (PHP MySQL) -

so created form takes 2 file buttons (for images) 1 thumbnail , other main image , has taken files , placed in database, has gotten right directory...but have problem...when time echo images dont show up...some please help me

here form , code(all in same file called addimage.php):

<?php include'includes/connect.php'; if($_post['submit']) { $img="main/"; $img= $img . basename($_files['photo1']['name']); $tmb="thumb/"; $tmb= $tmb . basename($_files['photo2']['name']); $imagename = mysql_real_escape_string($_post['imagename']); $content = mysql_real_escape_string($_post['content']); $links = mysql_real_escape_string($_post['links']); $pic1 = "main/" .(mysql_real_escape_string($_files['photo1']['name'])); $pic2 = "thumb/" .(mysql_real_escape_string($_files['photo2']['name'])); if(move_uploaded_file($_files['photo1']['tmp_name'], $img));{ if(move_uploaded_file($_files['photo2']['tmp_name'], $tmb));{ { mysql_query("insert `portweb` ( `imagename`, `content`, `links`, `photo1`, `photo2`) values('$imagename', '$content', '$links', '$pic1', '$pic2')"); echo "files upload success"; } } } /*else { echo "upload failed"; }*/ } ?> <html> <head> <title>upload pictures portfolio web</title> </head> <body> <a href="portweb.php">back</a> <br /> <form action="addportweb.php" method="post" enctype="multipart/form-data"> <label>main image:</label> <input type="file" name="photo1" /><br /> <label>thumb:</label> <input type="file" name="photo2" /><br /> <label>name:</label> <input type="text" name="imagename" class="text_input" maxlength="100" /><br /> <label>description:</label> <textarea name="content" style="width: 300px; height:80px; padding: 5px; resize:none;" ></textarea> <br /> <label>link:</label> <textarea name="links" style="width: 100px; height:50px; padding: 5px; resize:none;" ></textarea><br /> <input type="submit" name="submit" value="upload" /> </form> </body> </html>

and here function help output...and problem:

function getportweb() { $query = mysql_query("select * portweb") or die(mysql_error()); while($post = mysql_fetch_assoc($query)){ echo "<img src =".$post['photo1']."/>"; echo "<br>"; echo "<img src =" . $post['photo2'] . "/>"; echo"<br>"; echo "<p>" . $post['imagename'] . "</p>"; echo "<br>"; echo "<p>" . $post['content'] . "</p>"; echo "<br>"; echo "<p>" . $post['links'] . "</p>"; echo "<br>"; echo "<a href=\"deleteportweb.php?id=" . $post['id'] . "\">delete</a>"; echo "<a href=\"editportweb.php?id=" . $post['id'] . "\">edit</a>"; echo "<br>"; } }

i want believe problem

echo "<img src =".$post['photo1']."/>"; echo "<br>"; echo "<img src =" . $post['photo2'] . "/>"; echo"<br>";

but got nothing...please help

try this:

echo'<img src="'.$post['photo1'].'" />';

php mysql image forms

No comments:

Post a Comment