Jump to content

rick.emmet

Members
  • Posts

    68
  • Joined

  • Last visited

Everything posted by rick.emmet

  1. Hi Everyone, I'm confused; I went to the download page for JQuery and all I got was a script (1175 lines long). This doesn't even have any comments at the top of the script. What is this? It seems far too small to be a library. If it is a library, where does it go and how do I link to it? Any explanation will be most appreciated. Cheers, Rick
  2. Hi Gristoi, Thanks for the reply! I'll start reading a JQuery book and brush up on javascript; since I'll be doing basically the same thing over and over, it should be straight forward to write the code. At this point I only use Dreamweaver as an editor, it's so bizarre, who is the target market for that app? Cheers, Rick
  3. Hi Everyone, I just started working with Javascript, I have taken classes in the past, maybe 5 years ago, but have to implement form validation and a couple of other (minor) things. I have been reading about Spry (Dreamweaver CS4) and have a sneaky suspicion that I will find using this as frustrating as everything else in CS4. The more I use Dreamweaver, the less I like it. I find that it doesn't quite do what I need it to do and I'm going to have to "get under the hood" anyway, so I might as well just learn underling language. In the long run I'll understand more and be able to do the develop work more quickly. I think that I will need to use a framework (as opposed to simple javascript) and would like your comments on what I should study. Is there a clear industry standard? What framework do you prefer? What is the easiest to implement? Also, can you suggest a book on the subject? Any comments would be most appreciated! Cheers, Rick
  4. Hi Kays, Thanks for the reply. To answer your question, I do not have two elements on the page with "id=head1". I have a checkbox with "name=head1" and a form with "id=head1". When I first found this function on the web (with a demo) I thought that the naming convention was going to be a problem or at least confusing. But it was the only way I could get the function to work, so I went with it. And it does work in FireFox and Chrome - just not in IE8. I tried both of your functions and neither of them will work, which seems very odd to me, they look fine. When you apply the "block" or "none" properties to the div, I loose the boarder of the div (which I am using simply to justify the layout) and when I click on the checkbox, nothing happens. I'll try a couple of more things and report back (hopefully with good news). Thanks again, Rick
  5. Hi Adam, Thanks for noticing the caps "ID" - unfortunately the change to lowercase did not help. I'm a bit perplexed by the function's behavior. It works in FireFox and Chrome, but in IE8. In IE8 it's now turning on and off the checkbox itself. I attempted to change the names / id's of the various parts of the function, the checkbox and the form itself - but only way this works at all is to have the checkbox name=head1 and the form id=head1. FireFox and Chrome both act on the form and IE8 acts on the checkbox. I'll keep messing around with this. Thanks again, Rick
  6. Hello again, I went back and tried the function Smoseley suggested and noticed that I didn't even give you guys the total info on the function I'm attempting to use. I'm very sorry for the confusion! Below the checkbox that calls the function... <input type="checkbox" name="head1" unchecked onclick="ShowHide(); " /> ...is the actual form that I want to have hidden until the user clicks on the check box, that code is as follows: <div class="formLayout"> <form method="post" action="biplane_view2.php" name="biplane3" ID="head1" style="visibility:hidden;" > <input type="hidden" name="customer_id" value="<?php echo $_SESSION['customer_id'] ?>" /> <!-- REST OF THE FORM HERE --> As you can see, I'm not using the div name within the function, I'm simply using name of the form itself. The check box that activates the visibility (or display) properties, must remain visible at all times and that is why it is located outside of the form that the function operates on. I tried every variation of Smoseley's function and the best I could do was to get the boarder around the div to collapse and expand. This was true for all browsers. Using display instead of visibility makes sense, I can't get it to work at all though. Any input will be most appreciated! Cheers, Rick
  7. Hi Everyone, Thanks for all the responses! I just got back and will have to tinker with these suggestions - I'll let you know what the results are. BTW, I did not get any errors at all, which is really strange. And of course this works great in every other major browser. I'll post the results soon. Thanks again, Rick
  8. Hello everyone, I have a function on one of my PHP pages that allows the user to see a hidden form (they have to click on a check box). The code works fine in FireFox and Chrome, but fails in IE 8 (the earliest version of IE I'll support). I'm testing this on a development system with XP Pro and it may be an XP problem – but since XP is still has 25% of the share, I have to make sure what ever function I use will work in that environment. Here's the code: function ShowHide() { var head1 = document.getElementById("head1"); var showform = document.form1.head1.checked; head1.style.visibility=(showform) ? "visible" : "hidden"; } <!-- Farther down the page --> <input type="checkbox" name="head1" unchecked onclick="ShowHide(); " /> Does anyone know a work around for this problem? Any help is very much appreciated! Cheers, Rick
  9. Hi GingerRobot, Thank you for getting back to me! That was a dumb problem, I didn't even think to look for that as a solution. It worked great! Cheers, Rick
  10. Hi Everyone, I have an interface that users will view to see data that they are uploading to a site. I'm using echo statements to dump the form data (as $_SESSION variables) on the page, which works just fine in the “static” portion of the page. I want to allow the users to edit the data and so have a hidden form at the bottom of the page, where they can edit the form data. Again, I'm using echo statements to in the form - value=“<?php echo $_SESSION['variable'] ?>” - to dump the values the user input. This works with every type of input except with a <textarea> field (its just blank). If I view the page source, I can see all the text that was entered in the text box (and passed as a session variable to the page, but it will not display. Here's a simplified version of the code (for the form): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Form Page</title> </head> <body> <form method="post" action="test_formView.php" name="form1" ID="form1" > <label>Bake style</label> <select name="Bstyle" id="Bstyle"> <option>Broil</option> <option>High Temp</option> <option>Medium Temp</option> <option>Low Temp</option> <option>Warm</option> </select><br /> <label>Oven</label> <input name="Oven" type="text" size="50" maxlength="80" /><br /> <label>Baking <br> Description</label> <textarea name="description" cols="45" rows="5" id="description" ></textarea><br /> <label></label><input type="submit" name="userfile" value="Submit Info" /> </form> </body> And here is a simplified version of the php code that processes the form: <?php // code here for header, ect. // code to filter form data // storing POST variables in the session variable array $_SESSION['Bstyle'] = $_POST['Bstyle']; $_SESSION['Oven'] = $_POST['Oven']; $_SESSION['description'] = $_POST['description']; // Show the user what the contents of the ad uploaded ?> <form method="post" action="test_formView.php" name="form1" ID="form1" > <label>Bake style</label> <select name="Bstyle" id="Bstyle"> <option><?php echo $_SESSION['Bstyle'] ?></option> <option>Broil</option> <option>High Temp</option> <option>Medium Temp</option> <option>Low Temp</option> <option>Warm</option> </select><br /> <label>Oven</label> <input name="Oven" type="text" size="50" maxlength="80" value="<?php echo $_SESSION['Oven'] ?>" /><br /> <label>Baking <br> Description</label> <textarea name="description" cols="45" rows="5" id="description" value="<?php echo $_SESSION['description'] ?>" ></textarea><br /> <label></label><input type="submit" name="userfile" value="Re-submit Info" /> </form> <?php // code here for footer ?> When I submit the form, the processing page displays the form again (this is slightly different than the original way i'm doing this) with the data dynamically placed in the form. This allows the user to edit the form. All the data is displayed except the textarea data, that text box remains empty (although the data can be seen in the page source code). Can anyone explain why this is happening and how to fix it? I'd like to know! I appreciate your time. Cheers, Rick
  11. Hi Scootstah, Thanks for replying. I tried that too and get the same result, nothing but the message I wrote into the code is printed on the page. It seems so simple, I wonder how this could even be occurring. I'll keep working on it. Cheers, Rick
  12. Hi jcbones, Thanks for getting back to me! Yes I have tried to use that - 'echo "Error message is".mysqli_stmt_error(stmt);' and nothing but the text I wrote prints out on the page. I believe that the only thing coming back from mysqli_stmt_fetch($stmt) is a boolean for false. Cheers, Rick
  13. Hi Everyone, I've been using prepared statements to insert data into my database and they have been working just fine. I wanted to try prepared statements for select queries and began testing with the code provided at the PHP site. There are a couple of examples in the manual - one for mysqli_prepare() and another for mysqli_stmt_fetch(). The code looks like this: <?php $link = mysqli_connect("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $city = "Amersfoort"; /* create a prepared statement */ if ($stmt = mysqli_prepare($link, "SELECT District FROM City WHERE Name=?")) { /* bind parameters for markers */ mysqli_stmt_bind_param($stmt, "s", $city); /* execute query */ mysqli_stmt_execute($stmt); /* bind result variables */ mysqli_stmt_bind_result($stmt, $district); /* fetch value */ mysqli_stmt_fetch($stmt); printf("%s is in district %s\n", $city, $district); /* close statement */ mysqli_stmt_close($stmt); } /* close connection */ mysqli_close($link); ?> I am testing this code with a database and using SHA1 encryption for passwords. My code is as follows: $username = "somename"; $passwd = "somepass"; // Check if username is unique $stmt = mysqli_prepare($conn, "select verify from users where user_name=? and password=sha1(?)"); mysqli_stmt_bind_param($stmt, "ss", $username, $passwd); mysqli_stmt_execute($stmt); mysqli_stmt_bind_result($stmt, $verify); mysqli_stmt_fetch($stmt); echo "The registration varification is ".$verify."<br />"; // Close the statement mysqli_stmt_close($stmt); // Close the link mysqli_close($conn); The results are not as expected as I get the error message, Warning: mysqli_stmt_fetch() Couldn't fetch mysqli_stmt. I've looked up the error and I haven't found anything on the web that explains what's causing it. I can echo the value of $verify, which I'll need farther down the script, but mysqli_stmt_fetch is returning "false", and I need a return of "true" as a conditional to test the state of a users account (in this case the state of the account should return "true"). I have used the hash version of the password and that yields the same result. Could someone please clue me in? I have no idea what the issue is. Thanks much for your time! cheers, Rick
  14. Hi Everyone, This issue is solved. I inadvertently put escapeshellcmd() in the wrong place and it was producing the carets. Moving it back to it's proper place allows preg_replace() to clean that up. Thanks again for the input. Cheers, Rick
  15. Also, I forgot to mention that when I fetch the row and echo the data, the carets are in the output. Cheers, Rick
  16. Hello Laffin and ManiacDan, Thank you for the reply. I have XAMPP 1.7.3 on my development machine (XP Pro) which has PHP version 5.3.1, Apache version 2.2.14 and MySQL version 5.1.41 all slightly behind the latest available. But they are certainly not old systems; the behavior seems pretty odd to me though. This has bothered me for some time, but I had so much development work to do, I didn't take the time to search for an answer until now. I suspect that when I place the code on a production server, the behavior will change. As far as "mysql_real_escape_string" we did cover that in class as well and I should have mentioned it. I guess I'll try to look around some more for the answer (cause it bugs me), but it may become a non-issue when the web app is up on a production server. Thanks again for you time! Cheers, Rick
  17. Hello Everyone, I've been working with XAMPP 1.7.3 and have a general question. I've always read (and been told) to use addslashes() for any MySQL input to protect the database. My PHP.ini file has magic quotes off and the system automatically produces a caret symbol "^" in front of every control character I upload to the database. I can't find anything in the PHP.ini file relating to the caret symbols and control characters, nor can I find anything in the My.ini file. In testing, it the system behaves just as it would if I had magic quotes on, except that the system uses the carets instead of slashes. I have no problem removing the carets (and any slashes that a user might upload) but would like to know what is going on. I've done google searches on this and have only found content regarding regular expressions. Could someone clue me in? Thank in advance. Cheers, Rick
  18. Hi Requinix, Thanks for the quick reply! I just Googled AJAX and AUTO-POPULATE and the first site listed has exactly the functionality I need. It uses AJAX, JQuery and JSON. For anyone that's interested, I ran into an online book on JQuery - JQuery Fundamentals by Rebecca Murphy. It's at: http://jqfundamentals.com/ I just started reading it, so I can't really provide an opinion, but it looks very complete. Thanks again for the help! Cheers, Rick
  19. Hi Everyone, I'm creating a web application in PHP and need to do a little front end development. I need to research a particular type of functionality and don't know what it's called. It's probably Javascript and I have seen it used on a number of sites, however, when I look at the source code for the page I can't figure out what I'm looking at (I see the functions, but can't determine causality). If I can get the name of the functionality, I should have no problem finding tutorials on the subject. What I'm looking for is similar in functionality to context menus with sub-menus. I can't have the submenus though, as the lists I will be using are too long and the users will have a difficult time scrolling through them. Sites such as AutoTrader.com have the type of functionality I'm looking for. If you select an auto “Make” from one pull down menu, the “Model” list in another pull down menu is loaded for that Maker. When the lists are long, this is a more user friendly approach. Can anyone tell me what the general term for this functionality is? Thanks a bunch! Cheers, Rick
  20. Thank you, Thorpe, I tried the following code and got it to work: $photo_num = countPhotos(); if ($photo_num == false) { We didn't cover this in class, which seem very strange (we were trying to cover almost all of "PHP MySQL Web Development"). I'll be using this all the time, so I appreciate the input! Cheers, Ricki
  21. Hi Everyone, I'm testing out some functionality and can't get the results I'm expecting. On a page that will process uploaded data and photos, I call a function from one of my libraries that will count the number of photos uploaded. That function ( countPhotos), first determines if no photos were uploaded, and if that's the case, returns False. The library is an Included file and I've been reading the manual on Return and they say that if the Return comes from an Include file, control is returned to the file that calls the function. This is a bit confusing to me. Here's my script: // THIS IS THE FUNCTION CALLING "countPhotos" // Count the number of files uploaded $photo_num = countPhotos(); if (false) { echo "<div id='mainContent'> <span class='browserTable'> <br /> <p> You did not upload any photos.<br /> <a href='paid_bicycle_form.php'>BACK</a> </p> </span> </div>"; //Display bottom wrapper main_wrpr_bottom(); // display the footer do_html_footer(); exit; } else { // Continue - the count will be used in all the photo processing functions echo "The number of photos is ".$photo_num; } // THIS IS WITHIN AN INCLUDE LIBRARY FILE function countPhotos() { // How many photos have been uploaded? if ($_FILES['userfile']['error'][0] == 4 && $_FILES['userfile']['error'][1] == 4 && $_FILES['userfile']['error'][2] == 4 && $_FILES['userfile']['error'][3] == 4 && $_FILES['userfile']['error'][4] == 4) { return false; } else { $count_photos = 0; foreach($_FILES['userfile']['tmp_name'] as $key => $tmp_name) { if (is_uploaded_file($tmp_name)) { $count_photos++; } } return $count_photos; } } If I select five photos and click on the submit button, I get the failure notice, “You did not upload any photos”. This is exactly the opposite behavior expected. If I click on the submit button without uploading any files at all (no photos), I get a message, “The number of photos is 0". This comes from the portion of the function, that calls countPhotos, below the Else statement; and would only be expected to be output if at least one photo (or file) was uploaded. I guess what is confusing me so much is that if the function doesn't receive the False from countPhotos, why would it execute the portion of the script the outputs the message, “You did not upload any photos”. Does anybody know what I'm doing wrong here? I very much appreciate your input! Cheers, Rick
  22. OK, I see it now! Man, sometimes I can't find simple things like that. Kind of drives me crazy! Thanks much, Rick
  23. Hello Pikachu2000, Thanks for replying! I don't know what line you are referring to, is it the line before the beginning of the function? cheers, Rick
  24. Hello Everyone, I've been taking code snippets and functions from sites such as this and rewriting them for use on a project. I've been able to take these functions and iterate through a series of uploaded files to do various types of processing on them. I found a resizing function for uploaded images and have modified it only slightly – and it works great on a single file. I will allow users to upload multiple images, and I need to loop through the files and resize each one in turn. I've used While Loops for other functions and they have worked fine, but on this particular function I get a parse error, unexpected “}” (see the note in the code). I suspect that the While Loop is throwing every thing off, but I don't know of any other approach (and what I've tested so far hasn't worked). Here's the code: function resize_rename_img() { //list the width and height and maintain the photo ratio. $num = 0; while ($num < 5) { list($width, $height) = getimagesize('./uploads/'.$_FILES['userfile']['name'][$num]); //calculate the image ratio $imgratio=$width/$height; // determine the orientation of the photo if ($width > $height) { // LANDSCAPE ORIENTATION if ($width > 600) { $newWidth = 600; $newHight = $newWidth/$imgratio; //function for resize image. $resized_img = imagecreatetruecolor($newWidth,$newHight); // Identify the source photo $source = imagecreatefromjpeg('./uploads/'.$_FILES['userfile']['name'][$num]); //the resizing is going on here! imagecopyresized($resized_img, $source, 0, 0, 0, 0, $newWidth, $newHight, $width, $height); // NEED TO SAVE AND RENAME THE PHOTO ImageJpeg ($resized_img,'./uploads/'.$_FILES['userfile']['name'][$num]); // DISTROY THE TEMP IMG FILE ImageDestroy ($resized_img); } else { // Change the name of each photo rename ('./uploads/'.$_FILES['userfile']['name'][$num], './uploads/'.$_FILES['userfile']['name'][$num]); } } elseif ($height > $width) { // PORTRATE ORIENTATION if ($height > 600) { $newHight = 600; $newWidth = $newHight*$imgratio; //function for resize image. $resized_img = imagecreatetruecolor($newWidth,$newHight); // Identify the source photo $source = imagecreatefromjpeg('./uploads/'.$_FILES['userfile']['name'][$num]); //the resizing is going on here! imagecopyresized($resized_img, $source, 0, 0, 0, 0, $newWidth, $newHight, $width, $height); // NEED TO SAVE AND RENAME THE PHOTO ImageJpeg ($resized_img,'./uploads/'.$_FILES['userfile']['name'][$num]); // DISTROY THE TEMP IMG FILE ImageDestroy ($resized_img); } else { // Change the name of each photo rename ('./uploads/'.$_FILES['userfile']['name'][$num], './uploads/'.$_FILES['userfile']['name'][$num]); } } $num++ } // HERE'S WHERE THE PHP ENGINE SAYS I HAVE AN ERROR } Does anyone have a suggestion as to changing this and getting it running? Thanks much for your time! Cheers, Rick
  25. Hi Everyone, I've been studying the topics at this site and others on ways to count uploaded images; and what I've tried hasn't worked. I have seen this question posed and answered many times and most of the answers are something akin to this: $count = count($_FILES['userfile'] ['name']); echo "the number of photos is ".$count; The explanation usually states that "count($_FILES['userfile'])" will simply count the number of elements in the array and return 5. But including ['name'] will return the number of files (images) uploaded. I will allow up to five photos to be uploaded (less is OK too) and want to count them in order to iterate through the proper number of loops to filter and process the photos. I've tested both of the above and get 5 (elements) when I count the ['userfile']; but get 0 (zero) when I test "['userfile'] ['name']". Here's the html code: <!-- html here to input form data --> <label></label><input type="hidden" name="MAX_FILE_SIZE" value="500000000" /><br /> <label for="userfile">Upload photo 1</label> <input type="file" name="userfile1" id="userfile1" /><br /> <label for="userfile">Upload photo 2</label> <input type="file" name="userfile2" id="userfile2" /><br /> <label for="userfile">Upload photo 3</label> <input type="file" name="userfile3" id="userfile3" /><br /> <label for="userfile">Upload photo 4</label> <input type="file" name="userfile4" id="userfile4" /><br /> <label for="userfile">Upload photo 5</label> <input type="file" name="userfile5" id="userfile5" /><br /><br /> <label></label><input type="submit" name="userfile" value="Send Ad" /> </form> I've been testing the uploads with two files (jpg) and have tried to come up with an alternative that can iterate through the file arrays and determine how many photos I have. The code I've been testing is as follows: $num = 1; $count = 0; while ($num <=5) { foreach ($_FILES['userfile'.$num] as $upload){ if ($upload ['error'] != 4){ } $count ++; } $num++; } echo "the number of photos is ".$count; I'm using "['error'] !=4" because some times people won't have 5 photos to upload. The result I get is 25 or 5 (files) x 5 (elements) for a total of 25. Does anyone know the proper way of doing this? Thanks for you input! Cheers, Rick
×
×
  • 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.