Jump to content
Larry Ullman's Book Forums

chop

Members
  • Posts

    192
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by chop

  1. YESSS.. worked. And, I get it! Somehow I got stuck on $key => $value structure and thought I needed to use the $key within the loop. Way simpler now. chop
  2. Larry- Thank you so much... I'll try it and, if it works, study it for understanding. My biggest php headache is always the intermixing of it with HTML in forms. I worked for hours trying to get it! chop
  3. assuming I create this array: $vegetables=array('corn','squash','beans','carrots','peas','kale'); The following check boxes work fine in my form. <div class="checkbox"> <label><input type="checkbox" name="vegetables[]" value="<?php echo $vegetables[0]?>"> <?php echo $vegetables[0]?></label> <label><input type="checkbox" name="vegetables[]" value="<?php echo $vegetables[1]?>"> <?php echo $vegetables[1]?></label> <label><input type="checkbox" name="vegetables[]" value="<?php echo $vegetables[2]?>"> <?php echo $vegetables[2]?></label> <label><input type="checkbox" name="vegetables[]" value="<?php echo $vegetables[3]?>"> <?php echo $vegetables[3]?></label> <label><input type="checkbox" name="vegetables[]" value="<?php echo $vegetables[4]?>"> <?php echo $vegetables[4]?></label> <label><input type="checkbox" name="vegetables[]" value="<?php echo $vegetables[5]?>"> <?php echo $vegetables[5]?></label> </div> But I've been trying to go one step further so if I add another vegetable to $vegetables[] , I won't have to add another line of code in the check boxes. For example, if I add "spinach", I won't also have to add the line: <label><input type="checkbox" name="vegetables[]" value="<?php echo $vegetables[6]?>"> <?php echo $vegetables[6]?></label> I tried forever by using something along the lines of: foreach ($vegetables as $key =>$value) // mixing html and PHP here to create each of the 6 "<label> </label>" lines of code. } That way, all I have to do is add a vegetable to $vegetables and not change the html I thought I had it at one point but I wasn't able to check more than one of the boxes at a time. thanks for any comments chop
  4. Larry I like the way this forum design works and would like to know how to purchase it. thanks - hope I posted this in the correct place chop
  5. thanks to both- My client, as well, created a gmail account and says that that works but still not his original mail account. Blacklisting of the IP may well be the problem. chop
  6. I have a client complaining that the php mail form I made is not working. He is not able to retrieve any mail from his web page. As a check, I substituted his email address with two of my own. They each worked as they should though he claims they still aren't reaching him. As I see it, the mail is definitely being sent from the web form page. If they are not getting to him, the only thing I can think of is Outlook is filtering them. Is mail sent from using php "mail" different enough from other mail to cause it to look like spam? Or something nefarious? thanks, for helping Chop
  7. Thanks, Larry. I didn't realize it was so involved. I've decided I can live without it. chop
  8. All my php generated emails look like they're 6 pixels high and, man, are they ugly. Can anyone tell me how to add some size, fonts, color etc? Here's a sample of my code: $body = "Name: {$_POST['name']}\n\nEmail: {$_POST['email']}\n\n Telephone: {$_POST['phone']}\n\n Comments: {$_POST['comments']}\n\n Checked Boxes:\n\n {$checks}"; // Make it no longer than 70 characters long: $body = wordwrap($body, 70); $from="Collaboration Age, Website Mail"; mail('chop@myfairpoint.net', 'Contact Form Submission', $body, "From: {$from}"); // A message is printed on the first panel of this website // that the email has been sent // Clear $_POST (so that the form's not sticky): $_POST = array(); thank you
  9. This, I suppose, is as much an HTML question as a js or jQuery question so I'm not sure if this is the proper forum. But, here goes.... I'm trying to use a jQuery image rotater function in my "responsive" html design. My Bootstrap 3 framework let's me display html layout differently depending on the screen size. THE PROBLEM is that I want to use the same jQuery function (which uses the id #fader) to format the page differently according to the screen size. However, referencing the same #id more than once on a page is not allowed. So, I end up making multiple versions of the function "fader" and just change the id name. That results in something that works but uses lots of code. I'm looking for suggestions on how to handle this by using the function only once( I already tried changing "#fader" to ".fader" so to make it a class instead of an id but it did not work (I'm not a great js programmer however). Please refer to this script sample below. Here's the HTML code that accesses the function according to screen size. Here, I have simply made two copies of the function with a different id name for each (fader.txt and fader2.txt): <!--IMAGE FADER for DESKTOP screens--> <div class="visible-lg"> <script src="assets/js/fader.txt"></script> <div style="position:absolute;top:100px; left:650px"> <div id="fader" class="visible-lg"> <img src="images/standInImage.jpg" width="500"> <img src="images/standin2.jpg" width="500"> <img src="images/standin3.jpg" width="500"> <img src="images/standin4.jpg" width="500"> </div> </div> </div> <!--IMAGE FADER for TABLET screens--> <div class="visible-md visible-sm"> <script src="assets/js/fader2.txt"></script> <div style="position:absolute;top:150px; left:450px"> <div id="fader2"> <img src="images/standInImage.jpg" width="350"> <img src="images/standin2.jpg" width="350"> <img src="images/standin3.jpg" width="350"> <img src="images/standin4.jpg" width="350"> </div> </div> </div> Here's the jQuery code itself using "#fader" $(function() { $("#fader img:not(:first)").hide(); $("#fader img").css("position", "absolute"); $("#fader img").css("top", "0px"); $("#fader img").css("left", "50%"); $("#fader img").each(function() { var img = $(this); $("<img>").attr("src", $(this).attr("src")).load(function() { img.css("margin-left", -this.width / 2 + "px"); }); }); var pause = false; function fadeNext() { $("#fader img").first().fadeOut().appendTo($("#fader")); $("#fader img").first().fadeIn(); } function fadePrev() { $("#fader img").first().fadeOut(); $("#fader img").last().prependTo($("#fader")).fadeIn(); } $("#fader, #next").click(function() { fadeNext(); }); $("#prev").click(function() { fadePrev(); }); /* $("#fader, .button").hover(function() { pause = true; },function() { pause = false; });*/ function doRotate() { if(!pause) { fadeNext(); } } var rotate = setInterval(doRotate, 5000); }); I will need a total of 4 layouts for 4 different screen sizes for a single html page. I hope I can do this without having to load 4 copies of the same script but with different id names. Thank you. I hope I have stated this problem clearly.
  10. Update: I state above that $gal3 has no value because nothing printed out when I echoed it. However, I discovered that is actually has a value of false.
  11. Okay, I did a dumb programming maneuver, but I still got it to throw an error from within isset(). Here's what I had: Note: $galleries[2] has a string value and $gal3 has no value. <input type="checkbox" name="<?php echo $galleries[2];?>" <?php if (isset($_POST[$gal3])) echo 'checked = "checked"' ?> /> <?php echo" ". $galleries[2];?><br /><br /> The error was for this particular line number (containing the above the checkbox field) and the culprit variable that was "undefined" is gal3. Even though it is in an isset(). My solution, which I should have had in the beginning, was simply to replace the $_POST[$gal3] with $_POST[$galleries[2]]. So, though everything works now, I'm still a bit curious as to why the error? It can remain a mystery, that will be okay, Thank you for your help.
  12. I haven't been on the forum in quite a while so haven't asked a dumb question which probably catagorizes the following: Within the error management section of the book there is the following code: if (!LIVE ) { // Development (print the error). // Show the error message: echo '<div class="error">' . nl2br($message); // Add the variables and a backtrace: echo '<pre>' . print_r ($e_vars, 1) . "\n"; debug_print_backtrace(); echo '</pre></div>'; etc.... } This will give all errors and notices including undefined variables. I do want the undefined variable notices EXCEPT if they are included in an if (isset ()) conditional, which I don't care about. So, if (!LIVE && ($e_number != E_NOTICE) )} won't work because it won't point out $thisVar if it is not defined. Is there a way to shield the "isset" qualified variables.
  13. Aside from the db and file paths that HartleySan talks about, and testing it yourself as you go, just remember that the ultimate fail-safe is to have a backup of all your files and tables. Not just on your main hard drive but also on an external drive.. After putting in a year of work, I'd immediately get a safe copy offsite somewhere as a fallback. Nothing really bad can happen if you do this. You will then have three copies counting the one on your host. If you're new at developing locally and moving to a host, I suggest that you watch out for the urge to fix small bugs by going directly to the host site (ftp) and doing it. Inevitably, you will forget to reconcile localhost and the two sites will be different which will get you into trouble later on. One of your files is probably the one that contains the information to log into your database (mysql.in.php) or something like this. You might have developed that locally as being on the same level as your other files but is often kept in a safer location a level above the public Html of "root" directory on a host site. That's one path you might have to fix. good luck
  14. Larry - One more teensy detail: You might have forgotten to include: <link href="css/sticky-footer-navbar.css" rel="stylesheet"> inside the css folder, which is empty. thanks
  15. I looked up the sql.sql code (example 1) in the e-commerce 1st edition book and am assuming that it should be the same for 2nd edition. Here is the corrected code that creates the date_modified column: `date_modified` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', So, the download has an error in it. Larry, to let you know: The following link downloads both Example 1 and Example 2 of 2nd edition but with an error in line 50 of Example 1 sql.sql: `date_modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE This link downloads only Example 1 scripts of 1st edition. Example 2 code is missing: http://www.larryullman.com/books/effortless-e-commerce-with-php-and-mysql-2nd-edition/ effortless_ecommerce_2nd.zip (721 KB, last modified 11/17/2013)
  16. Antonio, I tried removing exactly what you said but it's giving me the same error. I could try a few other things and maybe get it to import but I'm not sure what else it might effect!
  17. I successfully downloaded the code for the 2nd edition of this book. But when I tried to import the .sql into MAMP I got the following error: SQL query: CREATE TABLE `users` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , `type` ENUM( 'member', 'admin' ) NOT NULL DEFAULT 'member', `username` VARCHAR( 45 ) NOT NULL , `email` VARCHAR( 80 ) NOT NULL , `pass` VARCHAR( 255 ) NOT NULL , `first_name` VARCHAR( 45 ) NOT NULL , `last_name` VARCHAR( 45 ) NOT NULL , `date_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `date_expires` DATE NOT NULL , `date_modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP , PRIMARY KEY ( `id` ) , UNIQUE INDEX `username_UNIQUE` ( `username` ASC ) , UNIQUE INDEX `email_UNIQUE` ( `email` ASC ) , INDEX `login` ( `email` ASC , `pass` ASC ) ) ENGINE = InnoDB DEFAULT CHARSET = utf8; MySQL said: #1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause The 3 tables that came before this error; categories, pages, pdfs were created correctly. I'm not sure how to fix this.
  18. Thanks, Larry. I think I'll go with the second edition downloads and fool around with them until the new book arrives.. just anxious to get started. Also, glad to hear you've got a new way to attack the PayPal IPN. I still have a migraine from calling PP tech support on that. Also, I've been using Bootstrap for a year now so that's also a plus.
  19. I have the 1st edition of this book. Because I have a similar project to example 1 coming up, I'm thinking about purchasing the 2nd edition. For now, if I want to start setting up my server and db before the new book arrives, can I download the new: Complete Set of Scriptseffortless_ecommerce_2nd.zip (721 KB, last modified 11/17/2013) and use the tables intended for the 2nd edition ( I assume it's for the 2nd edition) with the .php scripts from edition 1(that go along with the book I currently own)? Or have the table names changed? If I start now, using the files from the first edition, will it cause a problem when I start substituting the .php files from the 2nd edition? Actually, I have downloaded the above file but not created any of the tables yet. One thing I noticed is that the download only includes "ex1". Thought this is the one I want, I was wondering about "ex2" being absent from the .zip package. thanks
  20. Sorry. It's not that I couldn't get it to work after taking out the returns in my code. I was just curious because I tend to enter returns in Dreamweaver code view to break lines into a more visually understandable format. I never knew it could cause a problem. I will withdraw the question.
  21. Here's the code to read in a date from a db. The date itself, from the db table, contains no white space: Date Created: <input type="text" name="datecreated" size="12" maxlength="10" value="<?php echo $row['dateCreated'] ?>" /> yyyy-mm-dd<br /> If I go into my code and hit the return button after value=" it looks like this: Date Created: <input type="text" name="datecreated" size="12" maxlength="10" value=" <?php echo $row['dateCreated'] ?>" /> yyyy-mm-dd<br /> In Firefox, this has no effect a-as it should. However Safari will insert a space before the date value in the text field. This is a problem because the value for date within the form will not validate when it hits the space. Even if I insert a trim() in the above line: Date Created: <input type="text" name="datecreated" size="12" maxlength="10" value="<?php echo trim($row['dateCreated']) ?>" /> yyyy-mm-dd<br /> it still inserts a space. I've never considered the arbitrary code formatting practice of hitting a return anywhere I want. Has anyone else run into this?
  22. Here is a section of php code that I am using to read an html file and bring it into tinyMCE (html editor): $handle = fopen('textFiles/'.$category.'.html', "r") or die("Couldn't open this file."); $_POST['editText']= fread($handle, filesize('textFiles/'.$category.'.html')) or die("Couldn't read from this file."); Here is a section of the html file being read : <a class="accordion-toggle" style="margin-left: 50%;" href="#collapseOne" data-toggle="collapse" data-parent="#accordion1">MORE INFO </a></div> Here is what actually gets read into tinyMCE: <a class="accordion-toggle" style="margin-left: 50%;" href="#collapseOne">MORE INFO </a></div> -------------------------------------------- You see that a piece of html code gets eliminated from what is in the original html file: data-toggle="collapse" data-parent="#accordion1" PLEASE NOTE that tinymce editor gets the correct html code on my local server but gets the truncated version when done on the remote server. The php and html files are the same on both servers AND the version of tinyMCE is the same. Also, I have been using tinyMCE for years and never experienced this before. ALSO, it is only that small piece of the entire html code that is left out! Any thoughts?
  23. Okay, we won't go that route. Consider this case closed (now that we're HOT!) Thanks again for your assistance HS
  24. They do certain types of data analysis on the information they collect from members though I'm not sure how critical it is to them really. So it's not just data collection and retrieving. Anyway, I thought I had XYZ convinced that they could (and should perhaps) let go of i-gotcha if they want to continue to expand in the way they are planning. Otherwise the same problems will always come back to haunt them. Plus, the i-gotcha site is quite ugly and not well integrated with XYZ's current site. Anyway, thank you. That was exactly what I was looking for. I knew it could be done but didn't know where to start looking. I will find out more about cURL. Margaux, on the second post said: Is this at all related to cURL? Not critical, just wandering. I appreciate you tolerating me all this time.
×
×
  • Create New...