The Little Guy Posted February 19, 2007 Share Posted February 19, 2007 Here is the form: <?php echo'<form action="'.$home.'/uploadfiles.php?type=profile_image" method="post" enctype="multipart/form-data"> <table>'; $sql = mysql_query("SELECT * FROM pictures WHERE id='$_SESSION[userid]'")or die(mysql_error()); for($i=1;$i <= $maximages;$i++){ $picts = mysql_fetch_array($sql); if($picts){ echo'<tr> <td colspan="2"><input class="checkbox" type="checkbox" name="image_delete[]" value="'.$picts['filename'].'"> <img src="images/userimages/thumbs/'.$picts['filename'].'"></td> </tr>'; }else{ echo' <tr> <td>Picture Of You ('.$i.'):</td> <td><input class="file" type="file" name="pictures[]"></td> </tr>'; } } echo' <tr> <td><input type="submit" name="upload_images" value="Upload"></td> <td><input type="submit" name="delete_images" value="Delete"></td> </tr> </table> </form>'; ?> This code, when the page loads, doesn't go into the second if statement. If i type echo 'I am here'; right after the first { it echos, but if it is right after the second, it doesn't echo, I can't find the error. Please help. <?php session_start(); if($_SESSION['logedin']!=1){ header("Location: $home/index.php"); exit; } include"functions.php"; include"globalvars.php"; if($_GET['type'] == "profile_image"){ if(isset($_POST['upload_images'])){ Here is what the URL Looks like (Don't click, probably won't work.) http://68.117.46.68:6251/date/uploadfiles.php?type=profile_image Quote Link to comment https://forums.phpfreaks.com/topic/39122-solved-i-dont-know-what-is-wrong/ Share on other sites More sharing options...
monk.e.boy Posted February 19, 2007 Share Posted February 19, 2007 I'm not sure what your problem is, but try echoing the sql see if it is correct. $sql = mysql_query("SELECT * FROM pictures WHERE id='$_SESSION[userid]'")or die(mysql_error()); echo 'SQL :'. $sql; for($i=1;$i <= $maximages;$i++){ $picts = mysql_fetch_array($sql); Try posting a simpler code example, trim it down to 4-5 lines or code. You'll probably find the error yourself if you do that. Quote Link to comment https://forums.phpfreaks.com/topic/39122-solved-i-dont-know-what-is-wrong/#findComment-188484 Share on other sites More sharing options...
The Little Guy Posted February 19, 2007 Author Share Posted February 19, 2007 the problem isn't with the SQL, it is with the 2 pages, I don't think that $_POST['upload_images'] is being sent. I don't know why though Quote Link to comment https://forums.phpfreaks.com/topic/39122-solved-i-dont-know-what-is-wrong/#findComment-188955 Share on other sites More sharing options...
tom100 Posted February 19, 2007 Share Posted February 19, 2007 One thing you might try is having a hidden input with a value of 1. I always have that ever since I figured out that Submit values don't always send. For example, if you push enter, but don't click submit, the submit buttons value isn't sent. So adding a field like this would fix it: <input type="hidden" name="upload_images" value="1"> Make sure you change your input button's name though to avoid conflicting names. Quote Link to comment https://forums.phpfreaks.com/topic/39122-solved-i-dont-know-what-is-wrong/#findComment-188958 Share on other sites More sharing options...
hitman6003 Posted February 19, 2007 Share Posted February 19, 2007 do a print_r on $_POST, $_SESSION, and $_FILES to make sure that the variables you think are there, are actually there. Quote Link to comment https://forums.phpfreaks.com/topic/39122-solved-i-dont-know-what-is-wrong/#findComment-188959 Share on other sites More sharing options...
The Little Guy Posted February 19, 2007 Author Share Posted February 19, 2007 One thing you might try is having a hidden input with a value of 1. I always have that ever since I figured out that Submit values don't always send. For example, if you push enter, but don't click submit, the submit buttons value isn't sent. So adding a field like this would fix it: <input type="hidden" name="upload_images" value="1"> Make sure you change your input button's name though to avoid conflicting names. That didn't do work. could this be an HTML error? Quote Link to comment https://forums.phpfreaks.com/topic/39122-solved-i-dont-know-what-is-wrong/#findComment-188962 Share on other sites More sharing options...
The Little Guy Posted February 19, 2007 Author Share Posted February 19, 2007 Am I doing it wrong? print_r("$_POST"); print_r("$_SESSION"); print_r("$_FILES"); All it prints is ArrayArrayArray Quote Link to comment https://forums.phpfreaks.com/topic/39122-solved-i-dont-know-what-is-wrong/#findComment-188965 Share on other sites More sharing options...
tom100 Posted February 19, 2007 Share Posted February 19, 2007 print_r($_POST); Quote Link to comment https://forums.phpfreaks.com/topic/39122-solved-i-dont-know-what-is-wrong/#findComment-188966 Share on other sites More sharing options...
The Little Guy Posted February 19, 2007 Author Share Posted February 19, 2007 Result: Array ( ) Quote Link to comment https://forums.phpfreaks.com/topic/39122-solved-i-dont-know-what-is-wrong/#findComment-188967 Share on other sites More sharing options...
tom100 Posted February 19, 2007 Share Posted February 19, 2007 Ok, please post everything on your HTML starting with <FORM and ending with </form> Quote Link to comment https://forums.phpfreaks.com/topic/39122-solved-i-dont-know-what-is-wrong/#findComment-188968 Share on other sites More sharing options...
The Little Guy Posted February 19, 2007 Author Share Posted February 19, 2007 Frome the editor: <?php echo'<form action="'.$home.'/uploadfiles.php?type=profile_image" method="post" enctype="multipart/form-data"> <table>'; $sql = mysql_query("SELECT * FROM pictures WHERE id='{$_SESSION['userid']}'")or die(mysql_error()); for($i=1;$i <= $maximages;$i++){ $picts = mysql_fetch_array($sql); if($picts){ echo'<tr> <td colspan="2"><input class="checkbox" type="checkbox" name="image_delete[]" value="'.$picts['filename'].'"> <img src="images/userimages/thumbs/'.$picts['filename'].'"></td> </tr>'; }else{ echo' <tr> <td>Picture Of You ('.$i.'):</td> <td><input class="file" type="file" name="pictures[]"></td> </tr>'; } } echo' <tr> <td><input type="submit" name="upload_images" value="Upload"></td> <td><input type="submit" name="delete_images" value="Delete"></td> </tr> </table> </form>'; ?> From the Browser Source Code: <form action="http://ifolio.no-ip.org/date/uploadfiles.php?type=profile_image" method="post" enctype="multipart/form-data"> <table> <tr> <td>Picture Of You (1):</td> <td><input class="file" type="file" name="pictures[]"></td> </tr> <tr> <td>Picture Of You (2):</td> <td><input class="file" type="file" name="pictures[]"></td> </tr> <tr> <td>Picture Of You (3):</td> <td><input class="file" type="file" name="pictures[]"></td> </tr> <tr> <td>Picture Of You (4):</td> <td><input class="file" type="file" name="pictures[]"></td> </tr> <tr> <td><input type="submit" name="upload_images" value="Upload"></td> <td><input type="submit" name="delete_images" value="Delete"></td> </tr> </table> </form> Quote Link to comment https://forums.phpfreaks.com/topic/39122-solved-i-dont-know-what-is-wrong/#findComment-188980 Share on other sites More sharing options...
tom100 Posted February 19, 2007 Share Posted February 19, 2007 Ok, your form is fine, can you post the content of uploadFiles.php? Or at least the first part with the lines immediately following the second if statement? Quote Link to comment https://forums.phpfreaks.com/topic/39122-solved-i-dont-know-what-is-wrong/#findComment-188985 Share on other sites More sharing options...
The Little Guy Posted February 19, 2007 Author Share Posted February 19, 2007 uploadfiles.php: <?php session_start(); if($_SESSION['logedin']!=1){ header("Location: $home/index.php"); exit; } include"functions.php"; include"globalvars.php"; if($_GET['type'] == "profile_image"){ if(isset($_POST['upload_images'])){ foreach ($_FILES["pictures"]["error"] as $key => $error){ if($error === 0){ $filename = time().$_FILES["pictures"]["name"][$key]; if($_FILES["pictures"]["type"]!="image/gif"||$_FILES["pictures"]["type"]!="image/jpg"||$_FILES["pictures"]["type"]!="image/png"){ header("Location: $home/user.php?page=images&type=profile_image"); exit; } move_uploaded_file($_FILES["pictures"]["tmp_name"][$key], "$home/images/userimages/$filename"); createThumbnail("$home/images/userimages", "$filename", "$home/images/userimages/thumbs", 100); mysql_query("INSERT INTO pictures(`id`, `filename`) VALUES ('$_SESSION[userid]', '$filename')")or die(mysql_error()); } } // More code below that doesn't pertain the this: header("Location: $home/user.php?page=images&type=profile_image"); exit; }elseif(isset($_POST['delete_images'])){ foreach($_POST['image_delete'] as $img){ mysql_query("DELETE FROM pictures WHERE filename='$img'")or die(mysql_error()); $delete_img = "$home/images/userimages/$img"; $delete_thumb = "$home/images/userimages/thumbs/$img"; unlink($delete_img); unlink($delete_thumb); } header("Location: $home/user.php?page=images&type=profile_image"); exit; } }elseif($_GET['type'] == "avatar_image"){ if($_GET['action'] == "delete"){ $delete_avatar = "$home/images/avatars/$_POST[filename]"; unlink($delete_avatar); mysql_query("DELETE FROM avatars WHERE id='$_SESSION[userid]'"); header("Location: $home/user.php?page=images&type=avatar_image"); }elseif($_GET['action'] == "upload"){ foreach ($_FILES["avatar"]["error"] as $key => $error){ if($error === 0){ $filename = time().$_FILES["avatar"]["name"][$key]; move_uploaded_file($_FILES["avatar"]["tmp_name"][$key], "images/avatars/$filename"); createThumbnail("$home/images/avatars", "$filename", "$home/images/avatars", 100); mysql_query("INSERT INTO avatars(`id`, `filename`) VALUES ('$_SESSION[userid]', '$filename')")or die(mysql_error()); } } header("Location: $home/user.php?page=images&type=avatar_image"); exit; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/39122-solved-i-dont-know-what-is-wrong/#findComment-188987 Share on other sites More sharing options...
tom100 Posted February 19, 2007 Share Posted February 19, 2007 Try making a backup of your uploadfiles.php or point your form to a new location and simply put print_r($_POST); at the top of the file it posts to. Then see what the outcome is. The other thing you can try is checking your error logs on your server. It looks like PHP may be erroring out some where and you may have error_reporting set to not report anything. Quote Link to comment https://forums.phpfreaks.com/topic/39122-solved-i-dont-know-what-is-wrong/#findComment-188992 Share on other sites More sharing options...
The Little Guy Posted February 19, 2007 Author Share Posted February 19, 2007 error reporting is on, I have received many errors, just not for this. Quote Link to comment https://forums.phpfreaks.com/topic/39122-solved-i-dont-know-what-is-wrong/#findComment-188994 Share on other sites More sharing options...
The Little Guy Posted February 19, 2007 Author Share Posted February 19, 2007 I made a new file, called upload2.php, and the array is still empty. Quote Link to comment https://forums.phpfreaks.com/topic/39122-solved-i-dont-know-what-is-wrong/#findComment-188996 Share on other sites More sharing options...
The Little Guy Posted February 20, 2007 Author Share Posted February 20, 2007 Anyone have any Ideas? Quote Link to comment https://forums.phpfreaks.com/topic/39122-solved-i-dont-know-what-is-wrong/#findComment-189739 Share on other sites More sharing options...
The Little Guy Posted February 20, 2007 Author Share Posted February 20, 2007 Got it! it was my action, it was going to the right place, but I think it wouldn't let me do it since i was using http://ifolio.no-ip.org Quote Link to comment https://forums.phpfreaks.com/topic/39122-solved-i-dont-know-what-is-wrong/#findComment-189805 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.