Jump to content

roopurt18

Staff Alumni
  • Posts

    3,746
  • Joined

  • Last visited

    Never

Everything posted by roopurt18

  1. I'm not an authority on mass e-mailing so take my advice with a grain of salt. I think when you BCC someone the e-mail will show up in their address as if it was addressed only to them. You could test this if you had more than one e-mail account.
  2. You don't have to e-mail individually to each one. You could send a single e-mail to the server or a junk address and BCC all of the recipients. That way none of them will know about the others.
  3. Well, you don't have to loop through all of the existing users to find out who to send a notification to. If your database is set up correctly you should be able to run a query that grabs all the affected users and runs quite efficiently. Where this becomes inefficient is when the site is very large and very popular.
  4. You are correct. If there are 10 simultaneous requests from different users, then they will each get their own instance of the singleton. AFAIK, there is no built in mechanism to share data and objects between requests, but I've never looked into it. If you did want to share data between requests, then I'm sure you could. If there isn't a built in mechanism you could develop one of your own via permanent storage like a database. However you'd have to deal with broadcasting changes to the data, which I'm not sure how you'd accomplish that.
  5. The best way to do this is via cron job, which is the *nix equivalent of a Windows Scheduled Task. You also want to limit the amount of e-mails you send out if you are on shared hosting, as they may limit you to x e-mails per hour. Here is what I would do. Create a PHP script that gathers up all of the subscription notifications it is supposed to send. Group these by user so that the user gets 1 e-mail with 10 notifications as opposed to 10 separate e-mails with 1 notification each. This will cut down on the amount of e-mails you actually send. Note that you don't have to do this, but I recommend it. The script should keep track of who has been notified so that it doesn't continuously notify for the same event. Finally, use cron or Windows Scheduler to run this script every 15, 30, or 60 minutes.
  6. Provide your table structure, what you want to display, and which version of MySQL you are using.
  7. These forums are one of the best resources on the internet for learning about web development. If you are actually concerned with learning PHP, then this is the best place to do it. However, you must look at your questions from my perspective: They all dealt with fundamental concepts from PHP development They were all unrelated - i.e. it didn't look like a single one came from a project or piece of code you were actually working on None of them were of the format, "I'm having trouble with my code. This is what I want to do, this is the code I tried, and I'm stuck." Again, it didn't look like they were from code you were actually writing. They were all posted within 20 minutes All of those together would make most people believe you were looking for a handout for a homework assignment, quiz, or test. We are not here to provide anyone with handouts. Our goal is to actually help people learn how to develop web pages. When you get stuck with an actual piece of code you're writing, I encourage you to post about that and see if the response is a bit different. All of that said, I apologize if I am mistaken about the origin of your questions. I also thank you for posting your concerns on this board, rather than recreating the topics or spouting off in a private message. On your end you handled things maturely, so if you're just a little more careful about what you post in the future you should receive a great deal of help here.
  8. We're not here to answer your quiz or homework questions.
  9. Yah the brackets are necessary. Basically the string you're creating is a handy-dandy way of creating objects in Javascript. The square brackets are a short-hand way of creating an array in Javascript. So the net effect of that code is to create an array of objects that Google maps uses to place the push pins on their map. A word of caution. Be sure you understand why I have the lines: $value = str_replace("\\", "\\\\", $value); $value = str_replace("\"", "\\\"", $value); They may or may not be necessary depending on your data. For the sake of argument, let's pretend that one of your name columns was: Dave "The Coder" Linger If you go ahead and just wrap that in double quotes, then your Javascript will look like this: var businesses = [ {name: "Dave "The Coder" Linger", id: 18, You now have a syntax error in your Javascript. But by using str_replace we can replace a double quote in the original string with a \" which will escape the double quote properly by the time Javascript receives it. var businesses = [ {name: "Dave \"The Coder\" Linger", id: 18, Remember that the backslash is also a special character in strings which is why I have the other str_replace, which replaces a single backslash with a backslash-backslash. The order in which you perform the replacement is also import; if you get the order wrong you will wind up with too many backslashes. Again, you may or may not need to do this depending on your data, but it's important to understand what's happening there.
  10. Oh, one other thing. Since you're trying to create JSON you need to wrap your $value in double quotes (and also escape quotes inside). Change: foreach($row as $key => $value){ $rowString .= $key . ': ' . $value . ", "; // method 1 } To: foreach($row as $key => $value){ if(!is_numeric($value)){ $value = str_replace("\\", "\\\\", $value); $value = str_replace("\"", "\\\"", $value); $value = '"' . $value . '"'; } $rowString .= $key . ': ' . $value . ", "; // method 1 }
  11. Ok. This is easily fixed. First off, I accidentally left it as mysql_fetch_array(). Change that call to mysql_fetch_assoc(). As for the extra fields being displayed, change your query to select only those that you want. Also, since the display names have to be exact, you can alias them in the query. Change: $query="SELECT * FROM registry WHERE lat <> '' ORDER BY id ASC"; to: $query = " SELECT `owner` AS `name`, `id`, `location`, `year`, `texid`, `texusername`, `lat`, `lon` AS `lng` FROM registry WHERE lat <> '' ORDER BY id ASC "; Also, I don't see where you're setting $model anywhere so I have no idea which field in your database lines up with model in the text you're building. Finally, since what you're building here is JSON, we don't really need any fancy white spaces. Try this: <?php if (!$link = mysql_connect(x, x, x)) { echo 'Could not connect to mysql'; exit; } if (!mysql_select_db(x, $link)) { echo 'Could not select database'; exit; } $query = " SELECT `owner` AS `name`, `id`, `location`, `year`, `texid`, `texusername`, `lat`, `lon` AS `lng` FROM registry WHERE lat <> '' ORDER BY id ASC "; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $RowStrings = Array(); // each row string will go here, this is method 2 while ($row = mysql_fetch_assoc($result)) { // We want a string formatted like so: // { fld: value[, fld: value] } // each field happens to be named after the array keys in row so we can take // advantage of that fact $rowString = '{'; // we'll build the string for the row in here, this will // be method 1 foreach($row as $key => $value){ $rowString .= $key . ': ' . $value . ", "; // method 1 } $rowString = rtrim($rowString, ", ") . '}'; // method 1 // append $rowString to the $RowStrings array, for method 2 $RowStrings[] = $rowString; // method 2 } echo implode(",\n", $RowStrings); // method 2 ?>
  12. Untested <?php if (!$link = mysql_connect(x, x, x)) { echo 'Could not connect to mysql'; exit; } if (!mysql_select_db(x, $link)) { echo 'Could not select database'; exit; } $query="SELECT * FROM registry WHERE lat <> '' ORDER BY id ASC"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $RowStrings = Array(); // each row string will go here, this is method 2 while ($row = mysql_fetch_array($result)) { // We want a string formatted like so: // { fld: value[, fld: value] } // each field happens to be named after the array keys in row so we can take // advantage of that fact $rowString = '{'; // we'll build the string for the row in here, this will // be method 1 foreach($row as $key => $value){ $rowString .= $key . ': ' . $value . ",\n"; // method 1 if($key == 'lat'){ // Want lat and lng on same line $rowString = rtrim($rowString, "\n") . " "; } } $rowString = rtrim($rowString, ", \n") . '}'; // method 1 // append $rowString to the $RowStrings array, for method 2 $RowStrings[] = $rowString; // method 2 } echo implode(",\n", $RowStrings); // method 2 ?>
  13. mysql_fetch_array returns a numerically indexed array. Change the call to mysql_fetch_assoc to return an associative array, which is what you want. Also, with what you currently have you are repeating the entire string in each conditional body except for that comma. Build the string before the conditional since it is the same no matter what. Then add the comma in the special case. Or use one of the methods I showed you.
  14. C'mon guys this isn't that difficult. Method 1 Append each item to an array and call implode on the array. $array = Array(); for($i = 1; $i <= 10; $i++){ $array[] = $i; } echo implode(', ', $array); Method 2 Append to a string var and use rtrim(). $str = ''; for($i = 1; $i <= 10; $i++){ $str .= $i . ', '; } echo rtrim( $str, ', ' ); // The string is comma space
  15. Not sure. TBH I've never used a full outer join. Perhaps fenway or Barand will pop in and set us straight.
  16. Not from my understanding. Inner joins match all of the records from one table to another and return results only if matches are found. Outer joins match all of the records from one table to another and return all the records from one table matched with the records from the other table. However if a joining record is not found, it is still returned but with NULL values. (The difference is that an inner join would remove it from the result-set entirely). So unless I am mistaken, your WHERE condition will not change it to an OUTER JOIN and you will get many, many more records than you intended, none of which will have NULLs like they should. For example let's say that table `users` has one user with an `id` of 1. There is a `user_profile` table that joins with the `users` table on its `user_id` column. I don't know why this would be the case, but let's pretend that there are 10 records in `user_profile` but only one of them has `user_id` of 1. If you ran something like: SELECT * FROM `user_profile` p, `users` u WHERE p.`user_id`<>u.`id` You would get an inner join where the columns do not match, which would be 9 records. If you ran something like: SELECT * FROM `user_profile` p LEFT JOIN `users` u ON u.`id`=p.`user_id` This is a select from `user_profile` which I've stated has 10 records. So we should have 10 results in our record-set. For any where we can not make a match, we populate the columns from `users` with NULL. So we will get 10 records and one of them will have data from the `users` table. They are not the same (unless I am totally off base).
  17. They will continue to work until you add an OUTER JOIN (and there is no "short" syntax for outer joins). Most of your queries will chug along just fine, it's just a select few that go poo-poo.
  18. I could be mistaken, but AFAIK strings in MySQL begin and end with single quotes while you're using double quotes. In order to make your query search for all titles when one isn't selected, you could make the first item in the drop down look like this: <option value="%">All Titles</option> Which will make your query look like and title like '%' As for OR or AND, it depends on what you want. If you want results that meet all conditions use AND. If you want results that match one or more conditions use OR. If you want something else use parenthesis to group your conditions with AND or OR between groups. And if you want to be slick allow the user to decide.
  19. Caberman is mostly correct, but I must warn you about performing the join by connecting the columns in your WHERE clause. There are actually two syntaxes, one of which is more verbose: SELECT * FROM `table1`, `table2` WHERE `table1`.`some_col`=`table2`.`some_col` vs. SELECT * FROM `table1` INNER JOIN `table2` ON `table1`.`some_col`=`table2`.`some_col` I recommend the second (more verbose) method. First off it is more verbose and declares your intentions more clearly. Secondly, there is an issue in MySQL 5.x where you can't use the first method with OUTER JOINS. This will work in MySQL 4.x but not 5.x SELECT * FROM `table1`, `table2` LEFT JOIN `table3` ON `table1`.`another_col`=`table3`.`another_col` WHERE `table1`.`some_col`=`table2`.`some_col` I ran into this issue on my test server when I upgraded to MySQL 5.0. I noticed a lot of queries that worked perfectly before (and still work on the production server) stopped working altogether. It could be because I use table aliases but either way, it's better to be more verbose (and safer) IMO.
  20. It sounds like the sites are on different domains so the cookie you are trying to create is considered third party. On most IE security settings it will reject third party cookies automatically. To test if this is the case go into your IE -> Tools -> Internet Options -> Security -> Trusted Sites and click the Sites... button. Add the domain of the site that is trying to add the cookie to the list of trusted sites and then see if the cookie is created. If the cookie is created then that is the problem. However you can't get all your users to do this so to get around it you must provide a P3P (Peer Privacy Policy). A little bit of Google hunting and you should find more on what a P3P is and a free tool for creating one. Then you use a call to header() so that the P3P is sent with every page request and you should be good to go.
  21. Doc tags go in comments I would say the problem is not in how you're writing your doc tags but how you are generating them. I don't really have much experience generating doc tags but make sure you are using the program that generates them correctly and setting all of the proper flags. Other than that maybe someone will have something more for you.
  22. The box-thing is an un-representable character. Actually it is a \n but there's a slight difference between operating systems: *nix: \n Windows: \n\r (or \r\n, I forget the order) Mac: \r When you view a text file in one OS created by another OS, if the text editor isn't very smart you will see those squares because of the inconsistency in the representation of a newline. Which OS did you create the file in and which one are you viewing it on? What text editor are you viewing it with? If you started on *nix and are viewing on windows, try opening it in wordpad instead of notepad.
  23. I think this is Portuguese, but I'm not sure.
  24. http://www.youtube.com/watch?v=pWzHbrjOyqM&feature=user
×
×
  • 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.