I have added a transparent noimage.png to the blogimages folder and tried the above code as well as a blank div, but each time I make a post with no image there is still a broken image link. Am I adding it incorrectly or something?
//Puts it into an array
while($info = mysql_fetch_array( $data ))
{
//Outputs the image and other data
echo "<h4></b> ".$info['title'] . "</h4>";
echo "<b><h6>".$info['date']."</h6></b><br>";
if(isset($info['photo']))
{
echo "<p><img src=/blogimages/" . $info['photo'] . " /></p><br />";
}
else
{
echo "<p><img src='/blogimages/noimage.png' /></p><br />";
}
echo "<b><p></b> ".$info['text'] . "<p><br>";
echo "<div class='blogspacer'></div>";
}
If it makes any difference, in chrome and ie the broken image icon shows. In firefox it doesn't.
Is it a change I need to make to my addblog.php also?
//This gets all the other information from the form
$title=$_POST['title'];
$date= date("d F Y H:i:s");
$photo=($_FILES['photo']['name']);
$text=$_POST['text'];
//This keeps the formatting of text entered into the text area
$text=nl2br($text);
// Connects to your Database
mysql_connect("localhost:8888","Alexweb","*****") or die(mysql_error()) ;
mysql_select_db("Alexweb") or die(mysql_error()) ;
//Writes the information to the database
mysql_query("INSERT INTO `blogentries` VALUES ('$title', '$date', '$photo', '$text')") ;
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
//Tells you if its all ok
echo "<h4>The photo ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your entry has been added to the blog" ;
echo '<br><a href="http://www.mywebsite.com/blog2.php"> Click here to view</a>';
}
else {
//Gives an error if its not
echo "<h4>thanks for your entry .";
echo '<br><a href="http://www.mywebsite.com/blog2.php"> Click here to view</a>';
}