bmarker Posted August 24, 2006 Share Posted August 24, 2006 I have a super-simple CMS I'm making where someone can either delete a photo and description or change the description.The description on the first parse works fine, however after I sumbit my form, it repopulates the data, and gives me only the first letter in the original string...??? However the correct string is passed and updated in the dbase.Can someone tell my why?[img]http://www.3dubs.net/images/example.jpg[/img][code]? include("include/session.php"); if(isset($_POST['submit'])){ $propID = $_GET['propID']; $imageID = $_POST['imageID']; $image_desc = $_POST['image_desc']; mysql_connect(DB_SERVER,DB_USER,DB_PASS); mysql_select_db(DB_NAME) or die( "Unable to select database"); $update = "update images set image_desc = '$image_desc' where imageID = '$imageID' and prop_ID = '$propID'"; $update_result = mysql_query($update);} $propID = $_GET['propID']; mysql_connect(DB_SERVER,DB_USER,DB_PASS); mysql_select_db(DB_NAME) or die( "Unable to select database"); $query = "SELECT * FROM images, propdata WHERE images.prop_ID =$propID AND propdata.prop_ID =$propID"; $result = mysql_query($query); $num = mysql_num_rows($result); mysql_close(); define('PROP_PICS_PATH', '../property_pics');?><table width="770" border="1" cellspacing="0" cellpadding="5"> <tr> <td> <?if($num > 0){ $street = mysql_result($result,0,"street"); $city_state_zip = mysql_result($result,0,"city_state_zip"); $MLS_num = mysql_result($result,0,"MLS_num");}else{ echo("There are no pictures uploaded for this property.<br>"); echo("anything?".$propID); echo('<a href = "javascript:history.back()">Back to Properties</a>');}?><table> <tr> <td> <? echo($street);?><br> <? echo($city_state_zip);?><br> <? echo("MLS Number: ".$MLS_num);?> </td> </tr></table><?for($i=0;$i<$num;$i++){ $image_name[$i] = mysql_result($result,$i,"image_name"); $image_desc[$i] = mysql_result($result,$i,"image_desc"); $imageID[$i] = mysql_result($result,$i,"imageID"); echo('<form name="form1" method="post" action="'.$_SERVER['PHP_SELF'].'?propID='.$propID.'">'); echo('<input type = "hidden" name="imageID" value ="'.$imageID[$i].'">'); echo('<input type = "hidden" name="prop_ID" value ="'.$propID.'">'); echo("<table width = '100%' border='1' cellpadding='5' bgcolor='#F5F5F5'>\n <tr>\n"); echo("<td width=\"1\">\n"); echo('<img src = "'.PROP_PICS_PATH.'/'.$image_name[$i].'"/><br>'."\n"); echo("</td>\n"); echo("<td>\n"); echo('Image Description: <input type="text" name="image_desc" value ="'.$image_desc[$i].'">'."<br>\n"); echo('Remove image from database'); echo('<input type="checkbox" name="deletePic" value="1">'); echo("</td>\n"); echo("</tr>"); echo('<tr><td colspan = "3" align = "right">'); echo('<input type="submit" name ="submit" id="submit" value="Update">'); echo('</td></tr>'); echo("</table></form>\n"); }?> <table> <tr> <td> <? if($num>0){ echo('<a href = "javascript:history.back()">Back to Properties</a>'); } ?> </td> </tr> </table> </td> </tr></table>[/code] Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted August 24, 2006 Share Posted August 24, 2006 Try this:[code]<?phpinclude("include/session.php");if(isset($_POST['submit'])){ $propID = $_GET['propID']; $imageID = $_POST['imageID']; $image_desc = $_POST['image_desc']; mysql_connect(DB_SERVER,DB_USER,DB_PASS); mysql_select_db(DB_NAME) or die( "Unable to select database"); $update = "update images set image_desc = '$image_desc' where imageID = '$imageID' and prop_ID = '$propID'"; $update_result = mysql_query($update);} $propID = $_GET['propID'];mysql_connect(DB_SERVER,DB_USER,DB_PASS);mysql_select_db(DB_NAME) or die( "Unable to select database");$query = "SELECT * FROM images, propdata WHERE images.prop_ID =$propID AND propdata.prop_ID =$propID";$result = mysql_query($query) or die(mysql_error();$num = mysql_num_rows($result);define('PROP_PICS_PATH', '../property_pics');while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $html .= ' <form name="form1" method="post" action="'.$_SERVER['PHP_SELF'].'?propID=' . $propID . '"> <input type = "hidden" name="imageID" value ="' . $row['imageID'] . '"> <input type = "hidden" name="prop_ID" value ="' . $propID . '"> <table width="100%" border="1" cellpadding="5" bgcolor="#F5F5F5"> <tr> <td width="1"><img src="' . PROP_PICS_PATH . '/' . $row['image_name'] . '"/><br></td> <td> Image Description: <input type="text" name="image_desc" value ="' . $row['image_desc'] . '"><br> Remove image from database <input type="checkbox" name="deletePic" value="1"> </td> </tr> <tr> <td colspan = "3" align = "right"><input type="submit" name ="submit" id="submit" value="Update"></td> </tr> </table> </form>';}?><table width="770" border="1" cellspacing="0" cellpadding="5"> <tr> <td><?if($num > 0){ $street = mysql_result($result,0,"street"); $city_state_zip = mysql_result($result,0,"city_state_zip"); $MLS_num = mysql_result($result,0,"MLS_num");}else{ echo("There are no pictures uploaded for this property.<br>"); echo("anything?".$propID); echo('<a href = "javascript:history.back()">Back to Properties</a>');}?><table> <tr> <td> <? echo($street);?><br> <? echo($city_state_zip);?><br> <? echo("MLS Number: ".$MLS_num);?> </td> </tr></table><?php echo $html; ?> <table> <tr> <td> <? if($num>0){ echo('<a href = "javascript:history.back()">Back to Properties</a>'); } ?> </td> </tr> </table> </td> </tr></table>[/code] Quote Link to comment Share on other sites More sharing options...
bmarker Posted August 24, 2006 Author Share Posted August 24, 2006 Thanks hitman, it seemed to work. Any reason as to why my code didn't? I'm still learning PHP(obviously), but I would have though it SHOULD have worked. Hopefully you can enlighten me, so I know for other possible issues in the future.Thanks Again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.