patheticsam Posted March 29, 2010 Share Posted March 29, 2010 Hi! I have litlle form in which user can select either photo1 or photo2 to modify. Once the user chooses which photo he wants to modify he goes to a page with an upload form to upload the new picture. Here the form code : if( ($_GET['cmd']=="view") && (is_numeric($_GET['id'])) ) { $id=$_GET['id']; $photo = $_POST['photo']; $data = mysql_query("SELECT * FROM artists WHERE artist_id='$id'") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { echo " <center> <form enctype=\"multipart/form-data\" action=\"processes/modify_photo.php\" method=\"POST\" target=\"main2\"> <input type=\"hidden\" value=\"".$info['artist_id']."\" name=\"id\"> <table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"301\"> <tr> <td><h1>".$photo."</h1></td> </tr> <td><img src=\"../timthumb.php?src=/admin/artists photo/".$photo."&h=300&w=300&zc=1\" /></td> </tr> <tr> <td>Nouvelle photo : <input type=\"file\" name=\"uploadedfile\" class=\"login\" style=\"width: 250px\"></td> </tr> <tr> <td style=\"text-align: center;\"><input type=\"submit\" value=\"Modifier\"></td> </tr> </table> </form> </center> "; } } mysql_close(); ?> And this is where the problem is in the modify_photo.php part : <?php $target_path = "../artists photo/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $picture = basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "<center><br /><br />votre photo $picture a été correctement enregistré</center><br>"; } else{ echo "<center><br /><br />Il y a eu un problème avec l'instertion de votre photo</center><br>"; } ?> <?php mysql_connect("localhost", "login", "pass") or die(mysql_error()); mysql_select_db("DB") or die(mysql_error()); if( ($_GET['cmd']=="view") && (is_numeric($_GET['id'])) ) { $id=$_GET['id']; $photo = mysql_real_escape_string($_FILES['uploadedfile']['name']); $current = $_POST['photo']; $data = mysql_query("SELECT * FROM artists WHERE artist_id='$id'") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { if ($data[photo] == '$current') { mysql_query("UPDATE artists SET photo = '$photo' WHERE artist_id = '$id'"); } else { mysql_query("UPDATE artists SET photo2 = '$photo' WHERE artist_id = '$id'"); } } mysql_close($con); echo "<br /><br /><center>Votre photo a correctement été modifié<br /><br /><a href=\"../manage_artist.php\">Retour à la gestion des artistes</a></center>"; ?> But I'm getting a parse error and can't find where it comes from : Parse error: syntax error, unexpected $end in /home/content/m/a/z/mazemontana/html/login/admin/processes/modify_photo.php on line 53 If anyone can help it would be really appreciated. thnx Link to comment https://forums.phpfreaks.com/topic/196896-problem-with-upload-update-cmd-please-help/ Share on other sites More sharing options...
the182guy Posted March 29, 2010 Share Posted March 29, 2010 That error means the php interpreter was expecting more code before the end of the script. Usually it means there is a missing {} or one too many. That's exactly what the problem is with your code. This line opens a { but you don't close it anywhere. I'm not sure if you want to close it after the mysql_close or after the echo. if( ($_GET['cmd']=="view") && (is_numeric($_GET['id'])) ) { You need to add the closing brace } Link to comment https://forums.phpfreaks.com/topic/196896-problem-with-upload-update-cmd-please-help/#findComment-1033697 Share on other sites More sharing options...
patheticsam Posted March 29, 2010 Author Share Posted March 29, 2010 Ok! I added the } and I am now getting no error but the script isn't working. Tje data into mySQL is not updating but the file is uploading.........can't find why. Modify_photo.php <?php $target_path = "../artists photo/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $picture = basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "<center><br /><br />votre photo $picture a été correctement enregistré</center><br>"; } else{ echo "<center><br /><br />Il y a eu un problème avec l'instertion de votre photo</center><br>"; } ?> <?php mysql_connect("mazemontana.db.5882413.hostedresource.com", "mazemontana", "Dieu777") or die(mysql_error()); mysql_select_db("mazemontana") or die(mysql_error()); if( ($_GET['cmd']=="view") && (is_numeric($_GET['id'])) ) { $id = $_POST['id']; $photo = mysql_real_escape_string($_FILES['uploadedfile']['name']); $current = $_POST['photo']; $data = mysql_query("SELECT * FROM artists WHERE artist_id='$id'") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { if ($data[photo] == '$current') { mysql_query("UPDATE artists SET photo = '$photo' WHERE artist_id = '$id'"); } else { mysql_query("UPDATE artists SET photo2 = '$photo' WHERE artist_id = '$id'"); } } } echo "<br /><br /><center>Votre photo a correctement été modifié<br /><br /><a href=\"../manage_artist.php\">Retour à la gestion des artistes</a></center>"; ?> Any help is appreciated! Thanx Link to comment https://forums.phpfreaks.com/topic/196896-problem-with-upload-update-cmd-please-help/#findComment-1033788 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.