Jump to content

elkidogz

Members
  • Posts

    37
  • Joined

  • Last visited

    Never

Everything posted by elkidogz

  1. having it fetch the array is what made it work, the second array wasn't being built.
  2. $array is what the function gets it's the folders directory <?php $files = scandir("allPICS",0); comparearrays($files); ?> this generates an array of file names (scroll up for an example of the values) inside the function its a variable called $array latest code revision <?php function comparearrays($array) { //$cleartables="TRUNCATE TABLE `tobeadded`"; //clears table notadded //$doitnow2=mysql_query($cleartables); //$query1="SELECT notinfilename FROM notadded"; //$result1 = mysql_query($query1); //$array=mysql_fetch_array($result1); print_r($array); $query2="SELECT fileName FROM pictures"; $result2 = mysql_query($query2); $rows = mysql_fetch_array($result2); print_r($rows); $result = array_diff($array, $rows); foreach ($result as $arrayElement)//rebuilds table notadded { $query="INSERT INTO tobeadded (tobeaddedfilename) VALUES ('$arrayElement')"; $doit = mysql_query($query); echo "File:".$arrayElement." was added to table tobeadded <br>"; } echo "function comparearrays is complete."; } $files = scandir("allPICS",0); print_r($files); //shows array $files (verify the array exists) comparearrays($files); //sends $files array to function comparearrays as $array mysql_close($con) ?>
  3. when i do a print_r($result2); on the variable for my select it returns so i must not be getting that right... hmm how to set it up
  4. yes, it's an array of all the files in a given folder, my last post had a function that inserts to a table off that, then i use that same list to compare again to a second table. <?php $files = scandir("allPICS",0);?> output
  5. This function works fine. What i don't get is that the other one is basically doing the same thing, it has three arrays the first is provided, second is from a select, third is the difference of those two arrays... and then just insert it. <?php function insertarray($arrayName) { $con = mysql_connect("nope"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("nope", $con); $cleartable="TRUNCATE TABLE `notadded`"; //clears table notadded $doitnow=mysql_query($cleartable); foreach ($arrayName as $arrayElement)//rebuilds table notadded { if ($arrayElement != '.' && $arrayElement != '..')// don't want . and .. in array just file names { $query="INSERT INTO notadded (notinfilename) VALUES ('$arrayElement')"; $result = mysql_query($query); //echo "File:".$arrayElement." was added to the table notadded. <br>"; } } echo"function insertarray is complete.<br>"; }?>
  6. <?php function comparearrays($array) { $con = mysql_connect("nope"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("nope", $con); $query2="SELECT fileName FROM pictures"; $result2 = mysql_query($query2); $result = array_diff($array, $result2); foreach ($result as $arrayElement)//rebuilds table notadded { $query="INSERT INTO tobeadded (tobeaddedfilename) VALUES ('$arrayElement')"; $doit = mysql_query($query); echo "File:".$arrayElement." was added to table tobeadded"; } echo "function comparearrays is complete."; } $files = scandir("allPICS",0); comparearrays($files); ?> basically i want to see that it gets into the foreach loop, which it isn't right now... i think it's messing up on the arrays (the bane of my existence is arrays) it runs it's part and completes. any advice?
  7. Never mind the above code... i've updated it since then... <?php include('Gallery.php'); function insertarray($arrayName) { $con = mysql_connect("no no"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("nope", $con); $cleartable="TRUNCATE TABLE `notadded`"; //clears table notadded $doitnow=mysql_query($cleartable); foreach ($arrayName as $arrayElement)//rebuilds table notadded { if ($arrayElement != '.' && $arrayElement != '..')// don't want . and .. in array just file names { $query="INSERT INTO notadded (notinfilename) VALUES ('$arrayElement')"; $result = mysql_query($query); echo "File:".$arrayElement." was added to the table notadded. <br>"; } } } function comparearrays() { $con = mysql_connect("no no"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("nope", $con); $cleartable="TRUNCATE TABLE `tobeadded`"; //clears table tobeadded $doitnow=mysql_query($cleartable); $query1="SELECT notinfilename FROM notadded"; $result1 = mysql_query($query1); $query2="SELECT fileName FROM pictures"; $result2 = mysql_query($query1); $result = array_diff($result1, $result2); foreach ($result as $arrayElement)//rebuilds table tobeadded { $query="INSERT INTO tobeadded (tobeaddedfilename) VALUES ('$arrayElement')"; $doit = mysql_query($query); echo "File:".$arrayElement." was added to table tobeadded"; } echo "done"; } $files = scandir("allPICS",0); insertarray($files); comparearrays(); mysql_close($con) ?> it goes into both functions, but it only performs the first ones insert am i not doing the arrays right?... what's going on here?
  8. because i have one table where people are going to be working on these files that will constantly be added to the folder, it never shrinks, it only gets bigger... the first table is the work done table they are adding information about a picture to a table that has the file name, like a title, notes, etc... the second table is just a dump of the files that are in the folder. a third table is being generated so that i can display the pictures that are in the folder but don't have any information on them yet... <?php function insertarray($arrayName) { foreach ($arrayName as $arrayElement) { if ($arrayElement != '.' && $arrayElement != '..')// don't want . and .. in array just file names { $con = mysql_connect("my info"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("DOH ", $con); $query="INSERT INTO notadded (notinfilename) VALUES ('$arrayElement')"; $result = mysql_query($query); echo "File:".$arrayElement." was added to the table. <br>"; } } } function comparearrays() { $query1="SELECT notinfilename FROM notadded"; $result1 = mysql_query($query1); $query2="SELECT fileName FROM pictures"; $result2 = mysql_query($query1); $result = array_diff($result1, $result2); $query="INSERT INTO tobeadded (tobeaddedfilename) VALUES ('$result')"; return($result); } $files = scandir("allPICS",0); insertarray($files); comparearrays(); printr $result; //wanna see the results ?>
  9. <?php function insertarray($arrayName) { foreach ($arrayName as $arrayElement) { if ($arrayElement != '.' && $arrayElement != '..')// don't want . and .. in array just file names { $con = mysql_connect("my info"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("DOH ", $con); $query="INSERT INTO notadded (notinfilename) VALUES ('$arrayElement')"; $result = mysql_query($query); echo "File:".$arrayElement." was added to the table. <br>"; } } } $files = scandir("allPICS",0); insertarray($files); ?> Sorry but now, i'm having issues with this insert line, basically it only inserts 30 at a time, how can i make it continue? with a counter while loop or something? make it sleep? please help there are roughly 3000-5000 records in this folder all of them need to go into a table so i can compare them .
  10. ok, I'm going to have a select on two different tables, the difference i need to insert to a third, I can load the two up as arrays, but now i need compare the two arrays, and have the output entered into a third array so i can enter that one back into a table... suggestions? array 1 Touched files (select few from a HUGE of 5,000+ files) array 2 all files (from same folder) array 3 difference between the two
  11. quick simple, need a list of all files (i have like 5k or so) in a folder, I need to add there names to a table I am doing this so i can compare two tables table 1. comments added to uploaded pics -finished pictures- table 2. no comments added yet to uploaded pics (so they can be commented on GET IT?) -unfinished pictures- All the pictures are in a single folder for the time being i'm going to be making a form based on the pictures that are on table 2 so that they can have comments and titles and file name added to table 1 (to be done still) but i need to know all the file names for the folder in question, i guess i could do it via cmd line ls or something like that, i'll get back to you.
  12. look up joins for sql statements. please ensure that you have some of the same fields ie product number (sku) or something to relate table 1 to table 2
  13. <?php $persons = $_POST['PERSONS']; foreach ($_POST['PICTURES'] as $row => $PICTURES) { $pics = mysql_real_escape_string($PICTURES); echo "Picture File Name ".$pictures." was related to: ".$persons."<br>"; $sql="INSERT INTO relations (relPic, person)VALUES('$pics', '$persons')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } } ?> I think the SQL statement was getting screwed up.
  14. 1. Picture File Name=genie.jpg persons=Genie then it errors out (Unknown column '$pictures' in 'field list') <?php foreach ($_POST['PICTURES'] as $row => $PICTURES) { $pictures = mysql_real_escape_string($PICTURES); $persons = $_POST['PERSONS']; echo "1. Picture File Name=".$pictures."persons=".$persons." "; mysql_query('INSERT INTO relations (relPic, person) VALUES ($pictures, $persons)') or die (mysql_error()); echo "2. Picture File Name=".$pictures." persons=".$persons." "; } ?> changing $persons = $_POST['PERSONS']; to $persons = $_POST['PERSONS'][$row]; doesn't resolve this. what is actually going on here? the error message seems to indicate that the SQL statement isn't correct... but it looks ok to me.
  15. i added an echo before the insert to see what the values are... the PERSONS was only passing the first character with the $persons = $_POST['PERSONS'][$row]; Changed back to $persons = $_POST['PERSONS']; and it sends all of the data from $PERSONS again i know that the name of the field is relPics it's a text field...
  16. do i need to put an if statement for the null valued (not checked) around the insert?
  17. To make them more dynamic in nature it would be best to store the information needed to create these forms within the database. Then query that data to create the forms when needed. so instead of $output to a file, make it insert it into a table that would hold the values in a field... i like that! ~why didn't i think of that???? CAUSE i'm a NOOB!
  18. yeah it doesn't generate any errors but it also doesn't insert anything either. when i make the changes you suggest is the error i get. the field name is correct however i just double checked the variable values on the relations table, they are correct.
  19. insert into `<table name>` `<fields>` VALUES `<values for each field>`
  20. well, basically the reason is that i want to reuse these form items over and over so they are more dynamic in nature (after i get it working...) sorry that was older code in there... my apologies. foreach ($_POST['PICTURES'][] as $row=>$PICTURES) { $pictures = mysql_real_escape_string($PICTURES); $persons = $_POST['PERSONS']; mysql_query('INSERT INTO relations (relPics, person) VALUES ($pictures, $persons)') or die (mysql_error()); echo $pictures." ".$persons; }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.