Jump to content

TheFilmGod

Members
  • Posts

    1,941
  • Joined

  • Last visited

    Never

Everything posted by TheFilmGod

  1. I searched the jquery documentation high and low for what exactly "$(function(){" meant and couldn't find it. Thanks for the replies!
  2. What does this mean in jquery? $(function(){ Is the code executed after the dom is loaded or before? I don't want to be blindly coding and then have an error pop up in a few weeks because I'm using the wrong jquery code to begin the pages. Thank you.
  3. I am ripping my hair out because I've been trying to resolve this issue for the past 2 hours now and I have not made an progress. Basically, I have a transaction that inserts a record and updates another table. I commit the transaction. Then, php does some work and issues a SELECT statement. The select statement fails. At first I had to no idea why. Without the transaction it was working fine..? So I'm thinking maybe the transaction is locking the table for too long and causing the query to fail? I don't know. Looking for any advice help or pointers. I'm at the point of throwing my hands up and giving up. It doesn't make any sense.
  4. Ended up just passing the db connection class mysqli_extender { // Pass db connection through constructor function __construct($mysqli) { $this->mysqli = $mysqli; } }
  5. Ever since I started using OOP this past week, I have not been able to go back to the old "procedural" methods. HOwever, I seem to be stuck on creating a mysql connection that I can reuse in all of my classes. After I set up a connection to mysql using the mysqli object, I am unable to use the mysqli in other objects. $mysqli = new mysqli(.....); class new_class { function quickQuery () { $mysqli->query('some query') } } Obviously, this doesn't work, because $mysqli is not defined within that functions scope. One way, is to use global keyword. global $mysqli However, globals "are the root of all evil" and simply go against the idea of encapsulation in OOP. What's a way around this? HOWEVER: 1) I still want to use the mysqli object 2) I don't want to reference the $link of the db each time I instantiate a new class .... Maybe I'm asking too much? And I've google for the past hour or so. Singleton seems interesting but it requires the creation of a new db connection class. I want to use the mysqli object.
  6. You don't have to nest forms to have both forms use the secure post method. You can create two or possibly hundreds of form on a webpage.
  7. I know you're problem has been solved with more efficient code. But if you are wondering, you're original code didn't work because the li tag was set as inline. You have to set it as display: block; if you wish for it to take the width/height declarations you made.
  8. <table width="200" border="0" cellspacing="0" cellpadding="5"> <tr> <th scope="col"> </th> <th scope="col"> </th> <th scope="col"> </th> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table> table tr:hover td { background: gold; } table tr:hover td:first-child { background: white; } No need for classes. No need for ids.
  9. Hey Everyone, I am creating a social networking newsfeed for one of mywebsites. One of the challenges I came upon is the query I would sent tothe database to fetch the newsfeed records for a specific user.Originally I planned on querying the database to output the records from the last five days. However, this isn't ideal because the user may have been inactive for a period of time. Instead of a basic "fetch the records for the past five days" I want to query and select all the records that occurred in the "last five days that the user was active." This means, mysql should output all the records for each of the 5 last days the user interacted on my website. At first you may say, that sounds like simple solution: use DISTINCT or use LIMIT but that's not the case. For each of the 5 days, a user may have a number of records. For example, he or she may have posted on someone else's profile AND accepted a friend request from another user. That's two actions that would be saved under the same day. So a simple distinct would not output all the records for each day. Here's the table: newsfeed_id | user_id | datetime | all the other awesome stuff... primary index > newsfeed_id index > user_id, datetime (covering index) Example dataset (march 12, 2010) = shown for easier viewing; actually saved in mysql as timestamp 1 1 (March 11, 2010) Data 2 1 (March 12, 2010) Data 3 1 (March 12, 2010) Data 4 1 (March 14, 2010) Data 5 1 (March 14, 2010) Data 6 1 (March 15, 2010) Data 7 1 (March 15, 2010) Data 8 1 (March 17, 2010) Data 9 1 (March 17, 2010) Data 10 1 (March 22, 2010) Data Assume today is April 13, 2010. The user has been inactive since March 22, 2010. Therefore querying mysql to show all the records that occurred in the last five days (April 9-13) would be unwise. You would get no results. How would I query the table to get all the records of the last five days the user was active on the website? From the example table, the select query should select all but the first record. 5 most recent days plus multiple records that may have been saved under a specific date.
  10. Until recently I thought timezones were simply genius. But recently I have realized that they make everything far more complicated than they should be when developing a web application. The basic consensus is to: Save all date/time information as UTC. Output the date/time information according to the user's timezone preference with a bit of help from php's awesome datetime class. This sums up everything in a two sentences - HOWEVER there is more than meets the eye. I'm working on a web application that will enable schools to create events and announcements on their "network" pages. Now you may want to jump to the gun and say store everything in MYSQL in UTC. But that may not be ideal. Would it make sense if a person across the world came to the school webpage and saw that the dance was happening april 10th at 2:30 am? No it wouldn't. Shouldn't the school's events and announcements be saved in the school's local time? Does that make sense? Students profile pages should on the other hand be stored in UTC. It would make interactions student to student difficult if the times would be localized. Does my rational make sense? Or should I store EVERYTHING in UTC? Last question (I promise) - should I entirely drop datetime as the preferred field type in mysql and go with timestamp. I can't imagine how much harder it would be query the database according to local settings by the datetime field.
  11. Can you elaborate on how I can pass it to the constructor? The validation class needs access to the database to check if the email address is in the "blacklist" - if the email address has been unsubscribed permanently. I wouldn't want users to contact me through the online contact form and use an email that is "blacklisted" on my website's unsubscribed list, because in principle, I shouldn't be sending them emails EVER... unless they resubscribe of course.
  12. // EMAIL class validateEmail { // Grab mysqli class into scope global $mysqli; ... validate email ... check if email already exists in database .... How can I access the $mysqli class within the validateEmail class? is there a way of doing this? I don't want to have to connect to the database again.
  13. I'm creating an online application. A users who registered will have an email sent to them for account activation. Until they click on the provided link, they aren't "officially" in the database. I would like to provide the "unsubscribe" link in ALL of my emails, even those in which a user is not "officially" saved in my database. How would I go around providing users the ability to unsubscribe from my emails? Should I create a blacklist of unsubscribed emails as a table in mysql? And everytime I want to send an email, I would check against the database to see if that user's email is in the blacklist, and if it is, do not send the email. Does this seem like a logical way of doing it? How do you guys manage your "unsubscribed" users?
  14. a quick zap with seo xray and I see that you have no meta description no heading tags and have poor semantics code. For example why are you using span tags within an ordered list. Use <li>! It looks great... but that's not because of you. It's thanks to the desinger who put together the pictures for you.
  15. Thanks for the quick and great post! I do have a follow up question: Is it better to use the timestamp or datetime field type in mysql?
  16. $result = $mysqli->query("SELECT a.announce_id, a.date, u.nick_name, u.last_name, a.published, a.title, a.text FROM announcements_ref_network ref INNER JOIN announcements_details a ON ref.announce_id = a.announce_id AND ref.network_id = '$network['id']' AND ( a.date >= '2010-02-01' ) LEFT JOIN dummy_users u ON a.posted_by_id = u.user_id ORDER BY a.date ASC LIMIT 0, 5"); Problem 1) "...AND ref.network_id = '$network['id']'.." single quotes enclosed in another single quotes. How can I pass an array value into a mysql query without assigning a new variable. Problem 2) How do I make this: "... a.date >= '2010-02-01' ..." instead of reading "2010-02-01" read the current date? Thank you so much!
  17. SELECT * FROM calendar_events WHERE datetime BETWEEN '2010-01-01 00:00:00' AND '2010-01-31 23:59:59' A very very very basic SELECT statement that doesn't seem to work. This is part 1 of a complicated JOIN I am doing. But since this doesn't seem to pull up any records from the database, the complicated JOIN will not work. Thanks for your help!
  18. I am making a calendar application for my website. I have one master "events" table which has all the information for all the events - this part isn't difficult. The hard part is syndicating the appropriate events to each user (everything is customizable). There are three "intermediate" tables which connect users with the events. Joining these tables with the master table (individually) to get the event information isn't difficult. It is however, very difficult to join all of them at once to get a master selection. I want to be able to sort all the events syndicated to a specific user by date from all three intermediate tables. How would I go around doing this? Here is a layout of the databae: Class_events network_id grade event_id EC_events network_id ec_id event_id school_events network_id event_id events event_id all the event information stuff in this table
  19. Can you please elaborate why surrogate keys are advantageous to a natural keys. Surrogate keys hold no value and in my particular scenario, would create significant overhead as I will be using innodb (clustered indexes).
  20. I am currently in the process of finalizing my database. Before I dive head first into the massive programming job that still awaits me, I was hoping someone can help me decide whether using natural keys in my database is appropriate. Using natural keys really depends on the situation. Here is an example: * denotes a field of the primary key ec_comments * network_id * ec_id * comment_id author_id datetime text ... and some other fields ec_comments_reply * network_id * ec_id * comment_id * reply_id author_id text As you can see the primary keys are natural and tell the developer (me) a lot about what I am querying. The concern I have is that to query and find a specific reply to a comment, I need to know the network id, ec_id, comment_id, and reply id. I can't simply know the comment_id and the reply id. Therefore to see a comment the url address would be something like.... www.mywebsite.com/comment.php?network=1&ec_id=3&comment_id=24&reply_id=2 So what do you think? Should I use natural keys or simplify everything and use a surrogate key?
  21. Sanitizing user input is probably one of the most important things a web developer can do. I am currently designing the function/class that will deal with user input. Is using htmlentities() enough? Or is there something else I need to keep in mind? Also, if I use htmlentities() do I still need to use mysql_real_escape_string()? EDIT: Sorry, wrong forum!
  22. If the source code is 100% different, colors and images are entirely different, and the layout is also formatted in a completely different way, can I company file a lawsuit if people say a website is "similar" to another website? I'm making a social networking website and the student profiles look a lot like facebook's profile pages - yet they are signifincatly different. Could I be sued one day because the general layout of things is similar? What if I used the word "wall?" Is that a facebook only trademarked name? Or could I use it and say that as using the word "shopping cart" - a common web term.
  23. Actually, that was VERY good advice. You asked for critque and he gave it to you. Splash pages are a hundred no-no. You have broken the first rule of proper web site design.
×
×
  • 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.