Jump to content
Larry Ullman's Book Forums

margaux

Members
  • Posts

    453
  • Joined

  • Last visited

  • Days Won

    52

Everything posted by margaux

  1. margaux

    My Project Diary

    I feel the same way you do Edward. When I first started learning, I didn't understand patterns, now I understand the need for them. I also really grappled with oop. It may slow down the project initially, but will speed up other aspects and also any new ones you start. Are you using tdd? I've found that really helps but I do still struggle with writing them, particularly controller tests. Its great that you've stuck with it your project.
  2. Hi Larry I read with interest in your recent newsletter your plans to publish a new edition of your Javascript book. Having grappled with js for a few years and seen it change hugely, I'm looking forward to the new edition and was very pleased to read that you will be doing more with the advanced material. The language has evolved so quickly that it is hard to keep up and never having spent enough time learning it, I always have to start back at the beginning. Having read many of your books, I thought I'd give some feedback. Your books were one of the first resources I used and one of the few that I stayed with when I started teaching myself web development 4-5 years ago. I regularly recommend them to others. What I like about them is the real world examples with proper code samples and a full explanation of the concepts behind the techniques. I find that I'm able to apply what you've covered to my own projects and I haven't always found that with other resources I've used. I"m hoping that your new edition will enable me to get to grips with prototypes and closure. Would you be able to include a few examples to practice these concepts? What about including a few examples of using AJAX to work with APIs? I'm also hoping that I'll be able to get more involved in your forums again; having only used ruby and rails for the past year and a half, my php has become very rusty. Hope the feedback is useful.
  3. Hi Larry Thanks for your reply (and apologies for the delayed response). Its interesting to learn that Yii is influenced by Rails, I think I could probably pick it up having somewhat gotten to grips with Rails. Kind regards, margaux
  4. Hi I know these forums are primarily for php users but I'm wondering if any of you also use Rails. After spending the best part of a year working in Ruby and Rails, I've been asked to revisit a php site I built a couple of years ago and add paypal or stripe payments functionality to it. How similar is Yii to Rails?
  5. Try removing the quotes around $id in your INSERT statement, presumably that column is of type integer?
  6. Can you recommend the best way to send a request to the github api? I dont need to use authorisation for the data I'm after. Would it be better to use sockets or Http_Request? And could you suggest some resources - my php is rusty
  7. Hi, You could set up an array of allowed file types and check if the file extension is in that array. See this thread.
  8. Can you show the full name of the file you're trying to upload? Also just to be clear, have you included 'application/DWG' in the $allowed array?
  9. lastIndexOf method returns the position of the LAST occurrence of the string that you specify with the argument. In this example, there are 2 a's so the method returns the position of the last one, just before the 'n'. The method works by starting its search at the end of the string for efficiency purposes, but the index that is returned is counted from the beginning of the string (starting from 0). Hope that helps.
  10. Is there anything in the pop up window? Any text or error message? Try looking at the source code to see if that helps.
  11. Try doing a var_dump on the variable before you call the spam_scrubber function on it. You will probably see that it is an array. Check how you've coded the checkbox in the form - is it set up as an array?
  12. If I recall correctly, HTML_QuickForm2 is a class from the pear framework so you need to download any feature you want to use. Then you have to require it in the scripts that use that class. I never completely understood how require('HTML/QuickForm2.php'); made it possible for me to use it but I think its because php through php.ini has a list of directories it searches through for files/classes. By installing it you tell php where to find it. I think I followed the steps on the pear site. Sorry I can't be more definite, it was awhile ago.
  13. margaux

    My Project Diary

    The php manual tends to be my first go to when I need help with a function but I completely agree with the comments that it is difficult to make sense of. I mainly use it to confirm that I am using the correct parameters in the correct order and am expecting the correct return value. If I need more help, I look at the examples which I learn alot from and check out SO and a couple of other forums. I don't think I've ever posted on SO but the first time I posted on another forum, the response was pretty harsh, totally not helpful and the responders clearly hadnt even read the question. That experience totally put me off forums in general for awhile but they are good places to learn and get help so I've persevered. This one and thewebdesignforum.co.uk are helpful. So is css-tricks but the php forum is heavily wp biased. Edward - I've really enjoyed your project diary and have learned alot from it, though I haven't been able to keep up with all of it. You're so right in that there are so many things to learn. I'm currently learning ruby with a view to learning ruby on rails as there is a lot of demand for those skills. If you do get the time occasionally do provide an update, I'm sure many will be interested to see the final product.
  14. You can search for QuickForm2 In Finder and it will show you the folder it is in. It should be in Applications/MAMP/bin/php/php5.3.6/lib/php/HTML
  15. I'm not sure why my post didn't display? Try using just hassaan.bizsofttech.com/websol/ex2/ as the BASE_URL definition. If you can sign into your cpanel, you should see the file path to your root directory - its often displayed on the left side under Home Directory.
  16. @ianhg, that's great that you got it to work. Whilst there is nothing wrong with your code, I hope you don't mind if I make a couple of suggestions. As is, it won't be easy to maintain so you might want to consider making it more modulable (probably not a word but I'm sure you know what I mean). You could put your functions in a separate file, say functions.php and include that file. To check for allowed file types - put all the allowed file types into an array, then use the function in_array() to see if the file type is in the array. If you need to allow or disallow a filetype, just add/remove it from the array. Here's a function I created function file_allowed($filetype) { $filesAllowed = array('image/png','image/jpg','image/jpeg','image/pjpeg','application/x-rar-compressed','application/zip','application/pdf'); if (in_array($filetype, $filesAllowed)) { return true; } else { return false; } } Then when you loop through $_FILES, you could replace all that awkward code with $count = count($_FILES['ssFile']['size']) for ($i=0; $i<$count; $i++) { if (file_allowed(strstr($_FILES['ssFile']['type'][$i]))) { $fileAllow="true"; } else { $fileAllow="false"; } } Note - I created a count variable so you only count through the $_FILES array once, not every time you run through the loop. For big loops this will help with performance. I'm not sure $_FILES{'type'] is the best way to access the file type as it is supplied by the browser and can be manipulated. You might want to parse the file name instead. Hope this helps.
  17. Your script can't find the mysql.inc.php file which is why you're getting the other errors. You need to specify in your include statement the full path to mysql_inc.php using relative or absolute paths. You might want to consider defining a BASE_URL and BASE_URI which is explained in this book. Also you may need to alter the permissions on your files - I think on windows you do so in the Properties/Security tab, but I'm not really familiar with windows.
  18. Can we see more of your code? If you are performing var_dump() outside the loop then it will only hold the value of the last loop through.
  19. The colour wont necessarily have changed when you closed the php tag. If the editor comes with code folding functionality, that can be a useful though subtle indicator to the cause of the error.
  20. You don't need the quotes around post_date in your order by clause ORDER BY post_date ASC" I've had problems before with ordering by a timestamp field where the order is by the month, so you may need to do some date manipulation. Let me know if its not working and I'll see if I can dig up an example.
  21. I think this line is causing your error ?> } // End of submission IF. You've closed the php tag before closing the else clause. It needs to be the other way round. } // End of submission IF. ?> Once you've been doing this for awhile, you spot these errors straight away. Also, you might want to consider using a good text editor which provides colour coding and these sorts of errors will be easier to find, particularly if you have long scripts. TextWrangler is pretty good and is free. Please use code tags when you post code, it makes the post easier to read. Its the <> button on the editing bar. Hope this helps.
  22. You will want to apply stripslashes() before running the data through mysqli_real_escape_string. $message = mysqli_real_escape_string($dbc, stripslashes(strip_tags(trim($_POST['message']))) ) ; Your query currently is inserting the message directly from the global $_POST, I think you want to change your query to $q = "INSERT INTO forum(uname, subject, message, post_date) VALUES ('{$_SESSION['uname']}', '{$_POST['subject']}','$message',NOW() )"; If the apostrophes are still being escaped, check whether magic quotes is enabled.
  23. That's great that you got it working. HartleySan is right, you need the db connection object as the first parameter for mysqli_real_escape_string. Sorry I forgot that in my earlier post I'm pretty certain this should work $country_id = mysqli_real_escape_string($dbc, $coun); $q = "SELECT short_name FROM country WHERE country_id = $country_id"; Assuming country_id is set up as the unique primary index on the table with auto_increment you don't strictly need the LIMIT 1 clause, but its worth putting in so the sql engine stops as soon as it finds a match. Whenever, I'm not sure about the syntax of a function I go to the php manual and look up the function. I struggle with its readability but I do usually find answers and if you scroll down the page, the examples are often very helpful. You probably found this a bit frustrating but you've learned alot in the process. Good luck with the rest of your project.
  24. I think you're not getting a match because you have put the country_id variable between single quotes so mysql treats it as a string. I would be inclined for maintainability to run the variable through mysqli_real_escape_string outside the query. $country_id = mysqli_real_escape_string($coun); $q = "SELECT short_name FROM country WHERE country_id = $country_id";
×
×
  • Create New...