Jump to content

benphp

Members
  • Posts

    336
  • Joined

  • Last visited

Posts posted by benphp

  1. I'm the owner. I'm using

     

    <?php
    $fp = fopen($path.$_POST['signup'], 'w') or die("Sorry");
    flock($fp, LOCK_EX);
    fwrite($fp, $string);
    flock($fp, LOCK_UN);
    fclose($fp);
    ?>
    

     

    which works on my windows dev box, but then when I upload it to my Linux server, it doesn't. I have to set the directory to 777. 775 doesn't work - other security settings didn't work.

     

  2. Here's a grid generator. You can pick it apart and use it to your needs.

     

    <form action="" method="post">
    <input type="text" name="cols" value="4" size="2" maxlength="2">
    <input type="submit" value="Go" name="btnGo">
    </form> 
    
    
    <?php
    if (isset($_POST['btnGo']) && $_POST['cols'] > 0 && $_POST['cols'] != "") {
    $cols = $_POST['cols']; //number of columns to use
    } else {
    $cols = 4; //number of columns to use
    }
    
    print "\n<form action=\"\" method=\"post\">";
    print "\n<input type=\"text\" name=\"cols\" value=\"$cols\" size=\"2\" maxlength=\"2\">";
    print "\n<input type=\"submit\" value=\"Go\" name=\"btnGo\">";
    print "\n</form> \n";
    
    $anyOldArray = array("1. Nemo","2. Marlin","3. Coral","4. Dory","5. Phil","6. Bob","7. Bloat","8. Gurgle","9. Pearl","10. Bruce","11. Chum","12. Nigel","13. Gill","14. Jacque");
    print "<table border=\"1\"> \n<tr>"; //print the table
    $colCount = 1; //counts the column number being printed, starting at 1 - you're going to have at least one column.
    $numElements = count($anyOldArray); //count number of elements in array
    $i = 0; //loop counter
    //This while loop does two things: it prints a cell when an element exists, and it starts a new row if
    //there are more elements and it has reached the end of a row. 
    while($i < $numElements) { //Do this while loop counter is less than total array element count. 
    //Find the last cell in the row. If $colCount==$cols then this is the last column in the row, so end it and start another
    //The $i < $numElements-1 means DON'T start another row, because there aren't any more elements. For example, 
    //you don't want to start a new row when you have 4 columns and 8 elements. 
    if(($colCount==$cols) && ($i < $numElements-1) ) { 
    	print "\n\t<td>$anyOldArray[$i]  </td> \n</tr> \n<tr>";
    	$colCount = 1; //reset the column counter to 1, because you're starting a new row, so the first column is $colCount 1
    } elseif($numElements > 0) { //if it isn't the last cell, just print a regular cell
    	print "\n\t<td>$anyOldArray[$i]  </td>  ";
    	$colCount++; //add to your $colCount, because you just printed another element in a column.
    }
    $i++; //increment your loop counter.
    }
    //The above loop will write only cells that have elements to display in them. So when you run out of elements, what then?
    //The following loop fills in the remaining cells when your elements run out - so you don't get a table shaped like an F.
    //While fill out the remaining cells with a space [ number of columns is greater than the current row count ]
    //$colCount is set by the above script and is stuck at the last column printed. So if you have 14 elements in 4 columns, and you're on your last
    //row, the last printed element was in column #2
    while ($colCount <= $cols){ //keep printing cells until you reach the number of columns you want printed.
    print "\n\t<td> </td>";
    $colCount++; //keeps incrementing the number of columns printed - picks up where the first WHILE statement left off.
    } 
    
    print "\n</tr> \n</table> \n"; //close the row and table.
    ?>  
    

     

     

     

  3. var numerator = 186100488800821781.9216;

    var denominator = 496;

    var quot1 = (numerator / denominator);

    document.form.quotient.value = quot1;

     

    The result is:

    375202598388753.6

     

    but the real number (using a calculator) is

    375202598388753.59258387096774194

     

    It's been rounded off - without even using Math.Round. How do I get the actual number?

     

     

     

  4. This is probably simple for someone. I want to sort an array but maintain the array index (0, 1, 2, etc). Here's my example:

     

    <?php
    $testy = array ();
    $testy[] = "zebra";
    $testy[] = "alligator";
    $testy[] = "panda";
    $testy[] = "kangaroo";
    asort($testy);
    for($K = 0; $K < sizeof($testy); $K++) { 
    	$id = $K;
    	print "ID = ".$K.";";
    	print "Animal = ". $testy[$K];
    	print "<br />";
    }
    ?>
    

     

    This sorts the array, but my index gets jacked. It displays:

     

    ID = 0;Animal = zebra

    ID = 1;Animal = alligator

    ID = 2;Animal = panda

    ID = 3;Animal = kangaroo

     

    I want it to display:

     

    ID = 3;Animal = zebra

    ID = 0;Animal = alligator

    ID = 3;Animal = panda

    ID = 2;Animal = kangaroo

     

    Help!

  5. "Some people think they can just keep adding more and more features after you've begun development and agreed on a fixed price though"

     

    This has been my experience, which is why I've recently moved to an hourly rate. With previous jobs, I was far too generous in allowing the client to modify as we went along - ultimately, it was hardly worth my time.

     

    In the future, I'll go with a set price with solid requirements. Any modifications are extra and hourly. Trouble is, we often get into situations where new code is required due to unforeseen conflicts - and I end up coding-as-we-go.

     

    Pricing is tricky. I wish I had a billing department.

  6. Solved it:

     

    SELECT DISTINCT resp.rid, users.first, users.last, users.email 
    FROM users RIGHT JOIN resp ON users.uid = resp.uid 
    WHERE 1 = (SELECT MAX(resp2.rcount) FROM resp AS resp2 WHERE resp2.uid = $temp)  
    AND resp.uid = $temp
    ORDER BY users.last
    LIMIT 1
    

     

    revraz - it wouldn't work because it would return people who have both 1 and 2. I want to exclude people with both 1 and 2 and just return people with 1.

  7. Sorry to keep bugging you guys, but I've been working on this for hours and can't come up with a satisfactory statement. I'm trying to get a list of names of people in "users" that have an rcount of 1 ONLY. So I want to exclude people who have an rcount of 2 or 3. So selecting all with rcount = 1 isn't good enough. I need to select all with rcount = 1, but only 1.

     

    Any ideas?

     

    "resp"

    +-----+------+------+------+-------+---------+-------+--------+
    | rid | pid  | qid  | uid  | score | ractive | shift | rcount |
    +-----+------+------+------+-------+---------+-------+--------+
    |   1 |    1 |    1 |  215 | 1     | NULL    | 4     |      1 |
    |   2 |    1 |    2 |  215 | 2     | NULL    | 4     |      1 |
    |   3 |    1 |    3 |  215 | 1     | NULL    | 4     |      2 |
    |   4 |    1 |    4 |  215 | 2     | NULL    | 4     |      2 |
    |   5 |    1 |   31 |  216 | 2     | NULL    | 4     |      1 |
    |   6 |    1 |   13 |  216 | 2     | NULL    | 4     |      1 |
    |   7 |    1 |    5 |  216 | 3     | NULL    | 4     |      2 |
    |   8 |    1 |    6 |  216 | 1     | NULL    | 4     |      2 |
    |   9 |    1 |    7 |  217 | 1     | NULL    | 4     |      1 |
    |  10 |    1 |    8 |  217 | 1     | NULL    | 4     |      1 |
    

     

    "users"

    +-----+-------+----------+
    | uid | first | last     |
    +-----+-------+----------+
    | 204 | Mark  | Addama    |
    | 205 | Kevin | Barker   |
    | 206 | Bill  | Barnwell |
    | 207 | James | Bataki  |
    | 208 | Barry | Buer    |
    

×
×
  • 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.