Hello
I want to make a button autoclick itself. JQuery?
Whats the best way?
Tried trigger click but nothing
Thanks
Hello
I want to make a button autoclick itself. JQuery?
Whats the best way?
Tried trigger click but nothing
Thanks
I habe table one with
Col 1 (PK)
Col 2 (NN)
Col 3 (NN)
Col 4 (NN)
Col 5 (NN)
Col 6
Col 7
Col 8
Then I create table two with
Col 1 (PK) (AI)
Col 2
Col 3 (FK)
That col 3 from table two is col 1 from table one. I tried to make the FK relation in Workbench and it does not let me!
I drop that table two....recreate from sratch and it says:
ERROR 1005: Can't create table 'bd.table2' (errno: 121)
SQL Statement:
CREATE TABLE bd
.table2
(
col1
INT NOT NULL AUTO_INCREMENT ,
col2
VARCHAR(70) NULL ,
col3
INT(11) NOT NULL ,
PRIMARY KEY (col1
, col3
) ,
INDEX col3_idx
(col3
ASC) ,
CONSTRAINT col3
FOREIGN KEY (`col3` )
REFERENCES `bd`.`table1` (`col3` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
What is wrong?
Solved :) Finally I found a way to do correctly what I wanted.
PS: Not to offend you, what degree do you have in? It seems to me that you don't really have programming concept at all.
Offensive but nonetheless Im a software engineer. I just really hate programming in general, more so Java.
I apoligize for making so many topics about this......Its just that different methods have proved pointless and do not work.
I want to do the following:
I only have two functions right now: createfolder (Function A) and insertfile (Function B). Nothing else.
My requirements are the following:
Random number is a number common to function A and B
My main path is C:/ we base everything off that.
In C:/, we see if a folder called "webfolder" exists. If it does, we enter it. If it doesnt, we created it.
Once it is created and found, we enter it.
Function A: Counter is a local variable that equals 1. It is local to Function A. I make a folder with the current date and "" and the counter ONLY if there are less than 44 file inside this webfolder. If there is more than 44 files, I add one to a counter and then make a folder with the current date and the "" and the counter as long as it has less than 44 files inside. If not function A is repeated until counter is 9.
Once Function A is completed, I change to that that current date and "_" and the counter folder and inside make a folder with a random number.
Next, we have to insert some files into these folders. I once again start my path off C:/ then enter Webfolder (Webfolder at this point always exists because I call the folder creating …
OK, if you want it that way. My pseudo code is not exactly describing your A & B. The lookUpForFolder is a little combination of your A & B. It looks up a proper folder AND create it if not found, and then return the location which is ensured that it will be qualified for file insertion. There is no detail for your B in my pseudo code because it is just a simple file creation in the returned valid location from lookUpForFolder.
So then lookupfolder just gives me the route that I have to insert the file to? But how do I create that folder in the first place knowing it exists?
Also, It doesnt have to be recursive BTW; I dont mind making 50 inefficient functions as long as I understand the code....
Is there any way to do this non recursive which I would perfer?
Got this for now (not much but...)
package recursivo;
import java.io.File;
import java.io.IOException;
import java.net.SocketException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import org.apache.commons.net.ftp.FTPClient;
public class recursivo
{
/**
* @param args
*/
public static int counter=1;
public static void main(String[] args)
{
int i=0;
String ip="127.0.0.1";
for (i=0;i<50;i++)
{
Random random = new Random(System.nanoTime());
String name=String.valueOf(random.nextInt(10000000));
lookupforfolder(name,ip); //FUNCTION A
File b=new File(name+".bmp");
b.createNewFile();
insertfiletofolder(counter,name+".bmp",ip); //FUNCTION B
b.delete();
File j=new File(name+".jpg");
j.createNewFile();
insertfiletofolder(counter,name+".jpg",ip); //FUNCTION B
j.delete();
File x=new File(name+".bin");
x.createNewFile();
insertfiletofolder(counter,name+".bin",ip); //FUNCTION B
x.delete();
File p=new File("Path1.bin");
p.createNewFile();
insertfiletofolder(counter,"Path1.bin",ip); //FUNCTION B
p.delete();
}
} //end main
public static void insertfiletofolder(int counter,String filename,String ip)
{
FTPClient f=new FTPClient();
try {
f.connect(ip);
f.login("a","");
f.changeWorkingDirectory("/");
if (f.changeWorkingDirectory("WEBFOLDER")==false)
{
f.makeDirectory("WEBFOLDER");
f.changeWorkingDirectory("WEBFOLDER");
}
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
Date date = new Date();
String currentdate=dateFormat.format(date);
currentdate=currentdate.replace("/","");
currentdate=currentdate+"_"+Integer.toString(counter); // Is this: lookupFolder <- get current date string formatted as YYYYMMDD
// existFolder <- lookUpForFolder(mainFolderName, lookupFolder, FOLDER_COUNTER)
f.changeWorkingDirectory(/*step into existFolder*/);
f.storeFile(/*step into existFolder*/+"/"+filename, filename);
} catch (SocketException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} //end insertfiletofolder
} //end class
I understand some of what you wrote but I just do not know how to implement it.
For #1, that's why you should never separate the value and kept in 2 separated local variables. Keep the value out side and pass through the call, or keep no value but let the call figure it out. For #2, then why need underscore? If it is going to be 10 maximum, don't use up your precious count with not that meaningful character. Then you will have now 99 folders.
OK Ill attempt based on your pseudocode implement it with the value on the outside....
Even if I reach 99, the maximum that can be processed is 44 so........Also Ive been specified to do it this way (with underscore) and only up to 9. 891 files in total is MORE than enough.
To answer your question, you should see that it is at the beginning of my pseudo code -- A_MAIN_FOLDER_NAME.
I think your pseudocode is missing a lot of things (or at least some don't make sense) but I imagine this being intentional. I might even implement it now and see how it goes.
There are still questions regarding your approach.
1)Is your program keep the folder counter at all time? If so, is the value accessible by both function A and B? Or do you want to keep counter value separately for both? If you are thinking about keeping each function's local value, I will tell you that don't. The value should be from the same variable for both function A and B to access. If you keep them separated, you will have problem keeping track of your program states. Besides, it is a bad idea to decouple functions because both functions are directly related.
2)Why do you have to generate a random number for folder once the counter gets up to 9? Why don't you keep the counter going without a limit? Please enlighten me.
1) Yes, it will keep the folder counter all the time. The value is accessible and used by both functions BUT the variables are local to each function. Im not sure how to proceed using a local variable to the main function and use it between function a and b chaning values
2) Length issues (always 10 characters). The folders will be 20121512_1 to 20121512_9 ; Obviouly 10 makes it 11 characters. This is something someone else needs to use and program to as well so it has to stay 10 chars.
By the way, below is a pseudo code for the portion of searching & creating folders. It is the …
Apparently Intel processors from Ivy Bridge onwards have a hardware random number generator instruction that is as near quantum-mechanical noise random as you can be... http://software.intel.com/sites/default/files/m/d/4/1/d/8/441_Intel_R__DRNG_Software_Implementation_Guide_final_Aug7.pdf
Nice but, software/Java only please :)
By process I ment functions............They arent seperete process via thread and such. Damn, sorry for that wrong term
1: No. FUNCTION A which needs to create folders before FUNCTION B inserts filres
2: Exactly. FUNCTION B creates inserts files into folders made by FUNCTION A
3: A main. My program is this (obviously testing purposes):
public static void main(String[] args) throws SocketException, IOException
{
int i=0;
String ip="192.168.100.2";
for (i=0;i<50;i++)
{
Random random = new Random(System.nanoTime());
String nombre=String.valueOf(random.nextInt(10000000));
hacercarpetaversiontres(nombre,ip); //FUNCTION A
File b=new File(nombre+".bmp");
b.createNewFile();
meterarchivonuevaversion(nombre+".bmp",nombre,ip); //FUNCTION B
b.delete();
File j=new File(nombre+".jpg");
j.createNewFile();
meterarchivonuevaversion(nombre+".jpg",nombre,ip); //FUNCTION B
j.delete();
File x=new File(nombre+".bin");
x.createNewFile();
meterarchivonuevaversion(nombre+".bin",nombre,ip); //FUNCTION B
x.delete();
File p=new File("Path1.bin");
p.createNewFile();
meterarchivonuevaversion("Path1.bin",nombre,ip); //FUNCTION B
p.delete();
}
} //end main
4: No. It is called upon
5: NA
6: Could be but at the same same same SAME time, unlikely.
7: No. It would insert a file into if it is first (20121214_1 comes/is created before 20121214_2) and that folder has less than 44 files inside of it. After that, next "set" of files
8: Function A always runs before function B
Actually, there is no such thing in reality as a "perfect" random number generator. There are good ones, and there are ok ones. See this tutorial for more information: http://www.phy.ornl.gov/csep/CSEP/RN/RN.html
I like this from the extended summary (the posting is from one of the foremost research labs in the US, Oak Ridge National Laboratory):
And as an aside, I have done research into random number generators, and find that I personally like the lagged fibonnaci generators. I used such techniques in the 1980s when developing index fund balancing algorithms for the Mellon Bank / Mellon Capital Management. They worked very well.
I know that 100% random numbers are impossible but I want to get as close to 100% as possible.
Its out of curiousity nothing else...
Here it is:
Dont look at the code, just post a bit how you would implement it, even in pseudoJavacode.
Hi
This is related to 3 threads:
http://www.daniweb.com/software-development/java/threads/438729/recursive-ftp-listingmakingcreatingetc-access
http://www.daniweb.com/software-development/java/threads/439941/recursive-ftp-listingmakingcreatingetc-access...-part-2
http://www.daniweb.com/software-development/java/threads/442142/recursive-ftp-listingmakingcreatingetc-access...-part-3
At first, I had NO clue where to even start. Over a couple of weeks, Ive slowly but surely started to make the process correctly but Im stumpped so (for the third time) ive thought of rewriting everything from sratch.
I only have two functions right now: createfolder and insertfile. Nothing else.
My requirements are the following:
Random number is a number common to process A and B
My main path is C:/ we base everything off that.
In C:/, we see if a folder called Webfolder exists. If it does, we enter it. If it doesnt, we created it.
Once it is created and found, we enter it.
Process A: Counter is a local variable that equals 1. It is local to Process A. I make a folder with the current date and "" and the counter ONLY if there are less than 44 file inside this webfolder. If there is more than 44 files, I add one to a counter and then make a folder with the current date and the "" and the counter as long as it has less than 44 files inside. If not process A is repeated until counter is 9.
Once Process A is completed, I change to that that current date and "_" and the counter folder and inside make a folder with a random number.
Next, we have to insert …
Don't have time right now... Will try to take a look at it tomorrow... PS: I usually do not go through posts that past the first page. Sometimes I would go through on 2nd or 3rd page but that's it. If your post is bumped down way too far, I may not see it.
Better yet, Im going to start a new thread with fresh ideas on how to approch this. Maybe thats what I need....
Rewrote it and similar problems. This cant be this difficult to do....
Now it swallows the first one of the second folder.....Very annoying. Thought that Daniweb would have enough knowledge to know how to fix this.
Anyways Im problably rewriting both functions today, from scratch.
BTW, you will get better answers if you actually tell us why you need random/unique numbers...
Why? Really no reason; I just want to generate random numbers which are closest to 100% unique.
There honestly is no reason.
UUID.randomUUID().toString() gives the random-almost-unique string you are looking for. Replace the dashes which are present in the returned string if you don't need them.
I need a number (integer or/and long, no decimals). Not a string.
for questions about UUID you should check here
also: if you want it to be 100% ... hard to do, especially without some additional coding from your part. as you probably know, there are collections that don't accept doubles, so try storing all the so-far existing keys in one of those, and see whether or not when you add a generated one, it is added.
Thats a link to the same page sos put. It tells me absolutly nothing except what functions there are.
I know 100% is impossible but the closest to it.
Look into the UUID class offered by Java. Though the probability of collision is not 0%, it's still very low. Read this.
Which function to I call from that class to give me a random number? hash, etc.
In java what is the best way to create a truely random number sequence? One that is 100% never to be repeated again
Thank you
If you use the default PHP date functions then you should be able to get it going. You can use setlocale to get other languages.
Problem is that it wont check for Feburary 31th right?
Too bad... all of my users prefer the jQuery UI datepicker A LOT over three comboboxes. Consider your clients, not your preference. PHP only may be a little tricky. I am sure you'd want the days for February to adjust correctly without refreshing the page.
Thank you for your opinion but no; 3 comboboxes will be what the audience of my page chooses.
Hello
Im looking for a good date picker and easy to implement. HTML, PHP, and/or Javascript.
Since this is professional, I need also several things:
1: Language support.
2: If I pick Feburary, it doesnt show a legal day as 31
3: 3 dropdown boxes: One for month, another for day and another for year
4: It needs to return a string such as 12-31-2012 which I can easy capture and send it via POST/GET. If can be configured even better
5: Lightweight; No external libraries
I perfer PHP, then HTML and last Javascript. God I hate Javascript.
Thank you
Nothing still. Now it directly "swallows" it (it disappears)....Very odd.
No ideas at all? In the first two threads, you guys really helped and pretty much solved it...
Anyone?
Yup, that solves it theHop
public class recursiveftp
{
public static void meterarchivo(String elarchivo,String elnombredelprograma) throws SocketException, IOException
{
int counter=1;
FTPFile found;
int done=0;
String filetest=elarchivo;
String extension=filetest;
extension=extension.substring(extension.indexOf("."),extension.indexOf(".")+4);
String nombreprograma=filetest;
FTPClient f=new FTPClient();
System.out.println("Trying");
f.connect("192.168.100.2");
f.login("something","soemth");
System.out.println("YES!");
File e=new File(filetest);
//e.createNewFile();
FileInputStream s=new FileInputStream(e);
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
Date date = new Date();
String fechaactual=dateFormat.format(date);
fechaactual=fechaactual.replace("/","");
String cai=fechaactual; //folder I want to use
f.changeWorkingDirectory("/");
f.changeWorkingDirectory("webfolder");
FTPFile[] list = f.listFiles();
while (done==0)
{
found=null;
if (counter==1)
{
cai=fechaactual;
///f.makeDirectory(cai);
//f.changeWorkingDirectory(cai);
}
else
{
cai=fechaactual+Integer.toString(counter);
//f.makeDirectory(cai);
//f.changeWorkingDirectory(cai);
}
for (int i=0;i<list.length;i++)
{
if ((list[i].getType() == FTPFile.DIRECTORY_TYPE) && (list[i].getName().equals(cai)))
{
found=list[i];
break;
}
}
if (found!=null)
{
//f.changeWorkingDirectory("/"+found.getName());
//f.changeWorkingDirectory("/webfolder/"+found.getName());
f.changeWorkingDirectory(found.getName());
FTPFile[] list2 = f.listFiles();
int archivos=0; //number of files
for (int x=0;x<list2.length;x++)
{
if (list2[x].getType()==FTPFile.FILE_TYPE)
{
archivos=archivos+1;
}
}
System.out.println("Working with "+f.printWorkingDirectory()+"/"+e.getName());
System.out.println("Total file: "+archivos);
if (archivos<44)
{
if (extension.equals(".bmp"))
{
System.out.println("Soy un bmp");
f.setFileTransferMode(FTP.BINARY_FILE_TYPE);
f.setFileType(FTP.BINARY_FILE_TYPE);
f.storeFile(f.printWorkingDirectory()+"/"+e.getName(), s);
done=1;
}
else
{
f.changeWorkingDirectory(f.printWorkingDirectory());
System.out.println("nombreprograma es " + nombreprograma);
f.setFileTransferMode(FTP.BINARY_FILE_TYPE);
f.setFileType(FTP.BINARY_FILE_TYPE);
System.out.println("estoy en " + f.printWorkingDirectory());
f.storeFile(f.printWorkingDirectory()+"/"+elnombredelprograma+"/"+e.getName(), s);
//f.rename(f.printWorkingDirectory()+"/"+e.getName(), f.printWorkingDirectory()+"/"+nombreprograma+"/"+e.getName());
done=1;
}
}
else
{
System.out.println("Cambio al parent directory");
f.changeToParentDirectory();
//f.changeWorkingDirectory("/webfolder/");
counter=counter+1;
}
}//end if found not null
else //if found equals null
{
//f.makeDirectory("/"+cai);
//f.changeWorkingDirectory("/"+cai);
//f.changeToParentDirectory();
f.changeWorkingDirectory(cai);
f.storeFile(f.printWorkingDirectory()+"/"+e.getName(), s);
done=1;
}
}//end while
f.logout();
f.disconnect();
} //meterarchivo
public static void hacercarpeta(String nombre) throws SocketException, IOException
{
int counter=1;
FTPFile found;
int done=0;
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
Date date = new Date();
String fechaactual=dateFormat.format(date);
fechaactual=fechaactual.replace("/","");
String nombreprograma=nombre;
FTPClient f=new FTPClient();
System.out.println("Trying");
f.connect("192.168.100.2");
f.login("Asdfs","afdfd");
System.out.println("YES!");
String cai=fechaactual; //folder I want to use
f.changeWorkingDirectory("/");
if (f.changeWorkingDirectory("webfolder")==false) …
Posting code now.....
Any clearing up just ask because since it is SO big Ive split it up like I mentioned. Ill try to add comments....
This a followup to these two threads:
http://www.daniweb.com/software-development/java/threads/438729/recursive-ftp-listingmakingcreatingetc-access
http://www.daniweb.com/software-development/java/threads/439941/recursive-ftp-listingmakingcreatingetc-access...-part-2
For the "real thing" Ive decided to break it to two function: Insert file and make directory.
Ill reexplain what I am trying to do.
Im going to go a folder called "webfolder".
If it isnt found, it is created.
If it is found and a folder with the current date isnt isnide of it, a folder is created inside with the current date (a folder inside webfolder would be created called 12042012).
If that folder with the current date exists,
if there is more than 44 files inside,
then a second folder inside of webfolder would be created instead with a number (a folder inside webfolder would be created called 12042012_1 instead).
if it the folder with the current date does not have more than 44 files inside, a bmp file with a generated random num is created and then folder with that same num is created (so inside of webfolder and inside the current date foler, another folder with a generate random num). Inside this folder two files will be created.
The good news is that the code works 99.9% :) So thats reliving. The bad news is that when it detects that 44 limit, it puts it in the wrong place....
Its something like:
C:
------> webfolder
----------------->currentdate
--------------------------------------------->randomnumber
---------------------------------------------------------->file1
---------------------------------------------------------->file2
----------------------------->randomnumberbmp
--------------------------------------------->randomnumber1
---------------------------------------------------------->file1of1
---------------------------------------------------------->file2of1
----------------------------->randomnumber1bmp
--------------------------------------------->randomnumber2
---------------------------------------------------------->file1of2
You guys really need to stop kissing Dani's ass.....I said my opinion; I stated it not only in my first post but also in the title! Im glad Dani appriciates "as is" comments. Of course, her, my, and others opinions can differ and thats OK. Even though I dont like the posting system and I cannot get used to it, I like the site because most people are helpful.
I understand that repping/solved by yourself it is not implemented because it can be abused....
I cant because it gives the answer to someone else
At present there's no feature for marking a single post as being the solution, aside from voting and adding reputation to that post, of course. It's in the cards, just not implemented yet. ;)
Which I also cannot do; Rep my own post. Would people abuse it? Would a doubt. But solving my own question and not giving rep, would be a good solution....
Please, don't think that I an advocating the attitude of the original poster. I would be very happy to repost my comments in a new and constructively titled thread.
No attitude at all. I like the helpfulness of the members but I hate the pig behind the lipstick.
It troubles me that just because of this thread you posted a problem though :( I hope this is not all cases....
Hello
I answered my own thread and marked the thread as solved but it gave another user (which really didnt help at all) the "solved post". How can I select who and what post solved the thread?
Rep the answer please :) Thank you
Solved by.....me
<?php
$fp = fopen(getcwd()."/test.txt", "w");
fwrite($fp, "hello");
fclose($fp);
chmod(getcwd()."/test.txt", 0777);
unlink(getcwd()."/test.txt");
?>
I made a copy of the file that I originally write and I can delete that copy:
<?php
$fp = fopen(getcwd()."/test.txt", "w");
fwrite($fp, "hello");
chmod(getcwd()."/test.txt", 0777);
copy(getcwd()."/text.txt", getcwd()."/something.txt");
unlink(getcwd()."/something.txt"); /*THIS WORKS*/
unlink(getcwd()."/test.txt"); /*THIS DOES NOT WORK*/
fclose($fp);
?>
ok try copy a file to it and check it permission if is read/write then from your php scrip delete it.
What? Please speaker clearer :)
my little advise for you is create a folder and set the access permission through windows for that folder to be read/writable then further with your program.
I already set the permissions for that folder. Still does not work.
Hello
First off the server is running Windows 7 32bits.
I have the following code:
<?php
$fp = fopen(getcwd()."/test.txt", "w");
fwrite($fp, "hello");
chmod(getcwd()."/test.txt", 0777);
unlink(getcwd()."/test.txt");
fclose($fp);
?>
It creates the file perfectly but afterwards I cannot delete it. Giving me this error:
Warning: unlink(C:\test.txt) [function.unlink]: Permission denied in C:\writeanddel.php on line 4
First off, I know chmod doesnt work in Windows but I added it anyways.
Second, Im sure that the folder test is written on (obviously not C:/) has complete write/read access for everyone.
Whats wrong and how can I do this correctly?
taking the plus out would replace all whitespace chars with nothing variable.replace(/\s/g,""); if it's not working maybe there's something in the code surrounding this that needs debugging.
It doesnt work for that character
Hello
I want to remove this:
As you see it is a blank but the regular variable.replace(/\s+/g,''); does not work. I generate this character with Alt+0160 The best way would be its ascii code so how do I do it?
That should work, although you need to escape the backslash and single quote. What's the problem?
There; How do I "escape"?
Hello
I want to do a indexOf but of certain special characters such as
variable.indexOf(''')==-1)
variable.indexOf('/')==-1)
variable.indexOf('\')==-1)
variable.indexOf('"')==-1)
etc, etc. How can I do this?
Im on the page showing the products I have avaliable in my Magento store. I want to get the current ID of the order (or the ID of the cart, something unique that I can follow right up until I pay) should I continue on adding the order to my cart and buy it at the end.
Since the order per say does not exist and more than one person can buy at the same time, I would have to calculate the order ID someway while making sure that it does not conflict with another person making another order at the same time.
Another thing is like I mentioned that this is on the product listing page (/../../../../../template/catalog/product/list.phtml) so a “order” per say (I mentioned this before) does not exist.
How can I get the best possible way a order ID (or the cart ID) that is not in usage?
My work is on IE9 but my house has switched to preview version of IE10 so I cant report much bugs anymore except if they happen on my work PC...
It doesnt say anything. I want to either force it to run as admin or if it detects if it isnt running as admin, exit itself.