happypete Posted October 2, 2009 Share Posted October 2, 2009 pache version 1.3.41 (Unix) PHP version 5.2.6 MySQL version 5.0.81-community Architecture x86_64 Operating system Linux Simiular to the problem i had here: http://www.phpfreaks.com/forums/index.php/topic,271119.0.html I have integrated an image resize script with a multiple row display and update script. It uploads the image to a directory and saves the url to the database. It also displays the thumbnail on the page with the description and order, but I cant get it to update the description. <?php $submit = $_POST['submit']; $rank = $_POST['rank']; $description = $_POST['description']; $id = $_POST['id']; // Check if button name "Submit" is active, do this if($submit){ for($i=0;$i<$count;$i++){ $sql1= mysql_query("UPDATE photo SET rank='{$_POST['rank']}', description='{$_POST['description']}' WHERE id=$id"); $result1=mysql_query($sql1); } } if($result1){ header("location:index1.php"); } mysql_close(); // It double checks to see if I'm logged in require_once 'sources/login/classes/Membership.php'; $membership = New Membership(); $membership->confirm_Member(); $db_name = "trek_trek"; $db_server = "localhost"; $db_user = "trek_user"; $db_pass = "intergreen"; $mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name) or die(mysqli_error()); error_reporting(0); $picdescription = addslashes($_POST['picdescription']); $change=""; $abc=""; define ("MAX_SIZE","400"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if($_SERVER["REQUEST_METHOD"] == "POST") { $image =$_FILES["file"]["name"]; $uploadedfile = $_FILES['file']['tmp_name']; if ($image) { $filename = stripslashes($_FILES['file']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { $change='<div class="msgdiv">Unknown Image extension </div> '; $errors=1; } else { $size=filesize($_FILES['file']['tmp_name']); if ($size > MAX_SIZE*1024) { $change='<div class="msgdiv">You have exceeded the size limit!</div> '; $errors=1; } if($extension=="jpg" || $extension=="jpeg" ) { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); } else if($extension=="png") { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefrompng($uploadedfile); } else { $src = imagecreatefromgif($uploadedfile); } echo $scr; list($width,$height)=getimagesize($uploadedfile); $newwidth=600; $newheight=($height/$width)*$newwidth; $tmp=imagecreatetruecolor($newwidth,$newheight); $newwidth1=200; $newheight1=($height/$width)*$newwidth1; $tmp1=imagecreatetruecolor($newwidth1,$newheight1); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); $filename = "uploads/". $_FILES['file']['name']; $filename1 = "uploads/tn/". $_FILES['file']['name']; imagejpeg($tmp,$filename,100); imagejpeg($tmp1,$filename1,100); imagedestroy($src); imagedestroy($tmp); imagedestroy($tmp1); }} } //If no errors registred, print the success message if(isset($_POST['Submit']) && !$errors) { $q = "INSERT into photo(description, src, tn_src) VALUES('$picdescription', '$filename', '$filename1')"; $result = $mysqli->query($q) or die(mysqli_error($mysqli)); if($result) { $change=' <div class="msgdiv">Image Uploaded Successfully!</div>'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Admin Page</title> <link rel="stylesheet" href="sources/styles.css" type="text/css" /> <link rel="stylesheet" href="admin.css" type="text/css" /> </head> <body> <div id="container"> <div id="header"> <h1>Admin page</h1> </div> <div id="content"> <div id="page"> <?php echo $change; ?> <table width="502" cellpadding="0" cellspacing="0" id="main"> <tbody> <tr> <td width="500" height="238" valign="top" id="main_right"> <div id="posts"> <form method="post" action="" enctype="multipart/form-data" name="form1"> <table width="500" border="0" align="center" cellpadding="0" cellspacing="0"> <tr><Td style="height:25px"> </Td></tr> <tr> <td width="150"><div align="right" class="titles">Picture : </div></td> <td width="350" align="left"> <div align="left"> <input size="25" name="file" type="file" style="font-family:Verdana; font-size:10pt" class="box"/> </div></td> </tr> <tr><Td></Td> <Td valign="top" height="35px" class="help">Image maximum size <b>400 </b>kb</span></Td> </tr> <tr> <Td></Td> <Td valign="top" height="35px"> <label for="picdescription">Description</label><br /> <input type="text" name="picdescription" value="" /><br /></Td> </tr> <tr><Td></Td><Td valign="top" height="35px"><input type="submit" id="mybut" value="Upload" name="Submit"/></Td></tr> <tr> <td width="200"> </td> <td width="200"><table width="200" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="200" align="center"><div align="left"></div></td> <td width="100"> </td> </tr> </table></td> </tr> </table> </form> </div> </td> </tr> </tbody> </table> <form method="POST" action=""> <? include('testconfig.php'); $result = mysql_query("SELECT * FROM photo ORDER BY rank ASC") or die("Bad query: ".mysql_error()); while ( $row = mysql_fetch_array($result) ) { ?> <input type="text" name="<? print $row['rank'] ;?>" size="2" value="<? print $row['rank'] ;?>"> <input type="text" name="<? print $row['description'] ;?>" size="" value="<? print $row['description'] ;?>"> <? echo "<img src=\"".$row['tn_src']."\"/>"; echo " <a href=delete1.php?id={$row['id']}>Delete</a><br>"; } // END WHILE ?> <input type="submit" value="Update" name="submit"> </form> </div> Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/ Share on other sites More sharing options...
MadTechie Posted October 2, 2009 Share Posted October 2, 2009 your form says 'picdescription' you php code says 'description' update one of them (ie) change <input type="text" name="picdescription" value="" /><br /></Td> to <input type="text" name="description" value="" /><br /></Td> also <input type="text" name="<? print $row['rank'] ;?>" size="2" value="<? print $row['rank'] ;?>"> <input type="text" name="<? print $row['description'] ;?>" size="" value="<? print $row['description'] ;?>"> should be <input type="text" name="rank" size="2" value="<?php print $row['rank'] ;?>"> <input type="text" name="description" size="" value="<?php print $row['description'] ;?>"> Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929047 Share on other sites More sharing options...
happypete Posted October 2, 2009 Author Share Posted October 2, 2009 thats 'picdescription' for the upload and 'description' for the update...they were the same before and i changed them as i thought they could not be the same...but either way it doesn't update Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929054 Share on other sites More sharing options...
MadTechie Posted October 2, 2009 Share Posted October 2, 2009 can you post your updated code Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929120 Share on other sites More sharing options...
happypete Posted October 2, 2009 Author Share Posted October 2, 2009 updated script: <?php $submit = $_POST['submit']; $rank = $_POST['rank']; $description = $_POST['description']; $id = $_POST['id']; // Check if button name "Submit" is active, do this if($submit){ for($i=0;$i<$count;$i++){ $sql1= mysql_query("UPDATE photo SET rank='{$_POST['rank']}', description='{$_POST['description']}' WHERE id=$id"); $result1=mysql_query($sql1); } } if($result1){ header("location:index1.php"); } mysql_close(); // It double checks to see if I'm logged in require_once 'sources/login/classes/Membership.php'; $membership = New Membership(); $membership->confirm_Member(); $db_name = "trek_trek"; $db_server = "localhost"; $db_user = "trek_user"; $db_pass = "intergreen"; $mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name) or die(mysqli_error()); error_reporting(0); $picdescription = addslashes($_POST['picdescription']); $change=""; $abc=""; define ("MAX_SIZE","400"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if($_SERVER["REQUEST_METHOD"] == "POST") { $image =$_FILES["file"]["name"]; $uploadedfile = $_FILES['file']['tmp_name']; if ($image) { $filename = stripslashes($_FILES['file']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { $change='<div class="msgdiv">Unknown Image extension </div> '; $errors=1; } else { $size=filesize($_FILES['file']['tmp_name']); if ($size > MAX_SIZE*1024) { $change='<div class="msgdiv">You have exceeded the size limit!</div> '; $errors=1; } if($extension=="jpg" || $extension=="jpeg" ) { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); } else if($extension=="png") { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefrompng($uploadedfile); } else { $src = imagecreatefromgif($uploadedfile); } echo $scr; list($width,$height)=getimagesize($uploadedfile); $newwidth=600; $newheight=($height/$width)*$newwidth; $tmp=imagecreatetruecolor($newwidth,$newheight); $newwidth1=200; $newheight1=($height/$width)*$newwidth1; $tmp1=imagecreatetruecolor($newwidth1,$newheight1); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); $filename = "uploads/". $_FILES['file']['name']; $filename1 = "uploads/tn/". $_FILES['file']['name']; imagejpeg($tmp,$filename,100); imagejpeg($tmp1,$filename1,100); imagedestroy($src); imagedestroy($tmp); imagedestroy($tmp1); }} } //If no errors registred, print the success message if(isset($_POST['Submit']) && !$errors) { $q = "INSERT into photo(description, src, tn_src) VALUES('$picdescription', '$filename', '$filename1')"; $result = $mysqli->query($q) or die(mysqli_error($mysqli)); if($result) { $change=' <div class="msgdiv">Image Uploaded Successfully!</div>'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Admin Page</title> <link rel="stylesheet" href="sources/styles.css" type="text/css" /> <link rel="stylesheet" href="admin.css" type="text/css" /> </head> <body> <div id="container"> <div id="header"> <h1>Admin page</h1> </div> <div id="content"> <div id="page"> <?php echo $change; ?> <table width="502" cellpadding="0" cellspacing="0" id="main"> <tbody> <tr> <td width="500" height="238" valign="top" id="main_right"> <div id="posts"> <form method="post" action="" enctype="multipart/form-data" name="form1"> <table width="500" border="0" align="center" cellpadding="0" cellspacing="0"> <tr><Td style="height:25px"> </Td></tr> <tr> <td width="150"><div align="right" class="titles">Picture : </div></td> <td width="350" align="left"> <div align="left"> <input size="25" name="file" type="file" style="font-family:Verdana; font-size:10pt" class="box"/> </div></td> </tr> <tr><Td></Td> <Td valign="top" height="35px" class="help">Image maximum size <b>400 </b>kb</span></Td> </tr> <tr> <Td></Td> <Td valign="top" height="35px"> <label for="picdescription">Description</label><br /> <input type="text" name="picdescription" value="" /><br /></Td> </tr> <tr><Td></Td><Td valign="top" height="35px"><input type="submit" id="mybut" value="Upload" name="Submit"/></Td></tr> <tr> <td width="200"> </td> <td width="200"><table width="200" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="200" align="center"><div align="left"></div></td> <td width="100"> </td> </tr> </table></td> </tr> </table> </form> </div> </td> </tr> </tbody> </table> <form method="POST" action=""> <?php include('testconfig.php'); $result = mysql_query("SELECT * FROM photo ORDER BY rank ASC") or die("Bad query: ".mysql_error()); while ( $row = mysql_fetch_array($result) ) { ?> <input type="text" name="rank" size="2" value="<?php print $row['rank'] ;?>"> <input type="text" name="description" size="" value="<?php print $row['description'] ;?>"> <?php echo "<img src=\"".$row['tn_src']."\"/>"; echo " <a href=delete1.php?id={$row['id']}>Delete</a><br>"; } // END WHILE ?> <input type="submit" value="Update" name="submit"> </form> </div> Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929227 Share on other sites More sharing options...
MadTechie Posted October 2, 2009 Share Posted October 2, 2009 You missed this part! your form says 'picdescription' you php code says 'description' update one of them (ie) change <input type="text" name="picdescription" value="" /><br /></Td> to <input type="text" name="description" value="" /><br /></Td> do a find in your code for "picdescription" and replace them both with 'description' Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929281 Share on other sites More sharing options...
happypete Posted October 2, 2009 Author Share Posted October 2, 2009 piddescription replaced here is the script now.. still not working <?php $submit = $_POST['submit']; $rank = $_POST['rank']; $description = $_POST['description']; $id = $_POST['id']; // Check if button name "Submit" is active, do this if($submit){ for($i=0;$i<$count;$i++){ $sql1= mysql_query("UPDATE photo SET rank='{$_POST['rank']}', description='{$_POST['description']}' WHERE id=$id"); $result1=mysql_query($sql1); } } if($result1){ header("location:index1.php"); } mysql_close(); // It double checks to see if I'm logged in require_once 'sources/login/classes/Membership.php'; $membership = New Membership(); $membership->confirm_Member(); $db_name = "trek_trek"; $db_server = "localhost"; $db_user = "trek_user"; $db_pass = "intergreen"; $mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name) or die(mysqli_error()); error_reporting(0); $description = addslashes($_POST['description']); $change=""; $abc=""; define ("MAX_SIZE","400"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if($_SERVER["REQUEST_METHOD"] == "POST") { $image =$_FILES["file"]["name"]; $uploadedfile = $_FILES['file']['tmp_name']; if ($image) { $filename = stripslashes($_FILES['file']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { $change='<div class="msgdiv">Unknown Image extension </div> '; $errors=1; } else { $size=filesize($_FILES['file']['tmp_name']); if ($size > MAX_SIZE*1024) { $change='<div class="msgdiv">You have exceeded the size limit!</div> '; $errors=1; } if($extension=="jpg" || $extension=="jpeg" ) { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); } else if($extension=="png") { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefrompng($uploadedfile); } else { $src = imagecreatefromgif($uploadedfile); } echo $scr; list($width,$height)=getimagesize($uploadedfile); $newwidth=600; $newheight=($height/$width)*$newwidth; $tmp=imagecreatetruecolor($newwidth,$newheight); $newwidth1=200; $newheight1=($height/$width)*$newwidth1; $tmp1=imagecreatetruecolor($newwidth1,$newheight1); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); $filename = "uploads/". $_FILES['file']['name']; $filename1 = "uploads/tn/". $_FILES['file']['name']; imagejpeg($tmp,$filename,100); imagejpeg($tmp1,$filename1,100); imagedestroy($src); imagedestroy($tmp); imagedestroy($tmp1); }} } //If no errors registred, print the success message if(isset($_POST['Submit']) && !$errors) { $q = "INSERT into photo(description, src, tn_src) VALUES('$description', '$filename', '$filename1')"; $result = $mysqli->query($q) or die(mysqli_error($mysqli)); if($result) { $change=' <div class="msgdiv">Image Uploaded Successfully!</div>'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Admin Page</title> <link rel="stylesheet" href="sources/styles.css" type="text/css" /> <link rel="stylesheet" href="admin.css" type="text/css" /> </head> <body> <div id="container"> <div id="header"> <h1>Admin page</h1> </div> <div id="content"> <div id="page"> <?php echo $change; ?> <table width="502" cellpadding="0" cellspacing="0" id="main"> <tbody> <tr> <td width="500" height="238" valign="top" id="main_right"> <div id="posts"> <form method="post" action="" enctype="multipart/form-data" name="form1"> <table width="500" border="0" align="center" cellpadding="0" cellspacing="0"> <tr><Td style="height:25px"> </Td></tr> <tr> <td width="150"><div align="right" class="titles">Picture : </div></td> <td width="350" align="left"> <div align="left"> <input size="25" name="file" type="file" style="font-family:Verdana; font-size:10pt" class="box"/> </div></td> </tr> <tr><Td></Td> <Td valign="top" height="35px" class="help">Image maximum size <b>400 </b>kb</span></Td> </tr> <tr> <Td></Td> <Td valign="top" height="35px"> <label for="description">Description</label><br /> <input type="text" name="description" value="" /><br /></Td> </tr> <tr><Td></Td><Td valign="top" height="35px"><input type="submit" id="mybut" value="Upload" name="Submit"/></Td></tr> <tr> <td width="200"> </td> <td width="200"><table width="200" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="200" align="center"><div align="left"></div></td> <td width="100"> </td> </tr> </table></td> </tr> </table> </form> </div> </td> </tr> </tbody> </table> <form method="POST" action=""> <?php include('testconfig.php'); $result = mysql_query("SELECT * FROM photo ORDER BY rank ASC") or die("Bad query: ".mysql_error()); while ( $row = mysql_fetch_array($result) ) { ?> <input type="text" name="rank" size="2" value="<?php print $row['rank'] ;?>"> <input type="text" name="description" size="" value="<?php print $row['description'] ;?>"> <?php echo "<img src=\"".$row['tn_src']."\"/>"; echo " <a href=delete1.php?id={$row['id']}>Delete</a><br>"; } // END WHILE ?> <input type="submit" value="submit" name="submit"> </form> </div> Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929287 Share on other sites More sharing options...
MadTechie Posted October 2, 2009 Share Posted October 2, 2009 change // Check if button name "Submit" is active, do this if($submit){ for($i=0;$i<$count;$i++){ $sql1= mysql_query("UPDATE photo SET rank='{$_POST['rank']}', description='{$_POST['description']}' WHERE id=$id"); $result1=mysql_query($sql1); } } to // Check if button name "Submit" is active, do this if($submit){ $sql1= mysql_query("UPDATE photo SET rank='{$_POST['rank']}', description='{$_POST['description']}' WHERE id=$id"); $result1=mysql_query($sql1); } %count isn't set and i see no reason for having that code Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929295 Share on other sites More sharing options...
happypete Posted October 2, 2009 Author Share Posted October 2, 2009 thanks MadTechie, changed that but it's still NOT working any other ideas ? <?php $submit = $_POST['submit']; $rank = $_POST['rank']; $description = $_POST['description']; $id = $_POST['id']; // Check if button name "Submit" is active, do this if($submit){ $sql1= mysql_query("UPDATE photo SET rank='{$_POST['rank']}', description='{$_POST['description']}' WHERE id=$id"); $result1=mysql_query($sql1); } if($result1){ header("location:index1.php"); } mysql_close(); // It double checks to see if I'm logged in require_once 'sources/login/classes/Membership.php'; $membership = New Membership(); $membership->confirm_Member(); $db_name = "trek_trek"; $db_server = "localhost"; $db_user = "trek_user"; $db_pass = "intergreen"; $mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name) or die(mysqli_error()); error_reporting(0); $description = addslashes($_POST['description']); $change=""; $abc=""; define ("MAX_SIZE","400"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if($_SERVER["REQUEST_METHOD"] == "POST") { $image =$_FILES["file"]["name"]; $uploadedfile = $_FILES['file']['tmp_name']; if ($image) { $filename = stripslashes($_FILES['file']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { $change='<div class="msgdiv">Unknown Image extension </div> '; $errors=1; } else { $size=filesize($_FILES['file']['tmp_name']); if ($size > MAX_SIZE*1024) { $change='<div class="msgdiv">You have exceeded the size limit!</div> '; $errors=1; } if($extension=="jpg" || $extension=="jpeg" ) { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); } else if($extension=="png") { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefrompng($uploadedfile); } else { $src = imagecreatefromgif($uploadedfile); } echo $scr; list($width,$height)=getimagesize($uploadedfile); $newwidth=600; $newheight=($height/$width)*$newwidth; $tmp=imagecreatetruecolor($newwidth,$newheight); $newwidth1=200; $newheight1=($height/$width)*$newwidth1; $tmp1=imagecreatetruecolor($newwidth1,$newheight1); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); $filename = "uploads/". $_FILES['file']['name']; $filename1 = "uploads/tn/". $_FILES['file']['name']; imagejpeg($tmp,$filename,100); imagejpeg($tmp1,$filename1,100); imagedestroy($src); imagedestroy($tmp); imagedestroy($tmp1); }} } //If no errors registred, print the success message if(isset($_POST['Submit']) && !$errors) { $q = "INSERT into photo(description, src, tn_src) VALUES('$description', '$filename', '$filename1')"; $result = $mysqli->query($q) or die(mysqli_error($mysqli)); if($result) { $change=' <div class="msgdiv">Image Uploaded Successfully!</div>'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Admin Page</title> <link rel="stylesheet" href="sources/styles.css" type="text/css" /> <link rel="stylesheet" href="admin.css" type="text/css" /> </head> <body> <div id="container"> <div id="header"> <h1>Admin page</h1> </div> <div id="content"> <div id="page"> <?php echo $change; ?> <table width="502" cellpadding="0" cellspacing="0" id="main"> <tbody> <tr> <td width="500" height="238" valign="top" id="main_right"> <div id="posts"> <form method="post" action="" enctype="multipart/form-data" name="form1"> <table width="500" border="0" align="center" cellpadding="0" cellspacing="0"> <tr><Td style="height:25px"> </Td></tr> <tr> <td width="150"><div align="right" class="titles">Picture : </div></td> <td width="350" align="left"> <div align="left"> <input size="25" name="file" type="file" style="font-family:Verdana; font-size:10pt" class="box"/> </div></td> </tr> <tr><Td></Td> <Td valign="top" height="35px" class="help">Image maximum size <b>400 </b>kb</span></Td> </tr> <tr> <Td></Td> <Td valign="top" height="35px"> <label for="description">Description</label><br /> <input type="text" name="description" value="" /><br /></Td> </tr> <tr><Td></Td><Td valign="top" height="35px"><input type="submit" id="mybut" value="Upload" name="Submit"/></Td></tr> <tr> <td width="200"> </td> <td width="200"><table width="200" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="200" align="center"><div align="left"></div></td> <td width="100"> </td> </tr> </table></td> </tr> </table> </form> </div> </td> </tr> </tbody> </table> <form method="POST" action=""> <?php include('testconfig.php'); $result = mysql_query("SELECT * FROM photo ORDER BY rank ASC") or die("Bad query: ".mysql_error()); while ( $row = mysql_fetch_array($result) ) { ?> <input type="text" name="rank" size="2" value="<?php print $row['rank'] ;?>"> <input type="text" name="description" size="" value="<?php print $row['description'] ;?>"> <?php echo "<img src=\"".$row['tn_src']."\"/>"; echo " <a href=delete1.php?id={$row['id']}>Delete</a><br>"; } // END WHILE ?> <input type="submit" value="submit" name="submit"> </form> </div> Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929298 Share on other sites More sharing options...
MadTechie Posted October 2, 2009 Share Posted October 2, 2009 $submit = $_POST['submit']; should be $submit = $_POST['Submit']; Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929368 Share on other sites More sharing options...
happypete Posted October 2, 2009 Author Share Posted October 2, 2009 still not working the upper case 'S' does not match up with the 'submit' for the update...it matched the 'submit' for the upload, but that was working fine.... Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929371 Share on other sites More sharing options...
cags Posted October 2, 2009 Share Posted October 2, 2009 I'd personally say that... $submit = $_POST['submit']; Was correct and you should change it back, because thats what matches the form. MadTechie was probably thinking of this bit... if(isset($_POST['Submit']) && !$errors) which probably wants changing to... if(isset($submit) && !$errors) Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929376 Share on other sites More sharing options...
cags Posted October 3, 2009 Share Posted October 3, 2009 Scratch what I said, didn't realise there were two form one with button named Submit and another with button named submit, that is REALLY confusing. EDIT: On second look at the code it would make far more sense to rename the first submit button to "upload" and the other to "update". Then change any reference in code to Submit or submit to upload or update dependent on which job they are related to. Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929383 Share on other sites More sharing options...
happypete Posted October 3, 2009 Author Share Posted October 3, 2009 Ok changed the 's' back, then changed the other submit bit, but it stopped working...that was again for the upload part that is working, it id the update bit that is not working... Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929387 Share on other sites More sharing options...
cags Posted October 3, 2009 Share Posted October 3, 2009 See the EDIT of my last post. Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929391 Share on other sites More sharing options...
happypete Posted October 3, 2009 Author Share Posted October 3, 2009 ok made the buttons different to make it clearer..but it still doesnt update... full code up to now... <?php $Update = $_POST['Update']; $rank = $_POST['rank']; $description = $_POST['description']; $id = $_POST['id']; // Check if button name "Submit" is active, do this if($submit){ $sql1= mysql_query("UPDATE photo SET rank='{$_POST['rank']}', description='{$_POST['description']}' WHERE id=$id"); $result1=mysql_query($sql1); } if($result1){ header("location:index1.php"); } mysql_close(); // It double checks to see if I'm logged in require_once 'sources/login/classes/Membership.php'; $membership = New Membership(); $membership->confirm_Member(); $db_name = "trek_trek"; $db_server = "localhost"; $db_user = "trek_user"; $db_pass = "intergreen"; $mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name) or die(mysqli_error()); error_reporting(0); $description = addslashes($_POST['description']); $change=""; $abc=""; define ("MAX_SIZE","400"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if($_SERVER["REQUEST_METHOD"] == "POST") { $image =$_FILES["file"]["name"]; $uploadedfile = $_FILES['file']['tmp_name']; if ($image) { $filename = stripslashes($_FILES['file']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { $change='<div class="msgdiv">Unknown Image extension </div> '; $errors=1; } else { $size=filesize($_FILES['file']['tmp_name']); if ($size > MAX_SIZE*1024) { $change='<div class="msgdiv">You have exceeded the size limit!</div> '; $errors=1; } if($extension=="jpg" || $extension=="jpeg" ) { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); } else if($extension=="png") { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefrompng($uploadedfile); } else { $src = imagecreatefromgif($uploadedfile); } echo $scr; list($width,$height)=getimagesize($uploadedfile); $newwidth=600; $newheight=($height/$width)*$newwidth; $tmp=imagecreatetruecolor($newwidth,$newheight); $newwidth1=200; $newheight1=($height/$width)*$newwidth1; $tmp1=imagecreatetruecolor($newwidth1,$newheight1); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); $filename = "uploads/". $_FILES['file']['name']; $filename1 = "uploads/tn/". $_FILES['file']['name']; imagejpeg($tmp,$filename,100); imagejpeg($tmp1,$filename1,100); imagedestroy($src); imagedestroy($tmp); imagedestroy($tmp1); }} } //If no errors registred, print the success message if(isset($_POST['Upload']) && !$errors) { $q = "INSERT into photo(description, src, tn_src) VALUES('$description', '$filename', '$filename1')"; $result = $mysqli->query($q) or die(mysqli_error($mysqli)); if($result) { $change=' <div class="msgdiv">Image Uploaded Successfully!</div>'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Admin Page</title> <link rel="stylesheet" href="sources/styles.css" type="text/css" /> <link rel="stylesheet" href="admin.css" type="text/css" /> </head> <body> <div id="container"> <div id="header"> <h1>Admin page</h1> </div> <div id="content"> <div id="page"> <?php echo $change; ?> <table width="502" cellpadding="0" cellspacing="0" id="main"> <tbody> <tr> <td width="500" height="238" valign="top" id="main_right"> <div id="posts"> <form method="post" action="" enctype="multipart/form-data" name="form1"> <table width="500" border="0" align="center" cellpadding="0" cellspacing="0"> <tr><Td style="height:25px"> </Td></tr> <tr> <td width="150"><div align="right" class="titles">Picture : </div></td> <td width="350" align="left"> <div align="left"> <input size="25" name="file" type="file" style="font-family:Verdana; font-size:10pt" class="box"/> </div></td> </tr> <tr><Td></Td> <Td valign="top" height="35px" class="help">Image maximum size <b>400 </b>kb</span></Td> </tr> <tr> <Td></Td> <Td valign="top" height="35px"> <label for="description">Description</label><br /> <input type="text" name="description" value="" /><br /></Td> </tr> <tr><Td></Td><Td valign="top" height="35px"><input type="submit" id="mybut" value="Upload" name="Upload"/></Td></tr> <tr> <td width="200"> </td> <td width="200"><table width="200" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="200" align="center"><div align="left"></div></td> <td width="100"> </td> </tr> </table></td> </tr> </table> </form> </div> </td> </tr> </tbody> </table> <form method="POST" action=""> <?php include('testconfig.php'); $result = mysql_query("SELECT * FROM photo ORDER BY rank ASC") or die("Bad query: ".mysql_error()); while ( $row = mysql_fetch_array($result) ) { ?> <input type="text" name="rank" size="2" value="<?php print $row['rank'] ;?>"> <input type="text" name="description" size="" value="<?php print $row['description'] ;?>"> <?php echo "<img src=\"".$row['tn_src']."\"/>"; echo " <a href=delete1.php?id={$row['id']}>Delete</a><br>"; } // END WHILE ?> <input type="submit" value="Update" name="Update"> </form> </div>1.0 Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929399 Share on other sites More sharing options...
cags Posted October 3, 2009 Share Posted October 3, 2009 Right at the top there you have this... // Check if button name "Submit" is active, do this if($submit){ $sql1= mysql_query("UPDATE photo SET rank='{$_POST['rank']}', description='{$_POST['description']}' WHERE id=$id"); $result1=mysql_query($sql1); } Hopefully you can see your mistake in as much as it says $submit, which should obviously be $Update Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929401 Share on other sites More sharing options...
happypete Posted October 3, 2009 Author Share Posted October 3, 2009 thanks, I've changed that but there is still something wrong with it...it doesn't update..and the update doesn't even pass through as it does not redirect to index1.php doesnt redirect: if($result1){ header("location:index1.php"); } Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929405 Share on other sites More sharing options...
MadTechie Posted October 3, 2009 Share Posted October 3, 2009 this is what you should be on so far! <?php $rank = $_POST['rank']; $description = $_POST['description']; $id = $_POST['id']; // Check if button name "Submit" is active, do this if (isset($_POST['Update'])) { $sql1 = "UPDATE photo SET rank='$rank', description='$description' WHERE id=$id"; $result1 = mysql_query($sql1); if ($result1) { header("location:index1.php"); } } // It double checks to see if I'm logged in require_once 'sources/login/classes/Membership.php'; $membership = New Membership(); $membership->confirm_Member(); $db_name = "trek_trek"; $db_server = "localhost"; $db_user = "trek_user"; $db_pass = "intergreen"; $mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name) or die(mysqli_error()); error_reporting(0); $change = ""; $abc = ""; define("MAX_SIZE", "400"); $errors = 0; if (isset($_POST['Upload'])) { $image = $_FILES["file"]["name"]; $uploadedfile = $_FILES['file']['tmp_name']; if ($image) { $filename = stripslashes($_FILES['file']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { $change = '<div class="msgdiv">Unknown Image extension </div> '; $errors = 1; } else { $size = filesize($_FILES['file']['tmp_name']); if ($size > MAX_SIZE * 1024) { $change = '<div class="msgdiv">You have exceeded the size limit!</div> '; $errors = 1; } if ($extension == "jpg" || $extension == "jpeg") { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); } else if ($extension == "png") { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefrompng($uploadedfile); } else { $src = imagecreatefromgif($uploadedfile); } echo $scr; list ($width, $height) = getimagesize($uploadedfile); $newwidth = 600; $newheight = ($height / $width) * $newwidth; $tmp = imagecreatetruecolor($newwidth, $newheight); $newwidth1 = 200; $newheight1 = ($height / $width) * $newwidth1; $tmp1 = imagecreatetruecolor($newwidth1, $newheight1); imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagecopyresampled($tmp1, $src, 0, 0, 0, 0, $newwidth1, $newheight1, $width, $height); $filename = "uploads/" . $_FILES['file']['name']; $filename1 = "uploads/tn/" . $_FILES['file']['name']; imagejpeg($tmp, $filename, 100); imagejpeg($tmp1, $filename1, 100); imagedestroy($src); imagedestroy($tmp); imagedestroy($tmp1); } } } //If no errors registred, print the success message if ($errors>0) { $q = "INSERT into photo(description, src, tn_src) VALUES('$description', '$filename', '$filename1')"; $result = $mysqli->query($q) or die(mysqli_error($mysqli)); if ($result) { $change = '<div class="msgdiv">Image Uploaded Successfully!</div>'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Admin Page</title> <link rel="stylesheet" href="sources/styles.css" type="text/css" /> <link rel="stylesheet" href="admin.css" type="text/css" /> </head> <body> <div id="container"> <div id="header"> <h1>Admin page</h1> </div> <div id="content"> <div id="page"> <?php echo $change; ?> <table width="502" cellpadding="0" cellspacing="0" id="main"> <tbody> <tr> <td width="500" height="238" valign="top" id="main_right"> <div id="posts"> <form method="post" action="" enctype="multipart/form-data" name="form1"> <table width="500" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <Td style="height: 25px"> </Td> </tr> <tr> <td width="150"> <div align="right" class="titles">Picture :</div> </td> <td width="350" align="left"> <div align="left"><input size="25" name="file" type="file" style="font-family: Verdana; font-size: 10pt" class="box" /></div> </td> </tr> <tr> <Td></Td> <Td valign="top" height="35px" class="help">Image maximum size <b>400 </b>kb</span></Td> </tr> <tr> <Td></Td> <Td valign="top" height="35px"><label for="description">Description</label><br /> <input type="text" name="description" value="" /><br /> </Td> </tr> <tr> <Td></Td> <Td valign="top" height="35px"><input type="submit" id="mybut" value="Upload" name="Upload" /></Td> </tr> <tr> <td width="200"> </td> <td width="200"> <table width="200" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="200" align="center"> <div align="left"></div> </td> <td width="100"> </td> </tr> </table> </td> </tr> </table> </form> </div> </td> </tr> </tbody> </table> <form method="POST" action=""> <?php include ('testconfig.php'); $result = mysql_query("SELECT * FROM photo ORDER BY rank ASC") or die("Bad query: " . mysql_error()); while ($row = mysql_fetch_array($result)) { ?> <input type="text" name="rank" size="2" value="<?php print $row['rank']; ?>"> <input type="text" name="description" size="" value="<?php print $row['description']; ?>"> <?php echo "<img src=\"" . $row['tn_src'] . "\"/>"; echo " <a href=delete1.php?id={$row['id']}>Delete</a><br>"; } // END WHILE ?> <input type="submit" value="Update" name="Update"> </form> </div>1.0 <?php function getExtension ($str) { $i = strrpos($str, "."); if (! $i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929552 Share on other sites More sharing options...
happypete Posted October 3, 2009 Author Share Posted October 3, 2009 cut and pasted that...but still not working.... Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929648 Share on other sites More sharing options...
PFMaBiSmAd Posted October 3, 2009 Share Posted October 3, 2009 You have no database connection present at the point where the UPDATE query is being executed. The mysqli connection is being made later in the code and the mysql connection is right before a SELECT query near the bottom of the code. Are you developing and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON so that php would help you by displaying all the errors it detects? Edit: And remove the error_reporting(0); line that is in the code now as that just hides errors that would help you find why your code is not working. Attempting to learn php, develop php code, and debug php code without using full php error_reporting/display_errors and without using mysql/mysqli error reporting on query statements is like a blind guy trying to drive down the highway. You might eventually get where you are going (produce code that works) but it will take you a very long time and when you get there you will be in a world of hurt. Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929651 Share on other sites More sharing options...
happypete Posted October 3, 2009 Author Share Posted October 3, 2009 now going backwards, my update part still doesn't update and now the upload script doesn't work any more Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929660 Share on other sites More sharing options...
cags Posted October 3, 2009 Share Posted October 3, 2009 I don't see how fixing problems with your code/debug settings are a step backwards, even if they break functionality. Has your code changed from what you last posted? Do you now have error_reporting set on your server to E_ALL? Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929667 Share on other sites More sharing options...
MadTechie Posted October 3, 2009 Share Posted October 3, 2009 I removed some pointless code (loading MySqlI) and moved some parts around, turned on error reporting, try that if it fails you should get a useful error.. <?php error_reporting(E_ALL); // It double checks to see if I'm logged in require_once 'sources/login/classes/Membership.php'; $membership = New Membership(); $membership->confirm_Member(); $db_name = "trek_trek"; $db_server = "localhost"; $db_user = "trek_user"; $db_pass = "intergreen"; $change = ""; $abc = ""; define("MAX_SIZE", "400"); $errors = 0; $rank = $_POST['rank']; $description = $_POST['description']; $id = $_POST['id']; // Check if button name "Submit" is active, do this if (isset($_POST['Update'])) { $sql1 = "UPDATE photo SET rank='$rank', description='$description' WHERE id=$id"; $result1 = mysql_query($sql1) or die(mysql_error()); if ($result1) { header("location:index1.php"); } } if (isset($_POST['Upload'])) { $image = $_FILES["file"]["name"]; $uploadedfile = $_FILES['file']['tmp_name']; if ($image) { $filename = stripslashes($_FILES['file']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { $change = '<div class="msgdiv">Unknown Image extension </div> '; $errors = 1; } else { $size = filesize($_FILES['file']['tmp_name']); if ($size > MAX_SIZE * 1024) { $change = '<div class="msgdiv">You have exceeded the size limit!</div> '; $errors = 1; } if ($extension == "jpg" || $extension == "jpeg") { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); } else if ($extension == "png") { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefrompng($uploadedfile); } else { $src = imagecreatefromgif($uploadedfile); } list ($width, $height) = getimagesize($uploadedfile); $newwidth = 600; $newheight = ($height / $width) * $newwidth; $tmp = imagecreatetruecolor($newwidth, $newheight); $newwidth1 = 200; $newheight1 = ($height / $width) * $newwidth1; $tmp1 = imagecreatetruecolor($newwidth1, $newheight1); imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagecopyresampled($tmp1, $src, 0, 0, 0, 0, $newwidth1, $newheight1, $width, $height); $filename = "uploads/" . $_FILES['file']['name']; $filename1 = "uploads/tn/" . $_FILES['file']['name']; imagejpeg($tmp, $filename, 100); imagejpeg($tmp1, $filename1, 100); imagedestroy($src); imagedestroy($tmp); imagedestroy($tmp1); } } } //If no errors registred, print the success message if ($errors == 0) { $q = "INSERT into photo(description, src, tn_src) VALUES('$description', '$filename', '$filename1')"; //$mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name) or die(mysqli_error()); //$result = $mysqli->query($q) or die(mysqli_error($mysqli)); $result = mysql_query($q) or die(mysql_error()); if ($result) { $change = '<div class="msgdiv">Image Uploaded Successfully!</div>'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Admin Page</title> <link rel="stylesheet" href="sources/styles.css" type="text/css" /> <link rel="stylesheet" href="admin.css" type="text/css" /> </head> <body> <div id="container"> <div id="header"> <h1>Admin page</h1> </div> <div id="content"> <div id="page"> <?php echo $change; ?> <table width="502" cellpadding="0" cellspacing="0" id="main"> <tbody> <tr> <td width="500" height="238" valign="top" id="main_right"> <div id="posts"> <form method="post" action="" enctype="multipart/form-data" name="form1"> <table width="500" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <Td style="height: 25px"> </Td> </tr> <tr> <td width="150"> <div align="right" class="titles">Picture :</div> </td> <td width="350" align="left"> <div align="left"><input size="25" name="file" type="file" style="font-family: Verdana; font-size: 10pt" class="box" /></div> </td> </tr> <tr> <Td></Td> <Td valign="top" height="35px" class="help">Image maximum size <b>400 </b>kb</span></Td> </tr> <tr> <Td></Td> <Td valign="top" height="35px"><label for="description">Description</label><br /> <input type="text" name="description" value="" /><br /> </Td> </tr> <tr> <Td></Td> <Td valign="top" height="35px"><input type="submit" id="mybut" value="Upload" name="Upload" /></Td> </tr> <tr> <td width="200"> </td> <td width="200"> <table width="200" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="200" align="center"> <div align="left"></div> </td> <td width="100"> </td> </tr> </table> </td> </tr> </table> </form> </div> </td> </tr> </tbody> </table> <form method="POST" action=""> <?php include ('testconfig.php'); $result = mysql_query("SELECT * FROM photo ORDER BY rank ASC") or die("Bad query: " . mysql_error()); while ($row = mysql_fetch_array($result)) { ?> <input type="text" name="id" size="2" value="<?php print $row['id']; ?>"> <input type="text" name="rank" size="2" value="<?php print $row['rank']; ?>"> <input type="text" name="description" size="" value="<?php print $row['description']; ?>"> <?php echo "<img src=\"" . $row['tn_src'] . "\"/>"; echo " <a href=delete1.php?id={$row['id']}>Delete</a><br>"; } // END WHILE ?> <input type="submit" value="Update" name="Update"> </form> </div>1.0 <?php function getExtension ($str) { $i = strrpos($str, "."); if (! $i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929688 Share on other sites More sharing options...
happypete Posted October 3, 2009 Author Share Posted October 3, 2009 thanks for the updating the script. Now each time I try and update or refresh the page it adds a new input box (see attached screenshot), but doesn't update, although it is now getting redirected to index1.php as per: if ($result1) { header("location:index1.php"); Quote Link to comment https://forums.phpfreaks.com/topic/176285-solved-image-upload-and-update-script/#findComment-929713 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.