Did you ever get this problem solved I have a similar one.
problem removing image from database
I hope someone can help me. I have a problem that I cannot solve after 3 days.
I have a form with a few text fields, into which a url is added for an image. I can get the image addresses back out of the database and display them. no problem. My problem is when I update the the form text are and try to insert nothing into the Db it always inserts a black string. i have tried to convert these stings to null values but to no avail. any thoughts would be appreciated.
Here is some of code
For inserting to DB
Code: Select all
<?php
include_once('connect_to_database.php');
if(isset($_POST['save']))
{
$issue= $_POST['issue'];
$title = $_POST['title'];
$content = nl2br($_POST['editor1']);
$pic1 = $_POST['pic1'];
$pic2 = $_POST['pic2'];
$pic3 = $_POST['pic3'];
if(!get_magic_quotes_gpc())
{
$issue = addslashes($issue);
$title = addslashes($title);
$content = addslashes($content);
}
$query="INSERT INTO `newsletter_apm` (`issue_nos` , `story_title` , `story` ,`url1` ,`url2` ,`url3` ) VALUES('$issue','$title', '$content','$pic1','$pic2','$pic3')";
$result=mysql_query($query) or die("Died inserting info into db. Error returned if any: ".mysql_error());
echo "Article '$title' added";
}
?>
This works fine.
Code for updating.
Code: Select all
<?php
if(isset($_POST['save']))
{
$issue= $_POST['issue'];
$title = $_POST['title'];
$content = ($_POST['editor1']);
$pic1 = $_POST['pic1'];
$pic2 = $_POST['pic2'];
$pic3 = $_POST['pic3'];
if(!get_magic_quotes_gpc())
{
$issue = addslashes($issue);
$title = addslashes($title);
$content = addslashes($content);
}
if ($pic2==""){ $pic2=null;}
if ($pic3==""){ $pic3=null;}
//$query="UPDATE `newsletter_apm` SET `issue_nos` , `story_title` , `story` ,`url1` ,`url2` ,`url3`
$query="UPDATE `newsletter_apm` SET issue_nos ='$issue ' Where id=$id";
$result=mysql_query($query) or die("Died inserting info into db. Error returned if any: ".mysql_error());
$query="UPDATE `newsletter_apm` SET story_title ='$title ' Where id=$id";
$result=mysql_query($query) or die("Died inserting info into db. Error returned if any: ".mysql_error());
$query="UPDATE `newsletter_apm` SET story ='$content ' Where id=$id";
$result=mysql_query($query) or die("Died inserting info into db. Error returned if any: ".mysql_error());
$query="UPDATE `newsletter_apm` SET url1 ='$pic1 ' Where id=$id";
$result=mysql_query($query) or die("Died inserting info into db. Error returned if any: ".mysql_error());
$query="UPDATE `newsletter_apm` SET url2 ='$pic2 ' Where id=$id";
$result=mysql_query($query) or die("Died inserting info into db. Error returned if any: ".mysql_error());
$query="UPDATE `newsletter_apm` SET url3 ='$pic3 ' Where id=$id";
$result=mysql_query($query) or die("Died inserting info into db. Error returned if any: ".mysql_error());
echo "Article '$title' has been updated";
}
?>
This will update with new urls no problem but if I delete one leaving a blank it inserts an blank string.
code for diaplaying pics is repeating block
Code: Select all
<tr>
<td valign="top" bgcolor="#FF0000" ><!-- // Begin Module: Standard Preheader \ -->
<table width="100%" border="0" cellpadding="10" cellspacing="0" >
<tbody><tr>
<td valign="top" bgcolor="#FFFFFF" >
<h4 style="color:#336699; font-size:18pt; font-style:bold;line-height;8pt;font-family:Verdana;margin:0pt;padding-bottom:0pt" ><?php echo $storyheading[$i]; ?></h4>
<h2 style="font-family:Verdana; font-weight:lighter; font-style:inherit; font-size:8pt; margin:0pt;"><?php echo $story[$i] ;?></h2></td>
<td width="200" valign="top" bgcolor="#FFFFFF" style="background-color:#336699; " >
<?php
//loop through the pics and only display if there is one in the database to make sure thet a placeholder does not show.
if ( $pic[$i ]!= ''){ echo "<img src= $pic[$i] name='pic1' width='200' id='logo26' /><br><br>"; }
if ( trim($pic1[$i] !='')){ echo "<img src= $pic1[$i] name='pic1' width='200' /><br><br>"; }
if ( $pic2[$i] != ''){ echo "<img src= $pic2[$i] name='pic1' width='200' />"; }
?>
</td>
</tr>
I am trying to make a dynamic mailshot with any number of stories.
you can check out a version at
http://www.pat-trick.com.au/emailshot/a ... hp?issue=1
the problem is picture placer shows in safari, chrome and most email clients.
I hope i make the issue clear.
Thanking you in advance.