Jump to content

mickeymouse

Members
  • Content Count

    81
  • Joined

  • Last visited

Posts posted by mickeymouse

  1. I'm Baffled.  My code (as far as I can see) matches W3 School tutorial example but it doesn't work.

    My button to go to the function doesn't react (it does if I remove my red text code.

    "function myDelDB()
    {var r = Confirm('Delete');
    if (r==true)

        {location.href='CAS_RoulDeleteDB.php'; return false;
        window.open(location.href); return false;}
    else{return false;}
    }"

  2. Wherever I'm using $link is because documentation told me to use it and I always used that and it always worked.

    As for my problem, it is resolved.  My logic was totally wrong. This is the way it should have been:

    while($Rows = mysql_fetch_row($Results))
                    {print("Number = $Rows[0],<br>");}

    My original code covered my (erroneous) thinking that $Rows were Records in the Database instead of $rows being the fields in the records.

    So sorry to have taken your time.

    Many thanks

     

  3. The only way I know how to check what is in $Results is by printing it with a While loop but it doesn't work.

    I figure $Results has to contain the correct info since $AffectedRows = 4.

    My code to get $Results is:

    $link = mysql_connect($host, $username, $password);
    if (!$link){die('Not connected : ' . mysql_error());}
    $db_selected = mysql_select_db($database, $link);
    if (!$db_selected){die ('Can\'t use ' .$database .':'. mysql_error());}
    $query = "SELECT * FROM `spindat` WHERE `hand` <> 'x' ";
    $Results = mysql_query($query, $link) or die ('Error = '. mysql_error());
    $AffectedRows = mysql_affected_rows($link);

  4. My $AffectedRows = 4 which matches my database rows but when I print via the following code only row 0 gets printed - screen output below.

    $cntr=0;

    while($AffectedRows > $cntr)

         {$row = mysql_fetch_row($Results);
           print("Number = $row[$cntr]<br>");
            $cntr++;}

    image.thumb.png.b5d55de7869da93d68a5185fce722c1c.png

  5. I don't know why I am getting "011" instead of "2" after 2 times through my function.

    My code is:

    <input name=\"ent2a\" type='number' id=\"ent2a\" size=\"1\" style=\"text-align:center\" MaxLength=2 value=0 onblur=\"chkent(ent2a)\">

    <input id='cntR' type='number' size='1'  MaxLength=2 value=0>

    function chkent(entry)
    {with (entry);
    var e = entry.value;
    if(e==1){cntR.value = cntR.value + 1;return false;}
    return false;}

  6. Isn't this code correct?

    I'm trying to test for the length of an input field when submit is clicked.

    function formcheck()

    {if(stdcd.value.length < 9){alert(\"MUST BE 9 CHARACTERS.\");return false;}
    return true;}

    Thanks

     

  7. How do we define the width for a Dropdown Box?

    My code is:

    print("<select name='title'>
             <option style='color:maroon; font-size:bold' name='title'>$title</option>");
        while ($row = mysql_fetch_row($Results))
             {print("<option value=$row[1]>$row[1]</option>");}
    print("</select>");.

    All of this works fine except I don't know where to define the width and can't find it in the W3S HRML documentation.

    Thank you

     

  8. It works perfectly on my other forms so it's not a browser related problem.

    I'll look at the link you gave me in more detail later but right now I would prefer to find the problem and fix it rather than venture into new stuff at this time.

    As I said, it works in my other forms so I don't see why it shouldn't work in this one.

    Thanks for your help and thanks for moving the item to Javascript - I keep thinking these functions I've coded are PHP - sorry about that.

     

  9. Shouldn't this code return me to my from and not take action to open the next program/file.

         function formcheck(myform)

         {alert('Form Check.');    return false;}

    with the following form parameters:

         <form name='AmendForm' action='FT_AmendUpdate.php' method='POST' onsubmit='return formcheck(AmendForm)'>

    Whether I use return true or return false, the submit displays the "Form Check" message and then opens 

    the next program/file: FT_AmendUpdate.php

  10. OK.  It looks like I'm using the wrong tag to get my box and write-up in the box.

    It seems I should be using Table tag which I've now tried. 

    However, the width or  max-width is not working.  I show 50% but the box takes up the width of me widest line of text.

  11. My css  definition is:

    p.six {width: 50%;  height: 250px; margin-top: 30px; margin-left: auto; margin-right: auto; margin-bottom: 0px; 
        border-style: solid; border width: 2px; border-color: blue; align: center; text-align: center; 
        padding: 30px; background-color:white}

    Whatever I do with the "height" specification or even remove it completely, the height of my box remains the same at the original 250px.

    Actually, just noticed that a few other things don't work - like the width and background-color.  I change these and nothing happens; it retains the original specs.

     

     

  12. The POST is done upon Submit because, in the called program, I print "filenm" and the path & name are there and correct.

    However, In the upload program, my first statement is    '$target_dir = "C:/uploads/"; '   but the file doesn't get uploaded in this, I presume, temporary directory.

    Enough for tonight.  Happy New Year  and  talk to you next year.

    Thanks

  13. So what you are telling me is that  'fileToUpload'  should be  'filenm'  (which is the name attribute I used in the request to upload).

    I have tried that.  I've tried it pure, I've tried it with single quotes, I've tried it with double quotes and I always get the same error message.

  14. My code in request to upload is  <input type='file' name='filenm' size='80'>

    My code in the upload program is  $filenm=$_POST['filenm'];

    and this does give me the correct path & file name in my upload program.

    However I have no idea what is this  "fileToUpload"  in the W3S statement   $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);

    and this  "fileToUpload"  is what is giving the error.

    If I replace  "fileToUpload"  with  "$filenm" , i.e., $target_file = $target_dir . basename($_FILES["$filenm"]["name"]);  I get error:

    Notice: Undefined index: C:\Users\Michael\Downloads\Pinocchio.jpg in C:\xampp\htdocs\Family Tree\FT_UploadFile.php on line 35

     

  15. $query = "DELETE * FROM names WHERE `Ref` = '$ref' ";

    `Ref` is field 0 in my Database and I have an item whose `Ref` is "0001"

    and my $ref = "0001".

    But my item is not getting deleted.

    The  $AffectedRows = -1

    There are no error messages.

    What is wrong with my $query statement?

    Tks

  16. I want to do an image file upload.  I copied the code from W3S but get errors:

    1-  Notice: Undefined index: fileToUpload in C:\xampp\htdocs\Family Tree\FT_UploadFile.php on line 35

    2-  Notice: Undefined index: fileToUpload in C:\xampp\htdocs\Family Tree\FT_UploadFile.php on line 55

                      (Strangely, I don't get the same error on lines 40, 55, 70 and 71 even if there is reference to "fileToUpload")

    3-  Sorry, only JPG, JPEG, PNG & GIF files are allowed.Sorry, your file was not uploaded.

    The file I'm trying to upload is definitely a "jpg" file as shown when I print the file name that was POSTed for uploading, i.e.,  C:\Users\Michael\Documents\PHOTOS\EASTER.jpg .  Perhaps this is only due to the previous problem.

     

    The code in question is:

    $target_dir = "C:/xampp/htdocs/acconts/";
    $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);   <---------- line 35
    $uploadOk = 1;
    $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
    // Check if image file is a actual image or fake image
    if(isset($_POST["submit"])) {
        $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);    <---------- line 40
        if($check !== false) {
            echo "File is an image - " . $check["mime"] . ".";
            $uploadOk = 1;
        } else {
            echo "File is not an image.";
            $uploadOk = 0;
        }
    }
    // Check if file already exists
    if (file_exists($target_file)) {
        echo "Sorry, file \"$target_file\" already exists.";
        $uploadOk = 0;
    }
    // Check file size
    if ($_FILES["fileToUpload"]["size"] > 500000) {  <---------- line 55
        echo "Sorry, your file is too large.";
        $uploadOk = 0;
    }
    // Allow certain file formats
    if($imageFileType != "jpg" && $imageFileType != "JPG" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "JPEG" 
    && $imageFileType != "gif" ) {
        echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
        $uploadOk = 0;
    }
    // Check if $uploadOk is set to 0 by an error
    if ($uploadOk == 0) {
        echo "Sorry, your file was not uploaded.";
    // if everything is ok, try to upload file
    } else {
        if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {     <---------- line 70
            echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";  <---------- line 71
        } else {
            echo "Sorry, there was an error uploading your file.";
        }
    }

    Thank you.

  17. OK.  I got around the problem with the following code.

    $Child = mysql_fetch_row($Results);
                $SavedName[$childcnt] = $Child[1];
                $SavedSex[$childcnt] = $Child[2];}

    print("$SavedName[$childcnt], $SavedSex[$childcnt]<br>");

    (The print actually occurs later on in my code as it has to fit into a form after some other printing).

    Many thanks for your help.

  18. I must put double quotes or printing doesn't work.

    e.g.  Print(ABC<br>)  gives me error:  unexpected <

    I am trying to print the 1st item in the array $Child[$childcnt]

    I am not trying to print $childcnt.   $childcnt is indeed a number.  It is the nth child and it is used to define which $Child array of the many I could have

    and as created by the earlier code:  $Child[$childcnt] = mysql_fetch_row($Results);

    I expect to end up with Array $Child[1] containing an Array of child info

    followed by Array $Child[2] containing an Array of child 2 info, and so on.

    Then I'm trying to print the info from each array.

×
×
  • Create New...