smphil
asked on
Picture Load problem Binary help
I have a code below I have been working on for a few weeks for a control panel for my model site. I have a problem with the picture being stored.
1) I can store the pics that work fine.
2) If you load your pictures from 1 thru 10 ay one time it will work fine even if you only load 1 thru 4 it will work fine.
3) If you load 1 to 4 the first time then would like to go back in the same session or a different seesion and load 5 thru 10 IT WILL NOT WORK IT WILL STILL ONLY BE 1 thru 4 there.
4) If you have all 10 loaded and try to just change number 5 it willnot do it number 5 will still be the original number 5. In order to change 5 you must reload all the others.
CAN ANYONE HELP WITH THIS PROBLEM I KNOW THE CODES PRETTY INVOVLED.
***** IF YOU WANNA HELP AND NEED A PLACE TO TEST IT I CAN PROVIDE A TESTING ENVIROMENT....
ANY HELP WILL be appreciate but don't start telling me to rewrite the whole thing.
Thanks Phil
<?php
session_start();
require("loginfo.php");
###User login process
###User login process
require("login.php");
if(!$validLog) { header("Location: cplogin.php"); } else { $mustLog = true; }
if($PHPSESSID != $_GET['from'] && $PHPSESSID != $_POST['from']) { header("Location: cplogin.php"); }
###End of user login process
###End of user login process
###Data validation process
###Data validation process
$uped = "";
if($_SESSION['infoUped'] == "yes") { $_SESSION['infoUped'] = ""; $uped = "<i>Your changes have been saved</i>"; }
if($_POST['saveData'] == "yes")
{
$blank = "";
$allDone = true;
if($_POST['country'] == "US") { if($_POST['name'] == "" || $_POST['lastname'] == "" || $_POST['home_phone'] == "" || $_POST['adr1'] == "" || $_POST['city'] == "" || $_POST['state'] == "" || $_POST['zip'] == "" || $_POST['country'] == "X") { $allDone = false; $blank = "You can't leave any field blank, all fields need to be filled in.\\n\\nPlase provide the requested information in order to proceed."; } }
else if($_POST['country'] != "US") { if($_POST['name'] == "" || $_POST['lastname'] == "" || $_POST['home_phone'] == "" || $_POST['adr1'] == "" || $_POST['city'] == "" || $_POST['country'] == "X") { $allDone = false; $blank = "You can't leave any field blank, all fields need to be filled in.\\n\\nPlase provide the requested information in order to proceed."; } }
if($_POST['npassw'] != $_POST['npasswr']) { $allDone = false; $blank = "The provided passwords do not match.\\n\\nPlase provide two valid passwords in order to proceed."; }
if($blank != "") { echo "<script>alert(\"".$blank. "\");</scr ipt>"; }
if($allDone)
{
if($_POST['npassw'] == "" || $_POST['npasswr'] == "")
{
$updateMe = mysql_query("UPDATE models SET first_name = \"".$_POST['name']."\",las t_name = \"".$_POST['lastname']."\" ,
model_name = \"".$_POST['stage_name']." \",address _1 = \"".$_POST['adr1']."\",
address_2 = \"".$_POST['adr2']."\",cit y = \"".$_POST['city']."\",
state = \"".$_POST['state']."\",zi pcode = \"".$_POST['zip']."\",
country = \"".$_POST['country']."\", home_phone = \"".$_POST['home_phone']." \",
extra_phone = \"".$_POST['extra_phone']. "\",email = \"".$_POST['email']."\",
age = \"".$_POST['age']."\",sex = \"".$_POST['sex']."\",
eyecolor = \"".$_POST['eyecolor']."\" ,haircolor = \"".$_POST['haircolor']."\ ",
height = \"".$_POST['height']."\",h eight_inch es = \"".$_POST['height_inches' ]."\",
weight = \"".$_POST['weight']."\",c hest = \"".$_POST['chest']."\",
waiste = \"".$_POST['waiste']."\",s hoe_size = \"".$_POST['shoe']."\" WHERE ID = \"".$_SESSION['user']['ID' ]."\"");
}
else
{
$newPass = md5($_POST['npassw']);
$updateMe = mysql_query("UPDATE models SET first_name = \"".$_POST['name']."\",las t_name = \"".$_POST['lastname']."\" ,
model_name = \"".$_POST['stage_name']." \",address _1 = \"".$_POST['adr1']."\",
address_2 = \"".$_POST['adr2']."\",cit y = \"".$_POST['city']."\",
state = \"".$_POST['state']."\",zi pcode = \"".$_POST['zip']."\",
country = \"".$_POST['country']."\", home_phone = \"".$_POST['home_phone']." \",
extra_phone = \"".$_POST['extra_phone']. "\",email = \"".$_POST['email']."\",
age = \"".$_POST['age']."\",sex = \"".$_POST['sex']."\",
eyecolor = \"".$_POST['eyecolor']."\" ,haircolor = \"".$_POST['haircolor']."\ ",
height = \"".$_POST['height']."\",h eight_inch es = \"".$_POST['height_inches' ]."\",
weight = \"".$_POST['weight']."\",c hest = \"".$_POST['chest']."\",
waiste = \"".$_POST['waiste']."\",s hoe_size = \"".$_POST['shoe']."\",
passw = '$newPass' WHERE ID = \"".$_SESSION['user']['ID' ]."\"");
}
if(!$updateMe)
{
$blank = "An error has occurred while saving your data. Please try again later...<br>Error code: ".mysql_error();
echo "<script>alert(\"".$blank. "\");</scr ipt>";
} else { $_SESSION['infoUped'] = "yes"; header("Location: cplogin.php"); }
}
}
if($_POST['savePics'] == "yes")
{
if($_FILES)
{
$good = false;
$good2 = false;
$mainLoaded = false;
$otherLoaded = false;
$image_types = array("image/jpeg","image/ pjpeg","im age/gif"," image/x-pn g");
#Main picture
if(is_uploaded_file($_FILE S["mainpic "]["tmp_na me"]))
{ $mainLoaded = true;
$pic1 = addslashes(fread(fopen ($_FILES["mainpic"]["tmp_n ame"], "r"),filesize ($_FILES["mainpic"]["tmp_n ame"])));
$file_type = $_FILES["mainpic"]["type"] ;
if(in_array(strtolower($fi le_type), $image_types))
{
$result = mysql_query("UPDATE models SET main_pic = '{$pic1}' WHERE ID = \"".$_SESSION['user']['ID' ]."\"");
if(!$result) { $error1 = true; }
else { $good = true; } } else { $invalid1 = true; } }
#Other pics
$i = 1;
while(is_uploaded_file($_F ILES['pic' .$i]["tmp_ name"]))
{
$pic1 = addslashes(fread(fopen ($_FILES['pic'.$i]["tmp_na me"], "r"),filesize ($_FILES['pic'.$i]["tmp_na me"])));
$file_type = $_FILES['pic'.$i]["type"];
if(in_array(strtolower($fi le_type), $image_types)) { $picLoad[$i] = $pic1; }
else { $invalid2 = true; }
$i++;
}
if($i > 1) { $otherLoaded = true; }
$newID = $_SESSION['user']['ID'];
$queryUsers = mysql_query("SELECT * FROM pictures WHERE userID = \"".$_SESSION['user']['ID' ]."\"");
if(mysql_num_rows($queryUs ers) > 0 && $i > 1)
{
$resultIns = mysql_query("UPDATE pictures SET pic_1 = '{$picLoad[1]}',pic_2 = '{$picLoad[2]}',pic_3 = '{$picLoad[3]}',pic_4 = '{$picLoad[4]}',pic_5 = '{$picLoad[5]}',pic_6 = '{$picLoad[6]}',pic_7 = '{$picLoad[7]}',pic_8 = '{$picLoad[8]}',pic_9 = '{$picLoad[9]}',pic_10 = '{$picLoad[10]}' WHERE userID = '$newID'");
if(!$resultIns) { echo "1 - ".mysql_error(); } else { $good2 = true; }
}
else if(mysql_num_rows($queryUs ers) == 0)
{
$resultIns = mysql_query("INSERT INTO pictures VALUES('$newID','$picLoad[ 1]','$picL oad[2]','$ picLoad[3] ','$picLoa d[4]','$pi cLoad[5]', '$picLoad[ 6]','$picL oad[7]','$ picLoad[8] ','$picLoa d[9]','$pi cLoad[10]' )");
if(!$resultIns) { echo "2 - ".mysql_error(); } else { $good2 = true; }
}
if($error1 || $error2) { echo "<script>alert('An error occured while saving your pictures.\n\nPlease try again...')</script>"; }
if ($invalid1 || $invalid2) { echo "<script>alert('You are trying to load an invalid file format.\n\nPlease try again...')</script>"; }
if($mainLoaded && !$otherLoaded) { if($good) { $loaded = "<i>Pictures have been loaded</i>"; } }
elseif(!$mainLoaded && $otherLoaded) { if($good2) { $loaded = "<i>Pictures have been loaded</i>"; } }
elseif($mainLoaded && $otherLoaded) { if($good && $good2) { $loaded = "<i>Pictures have been loaded</i>"; } }
}
$bio = $_POST['myBio'];
$resultBio = mysql_query("UPDATE models SET bio_info = '$bio' WHERE ID = '$newID'");
}
###End of data validation process
###End of data validation process
?>
1) I can store the pics that work fine.
2) If you load your pictures from 1 thru 10 ay one time it will work fine even if you only load 1 thru 4 it will work fine.
3) If you load 1 to 4 the first time then would like to go back in the same session or a different seesion and load 5 thru 10 IT WILL NOT WORK IT WILL STILL ONLY BE 1 thru 4 there.
4) If you have all 10 loaded and try to just change number 5 it willnot do it number 5 will still be the original number 5. In order to change 5 you must reload all the others.
CAN ANYONE HELP WITH THIS PROBLEM I KNOW THE CODES PRETTY INVOVLED.
***** IF YOU WANNA HELP AND NEED A PLACE TO TEST IT I CAN PROVIDE A TESTING ENVIROMENT....
ANY HELP WILL be appreciate but don't start telling me to rewrite the whole thing.
Thanks Phil
<?php
session_start();
require("loginfo.php");
###User login process
###User login process
require("login.php");
if(!$validLog) { header("Location: cplogin.php"); } else { $mustLog = true; }
if($PHPSESSID != $_GET['from'] && $PHPSESSID != $_POST['from']) { header("Location: cplogin.php"); }
###End of user login process
###End of user login process
###Data validation process
###Data validation process
$uped = "";
if($_SESSION['infoUped'] == "yes") { $_SESSION['infoUped'] = ""; $uped = "<i>Your changes have been saved</i>"; }
if($_POST['saveData'] == "yes")
{
$blank = "";
$allDone = true;
if($_POST['country'] == "US") { if($_POST['name'] == "" || $_POST['lastname'] == "" || $_POST['home_phone'] == "" || $_POST['adr1'] == "" || $_POST['city'] == "" || $_POST['state'] == "" || $_POST['zip'] == "" || $_POST['country'] == "X") { $allDone = false; $blank = "You can't leave any field blank, all fields need to be filled in.\\n\\nPlase provide the requested information in order to proceed."; } }
else if($_POST['country'] != "US") { if($_POST['name'] == "" || $_POST['lastname'] == "" || $_POST['home_phone'] == "" || $_POST['adr1'] == "" || $_POST['city'] == "" || $_POST['country'] == "X") { $allDone = false; $blank = "You can't leave any field blank, all fields need to be filled in.\\n\\nPlase provide the requested information in order to proceed."; } }
if($_POST['npassw'] != $_POST['npasswr']) { $allDone = false; $blank = "The provided passwords do not match.\\n\\nPlase provide two valid passwords in order to proceed."; }
if($blank != "") { echo "<script>alert(\"".$blank.
if($allDone)
{
if($_POST['npassw'] == "" || $_POST['npasswr'] == "")
{
$updateMe = mysql_query("UPDATE models SET first_name = \"".$_POST['name']."\",las
model_name = \"".$_POST['stage_name']."
address_2 = \"".$_POST['adr2']."\",cit
state = \"".$_POST['state']."\",zi
country = \"".$_POST['country']."\",
extra_phone = \"".$_POST['extra_phone'].
age = \"".$_POST['age']."\",sex = \"".$_POST['sex']."\",
eyecolor = \"".$_POST['eyecolor']."\"
height = \"".$_POST['height']."\",h
weight = \"".$_POST['weight']."\",c
waiste = \"".$_POST['waiste']."\",s
}
else
{
$newPass = md5($_POST['npassw']);
$updateMe = mysql_query("UPDATE models SET first_name = \"".$_POST['name']."\",las
model_name = \"".$_POST['stage_name']."
address_2 = \"".$_POST['adr2']."\",cit
state = \"".$_POST['state']."\",zi
country = \"".$_POST['country']."\",
extra_phone = \"".$_POST['extra_phone'].
age = \"".$_POST['age']."\",sex = \"".$_POST['sex']."\",
eyecolor = \"".$_POST['eyecolor']."\"
height = \"".$_POST['height']."\",h
weight = \"".$_POST['weight']."\",c
waiste = \"".$_POST['waiste']."\",s
passw = '$newPass' WHERE ID = \"".$_SESSION['user']['ID'
}
if(!$updateMe)
{
$blank = "An error has occurred while saving your data. Please try again later...<br>Error code: ".mysql_error();
echo "<script>alert(\"".$blank.
} else { $_SESSION['infoUped'] = "yes"; header("Location: cplogin.php"); }
}
}
if($_POST['savePics'] == "yes")
{
if($_FILES)
{
$good = false;
$good2 = false;
$mainLoaded = false;
$otherLoaded = false;
$image_types = array("image/jpeg","image/
#Main picture
if(is_uploaded_file($_FILE
{ $mainLoaded = true;
$pic1 = addslashes(fread(fopen ($_FILES["mainpic"]["tmp_n
$file_type = $_FILES["mainpic"]["type"]
if(in_array(strtolower($fi
{
$result = mysql_query("UPDATE models SET main_pic = '{$pic1}' WHERE ID = \"".$_SESSION['user']['ID'
if(!$result) { $error1 = true; }
else { $good = true; } } else { $invalid1 = true; } }
#Other pics
$i = 1;
while(is_uploaded_file($_F
{
$pic1 = addslashes(fread(fopen ($_FILES['pic'.$i]["tmp_na
$file_type = $_FILES['pic'.$i]["type"];
if(in_array(strtolower($fi
else { $invalid2 = true; }
$i++;
}
if($i > 1) { $otherLoaded = true; }
$newID = $_SESSION['user']['ID'];
$queryUsers = mysql_query("SELECT * FROM pictures WHERE userID = \"".$_SESSION['user']['ID'
if(mysql_num_rows($queryUs
{
$resultIns = mysql_query("UPDATE pictures SET pic_1 = '{$picLoad[1]}',pic_2 = '{$picLoad[2]}',pic_3 = '{$picLoad[3]}',pic_4 = '{$picLoad[4]}',pic_5 = '{$picLoad[5]}',pic_6 = '{$picLoad[6]}',pic_7 = '{$picLoad[7]}',pic_8 = '{$picLoad[8]}',pic_9 = '{$picLoad[9]}',pic_10 = '{$picLoad[10]}' WHERE userID = '$newID'");
if(!$resultIns) { echo "1 - ".mysql_error(); } else { $good2 = true; }
}
else if(mysql_num_rows($queryUs
{
$resultIns = mysql_query("INSERT INTO pictures VALUES('$newID','$picLoad[
if(!$resultIns) { echo "2 - ".mysql_error(); } else { $good2 = true; }
}
if($error1 || $error2) { echo "<script>alert('An error occured while saving your pictures.\n\nPlease try again...')</script>"; }
if ($invalid1 || $invalid2) { echo "<script>alert('You are trying to load an invalid file format.\n\nPlease try again...')</script>"; }
if($mainLoaded && !$otherLoaded) { if($good) { $loaded = "<i>Pictures have been loaded</i>"; } }
elseif(!$mainLoaded && $otherLoaded) { if($good2) { $loaded = "<i>Pictures have been loaded</i>"; } }
elseif($mainLoaded && $otherLoaded) { if($good && $good2) { $loaded = "<i>Pictures have been loaded</i>"; } }
}
$bio = $_POST['myBio'];
$resultBio = mysql_query("UPDATE models SET bio_info = '$bio' WHERE ID = '$newID'");
}
###End of data validation process
###End of data validation process
?>
Got tired of waiting huh phil?
ASKER
No just trying to get as much help as possible
ASKER
I ve been working on it all morning and I can find the answer I am going totaly nuts. And Maybe someone can steer you even in the right direction aand If you want if you can help me dinish up ill give some add space on the site if you would like. Thanks Cory Hit me up after work.
I hope you can do it for me.
I hope you can do it for me.
Hi Phil, I have had a look at your code but i'm at that point tonight where i can't stay focused long enough to get anything done so i think i will come back to it in the morning with fresh eyes.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.