Jump to content

vidyashankara

Members
  • Posts

    75
  • Joined

  • Last visited

    Never

Posts posted by vidyashankara

  1. index.php
    [code]

    echo "<p><img src=/images/part2index.jpg>

    <form enctype=multipart/form-data method=post action=upload.php>

    <input type=file name=file />

      <input type=image src=/images/uploadindex.jpg value=Upload>

    </form>";
    [/code]

    upload.php

    [code]
    ini_set("display_errors",1);
    $time=time();

    // Where the file is going to be placed
    chdir("uploaded_pdb");

    mkdir($time,0777);
    chdir($time);
    $target_path = "uploaded_pdb/$time/";



    /* Add the original filename to our target path. Result is "uploads/filename.extension" */

    $filename = basename($_FILES['file']['name']);
    $target_path = $target_path . $filename;




    // This is how we will get the temporary file...

    $tmpname = $_FILES['file']['tmp_name'];
    $move = move_uploaded_file($tmpname, $target_path);


    if ($move) {

        echo "The file $filename has been uploaded";

    } else {

        echo "There was an error uploading the file, $filename, please try again!";

    }
    print "<pre>";
    echo 'Here is some more debugging info:<br>';
    print_r($_FILES);
    print "</pre>";

    [/code]

    Output of array file
    [code]

    Array
    (
        [file] => Array
            (
                [name] => 1.txt
                [type] => text/plain
                [tmp_name] => /tmp/phpyxLK1B
                [error] => 0
                [size] => 666
            )

    )
    [/code]

    the error i get is

    [code]
    Warning: move_uploaded_file(uploaded_pdb/1154116683/1.txt): failed to open stream: No such file or directory in /var/www/html/pdbreader/upload.php on line 20

    Warning: move_uploaded_file(): Unable to move '/tmp/phpyxLK1B' to 'uploaded_pdb/1154116683/1.txt' in /var/www/html/pdbreader/upload.php on line 20
    There was an error uploading the file, 1.txt, please try again!

    [/code]


    whats wrong??? the code looks perfect to me...
  2. I have this function on my php script..

    [code]
    echo "
    function add() {
    var i =1;
    var txt = \"SEGID : <select name='segid[]'>";
    for ($i=0; $i<count($atm); $i++) {
    echo "<option value='PRO$atm[$i]'>PRO$atm[$i]";
    }
    echo "</select>\";
    txt +=\" Residue : <select name='resi[]'> <option value=ASP>ASP <option value=GLU>GLU <option value=LYS>LYS </select>\";
    txt +=\" Residue ID : <input type='text' name='resid[]' + i><br>\";
    document.getElementById('prot').innerHTML += txt;
    }";
    [/code]

    This function adds a set of text boxes everytime you click a button. The problem is, when you click on the button the second time, the values in the first set of text boxes gets reset and i gotta enter them again. is there anyway to prevent that?
  3. I have this function on my php script..
    [code]
    echo "
    function add() {
    var i =1;
    var txt = \"SEGID : <select name='segid[]'>";
    for ($i=0; $i<count($atm); $i++) {
    echo "<option value='PRO$atm[$i]'>PRO$atm[$i]";
    }
    echo "</select>\";
    txt +=\" Residue : <select name='resi[]'> <option value=ASP>ASP <option value=GLU>GLU <option value=LYS>LYS </select>\";
    txt +=\" Residue ID : <input type='text' name='resid[]' + i><br>\";
    document.getElementById('prot').innerHTML += txt;
    }";
    [/code]

    This function adds a set of text boxes everytime you click a button. The problem is, when you click on the button the second time, the values in the first set of text boxes gets reset and i gotta enter them again. is there anyway to prevent that?
  4. nogray.. you rock! Thanks a lot!

    and just one more question, now we have so many text boxes, how do i read the data submitted in this box? The script reads only the value in the last box. should i put the name of the form as resid[] ? instead of just resid?
  5. Doesnt seem to work again now. I think i screwed up something.

    [code]
    echo "<head>

    <script language=\"javascript\">";

    echo "
    function add() {
    var txt = \"<input type='checkbox' name=prot[] value='prot'> Selection of Protonation of Residues:<br>SEGID : <select name='segid'>";
    for ($i=0; $i<count($atm); $i++) {
    echo "txt += <option value='PRO$atm[$i]'>PRO$atm[$i]";
    }
    echo "txt +=</select>\")
    txt +=\"Residue : <select name=resi> <option value=ASP>ASP <option value=GLU>GLU <option value=LYS>LYS </select>\";
    txt +=\"Residue Id : <input type='text' name='resid' onClick='add()'><br>\");
    document.getElementById('code').innerHTML += txt;

    }";


    echo "
    </script>
    </head>";


    echo "<br>
    <input type=checkbox name=prot[] value='prot'> Selection of Protonation of Residues:<br>";

    echo "SEGID : <select name=segid> ";


    for ($i=0; $i<count($atm); $i++) {
    echo "<option value=PRO$atm[$i]>PRO$atm[$i]";
    }

    echo "</select>



    Residue :
    <select name=resi>
    <option value=ASP>ASP
    <option value=GLU>GLU
    <option value=LYS>LYS
    </select>
    Residue Id : <input type=\"text\" name=\"resid\" onClick=\"add()\"><p>
    <body onload=\"add();\">
    <div id=\"code\">";
    [/code]

  6. Dude, you are amazing dude. Its working now!

    thanks a lot :)

    Just one little problem

    in the following line, the onClick doesnt work, i tried /"add()/" and it still doesnt work. what do i do?
    [code]
    document.write(\"Residue Id : <input type='text' name='resid' onClick='add()'><br>\")
    [/code]
  7. Ok, I removed the Function add() and the function cat() started to work alright, so There's something wrong with the first function.

    The Generated Code
    [code]

    function add() {
    var i = 1;
    document.write("<input type='checkbox' name=prot[] value="prot"> Selection of Protonation of Residues:<br>SEGID : <select name="segid"><option value="PROA">PROA<option value="PROB">PROB<option value="PROC">PROC<option value="PROD">PROD</select>")
    document.write("Residue : <select name=resi> <option value=ASP>ASP <option value=GLU>GLU <option value=LYS>LYS </select>")
    document.write("Residue Id : <input type="text" name="resid" + i onClick="add()"><br>")
    }

    [/code]

    PHP Code

    [code]
    function add() {
    var i = 1;
    document.write(\"<input type='checkbox' name=prot[] value=\"prot\"> Selection of Protonation of Residues:<br>SEGID : <select name=\"segid\">";

    for ($i=0; $i<count($atm); $i++) {
    echo" <option value=\"PRO$atm[$i]\">PRO$atm[$i]";
    }

    echo "</select>\")
    document.write(\"Residue : <select name=resi> <option value=ASP>ASP <option value=GLU>GLU <option value=LYS>LYS </select>\")
    document.write(\"Residue Id : <input type=\"text\" name=\"resid\" + i onClick=\"add()\"><br>\")
    }";

    [/code]
  8. [code]
    <script language="javascript">
    function add() {
    var i = 1;
    document.write("<input type='checkbox' name=prot[] value="prot"> Selection of Protonation of Residues:<br>SEGID : <select name="segid"><option value="PROA">PROA<option value="PROB">PROB<option value="PROC">PROC<option value="PROD">PROD</select>")
    document.write("Residue : <select name=resi> <option value=ASP>ASP <option value=GLU>GLU <option value=LYS>LYS </select>")
    document.write("Residue Id : <input type="text" name="resid" + i onClick="add()"><br>")
    }
    function cat(txt) {
    alert(txt)
    }
    </script>
    </head><br>
    <input type=checkbox name=prot[] value='prot'> Selection of Protonation of Residues:<br>SEGID : <select name=segid> <option value=PROA>PROA<option value=PROB>PROB<option value=PROC>PROC<option value=PROD>PROD</select>


    Residue :
    <select name=resi>
    <option value=ASP>ASP
    <option value=GLU>GLU
    <option value=LYS>LYS
    </select>
    Residue Id : <input type="text" name="resid" onClick="cat('Hello')"><p><br>

    [/code]

    Thats my generated Code. it seems alright to me.
  9. [code]
    echo "<head>

    <script language=\"javascript\">";

    echo "function add() {
    var i = 1;
    document.write(\"<input type=\"checkbox\" name=prot[] value=\"prot\"> Selection of Protonation of Residues:<br>SEGID : <select name=\"segid\">";

    for ($i=0; $i<count($atm); $i++) {
    echo"<option value=\"PRO$atm[$i]\">PRO$atm[$i]";
    }

    echo "</select>\")
    document.write(\"Residue : <select name=resi> <option value=ASP>ASP <option value=GLU>GLU <option value=LYS>LYS </select>\")
    document.write(\"Residue Id : <input type=\"text\" name=\"resid\" + i onClick=\"add()\"><br>\")
    }";

    echo "function cat(txt) {
    alert(txt)
    }";

    echo "
    </script>
    </head>";


    echo "<br>
    <input type=checkbox name=prot[] value='prot'> Selection of Protonation of Residues:<br>";

    echo "SEGID : <select name=segid> ";


    for ($i=0; $i<count($atm); $i++) {
    echo "<option value=PRO$atm[$i]>PRO$atm[$i]";
    }

    echo "</select>



    Residue :
    <select name=resi>
    <option value=ASP>ASP
    <option value=GLU>GLU
    <option value=LYS>LYS
    </select>
    Residue Id : <input type=\"text\" name=\"resid\" onClick=\"cat('Hello')\"><p>";
    [/code]

    Hi, this is the code that i have right now. For some reason, i cant call the javascript function when i click on the text box. All the variable like $atm is defined earlier in the script. I added another function "cat" just to test if its working, but its not calling javascript at all. how do i do it?

    Thanks
    Vidyashankara
  10. I have 2 scripts.  A.php and B.php

    In A.php,
    I have 3 text fields.

    and in B.php,
    i have the script read these text fields and perform certain operations

    Now the problem is, in A.PHP, if the users wants to do multiple functions, he should be able to do it

    for eg.
    As soon as the user fills out the 3 text fields, 3 more should turn up automatically and once he fills those, 3 more should turn up and so on.
    and when he clicks submit, the script should takes all the values and give it to B.php

    I heard you can do it only with javascript. how do you do it? is this possible?
  11. I am calling the following system command

    [code]
    $command = "sed '1~3 {N;N;s/\n //g}' $biofile > $id.biomat1";
    s ystem($command, $output);
    [/code]

    for some reason, It changes to

    [code]
    $command - sed '1~3 {N;N;s/ //g}' $biofile > $id.biomat1";
    [/code]

    the /n is missing.

    I changed it to
    [code]
    $command = "sed '1~3 {N;N;s/\ ".\n." //g}' $biofile > $id.biomat1";
    s ystem($command, $output);
    [/code]

    but the php has a space between \ and n. How do i get rid of that space?
  12. I have the following arrays

    [code]
    Array
    (
        [0] => 2  A1 B1 C1 X      

        [1] => 2  A2 B2 C3 Y        

        [2] => 2  A3 B3 C3 Z      

        [3] => 3  D1 E1 F1 A        

        [4] => 3   D2 E2 F2 B          

        [5] => 3   D3 E3 F3 C          

        [6] => 4  G1 H1 I1 J        

        [7] => 4  G2 H2 I2 K      

        [8] => 4  G3 H3 I3 L  

    )
    [/code]


    How do i merge it to output the following?
    [code]
    Array
    (
        [0] => 2  A1 B1 C1 X     A2 B2 C3   Y      A3 B3 C3 Z      

        [1] => 3  D1 E1 F1 A     D2 E2 F2 B      D3 E3 F3 C  

        [2] => 4   G1 H1 I1 J     G2 H2 I2 K    G3 H3 I3 L  
    }

    [/code]

    Is this possible? Please help me out. I was thinking of the following code
    [code]
    $count = $array[0];
    if (!array_unique($count)) {
    array_merge($array)
    }

    [/code]

    Doesnt work, i dont know how to define the arrays to merge...
  13. [code]
    1 A1 B1 C1 1 A2 B2 C2 1 A3 B3 C3 //all the coordinates of matrix 1
    2 A1 B1 C1 2 A2 B2 C2 2 A3 B3 C3  //all the coordinates of matrix 2
    3 A1 B1 C1 3 A2 B2 C2 3 A3 B3 C3  //all the coordinates of matrix 3
    [/code]

    Can atleast this be done? all the elements of the first 3 rows into the first line, second 3 rows into the second line?


  14. I have the Following text file

    [code]
    1 A1 B1 C1 //first row in matrix 1
    1 A2 B2 C2 //second row in matrix 1
    1 A3 B3 C3 //third row in matrix 1
    2 A1 B1 C1 //first row in matrix 2
    2 A2 B2 C2 //2nd row in matrix 2
    2 A3 B3 C3 //3rd row in matrix 2
    3 A1 B1 C1 //first row in matrix 3
    3 A2 B2 C2 //2nd row in matrix 3
    3 A3 B3 C3 //3rd row in matrix 3
    [/code]

    I want to rearrage it to
    [code]
    1 A1 B1 C1 A2 B2 C2 A3 B3 C3 //all the coordinates of matrix 1
    2 A1 B1 C1 A2 B2 C2 A3 B3 C3  //all the coordinates of matrix 2
    3 A1 B1 C1 A2 B2 C2 A3 B3 C3  //all the coordinates of matrix 3
    [/code]

    How do i do this dynamically? There can be any number of matrices...


    Thanks
  15. I have the Following text file

    [code]
    1 A1 B1 C1 //first row in matrix 1
    1 A2 B2 C2 //second row in matrix 1
    1 A3 B3 C3 //third row in matrix 1
    2 A1 B1 C1 //first row in matrix 2
    2 A2 B2 C2 //2nd row in matrix 2
    2 A3 B3 C3 //3rd row in matrix 2
    3 A1 B1 C1 //first row in matrix 3
    3 A2 B2 C2 //2nd row in matrix 3
    3 A3 B3 C3 //3rd row in matrix 3
    [/code]

    I want to rearrage it to
    [code]
    1 A1 B1 C1 A2 B2 C2 A3 B3 C3 //all the coordinates of matrix 1
    2 A1 B1 C1 A2 B2 C2 A3 B3 C3  //all the coordinates of matrix 2
    3 A1 B1 C1 A2 B2 C2 A3 B3 C3  //all the coordinates of matrix 3
    [/code]

    How do i do this dynamically? There can be any number of matrices...


    Thanks

  16. I have a number of text files that are got from the previous page. I need a script to read this files, and make some operations. i have the following script

    [code]
    $files = $$HTTP_POST_VARS["files"]; //gets the file names.

    foreach($files as $file) {
    $contents=file_get_contents($file); //read contents into an string
    $atomarray = explode("\n", $atomstart);  // read string into array

    for ($i=0; $i<count($atomarray); $i++) {
    $resi[$i] = substr($atomarray[$i], 13, 3); // read the 14,15,16 character of each line
    }

    $resi = array_unique($resi); //get only unique results
    sort($resi);  // sort results

    $resi1 = implode(" ", $resi);  //seperate results with a space.

    if (strpos($resi1, " ABC ")) {
        $str="Hi" // if ABC exists, $str = "hi"
    }
    if (strpos($resi1, "XYZ")) {
            $str="Bye" // if XYA exists, $str = "bye"
    }

    $fp = f open("test.txt", "w");
    f write ($fp, $str);
    f close($fp);
    }
    [/code]

    The problem with this script is that when ask it to echo $resi1, It echos only the results from the last file. The script might have to read anywhere between 2 to 5 files, can you find anything wrong with the script?

    Thanks
  17. The strpos function doesnt seem to work for some reason.

    Here is my code.

    [code]
    $head = strpos($line, "MODEL         $number");
    echo $head;
    [/code]

    [code]
    $line is a text file, i did $line=file_get_contents;
    [/code]

    [code]
    $number is a number variable. like 1,2 ,3,
    if $number =1 ,

    then the function will be
    $head = strpos($line, "MODEL         1");
    echo $head;
    [/code]

    The function should return a number of the firt occurance right?

    I dont get any error message, The text file i am using is really huge... do you find any error? do you know any better way to find out?
×
×
  • 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.