Jump to content

Zane

Administrators
  • Posts

    4,362
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Zane

  1. You are right. It is the fault of the teacher and the ignorance of the average American student.
  2. These seem to be the dumbest arguments since the Obama/Romney campaigns. Either side claims that their way will change the future and that that of the other side will destroy everything as we know it. I have yet to read an intelligent opinion on this case. Furthermore, this argument has came up several times in the past here. If no one can come up with a decent "argument" for the pros and cons of OOP, the thread will eventually and inevitably end up in a flame war at which point it will be locked. Someone put some effort into their arguments, provide some benchmarks, create some graphs, anotate a bibliography. Do anything other than just sling insults back and forth. ---------------------------------------------------------------------------------- Just for the record and to add my input, I have never used OOP in a professional setting, only in the classroom. I must say, OOP does have its advantages. It keeps you from rewriting code, it allows you to use it over and over again, and given the proper nomenclature... Objects serve as a simple way to accomplish something that would normally be rather difficult. What I do not like about OOP is that it advocates copy and pasting. When I was in my C# class, the teacher would give us the code to connect to a database. All of the students heavily relied on Copying and Pasting because throughout the semester we migrated from procedural code in the beginning and converted it into OOP in the end. I will bet you anything though that none of those students actually know how to connect to a database today without looking through their old flash drives. We were taught the use of Objects and that the ConnectionObject allowed us to create a connection to the database. Several other Objects allowed us to retrieve and store that information. We never had to write this code manually though. It was provided for us and 99% of the class, including me, could care less how those Connection and Fetching Objects worked since we had them in our own classes and methods. It wasn't until I started having to debug errors that I realized the fallacy of OOP. If you simply copy and paste a bunch of code snippets you find out in wherever into a method named something like.. findNearestByZip, then when the code within that method fails you have no idea why. You are left with the options of tackling it yourself, googling the error, posting in a forum or searching for a new algorithm altogether because you have no idea what you have copied and pasted.
  3. You're better off doing this through the SQL query SELECT * FROM ips WHERE ip = '$getip'
  4. If you plan to carry variables over multiple pages, your best option is to use SESSIONs which were made specifically for that reason. Read up on Sessions in the PHP Manual, they are very easy to use given you read the instructions. Just a quick hint for your future questions.. You will have to store POST or GET data into these SESSIONS. That is how you will accomplish what you are trying to do.
  5. A much better approach to this would be to use an array instead of having a billion ifs and if elses.. if(trim($name) == '') $error[] = '<div class="errormsg">Please enter your name!'; if(trim($email) == '') $error[] = '<div class="errormsg">Please enter your email address!</div>'; if(!isEmail($email)) $error[] = '<div class="errormsg">You have enter an invalid e-mail address. Please, try again!</div>'; if(trim($subject) == '') $error[] = '<div class="errormsg">Please enter a subject!</div>'; //etcetera etcetera.. Then you can use the implode function in the end to echo them...as well as check for errors. if(count($error) != 0) echo implode("\n", $errors); else { Execute code for success.... }
  6. Do not expect to get very much help from this community by attaching the PHP file. Our community is full of people who are weary to download a file from a complete stranger mainly for security breech reasons. That could easily be an executable whose extension is changed. Especially since you are absolutely new here. Post the code (within code tags please), and rephrase your question to be more clear
  7. Ctrl + F5. Clear your cache.. and it should appear. It might take a few minutes.
  8. That PHP error message most always means that your query is invalid. You should put this at the end of your query statement so we can see the SQL error $query = mysql_query("SELECT * FROM Products WHERE cat='Skate' AND subcat='Footwear' LIMIT $start, $limit_img ") or die(mysql_error());
  9. If reports is a folder that contains an index.php file then the url is fine. All you have to do is check whether $_GET['next'] isset and then code around it. As far as changing a php variable on click, I dont believe that is possible. You would need to store the current month somewhere like in a $_SESSION variable... then use date("M", strotime("+1 month", $_SESSION['curMonth'])) to get the next month
  10. Retrieving the list of images should be one of the first things you do on this page since it is the feature of the page. The create_imagelist function should return $html... not echo it. Echo the return of the function..... dont echo inside the function. Try doing that and see what happens. I'm not positive that will indeed fix it... definitely a shot in the dark.
  11. Read up on how to use DOMDocument http://php.net/manual/en/class.domdocument.php inside that class is a function called, getElementById http://www.php.net/manual/en/domdocument.getelementbyid.php
  12. http://php.net/foreach foreach($laborRates as $currentRow => $theRow) { //Assuming you have a column called rate in your labor_rates table, this would echo all from that column echo "Row Number $currentRow contains this" . $theRow['rate'] . "in the rate field."; } Simple as that..
  13. There is no possible way of doing this with a fetch function. They were created explicitly to fetch the data from the dataset. I suppose you could get away with using a for loop and use mysql_num_rows for your threshold, but that is just ridiculous. My advice to you is to not stray from the fetch approach. Since you say you plan to select different datasets and use them outside the loop, it is probably the best idea to create an array for each of your datasets... for instance $query = "SELECT * FROM labor_rates"; $go[] = mysql_query($query, $connection); $query = "SELECT * FROM ed_scores"; $go[] = mysql_query($query, $connection); $query = "SELECT * FROM someTable"; $go[] = mysql_query($query, $connection); $laborRates = array(); $ed_scores = array(); $someTable = array(); while($row = mysql_fetch_array($go[0])) $laborRates[] = $row; while($row = mysql_fetch_array($go[1])) $ed_scores[] = $row; while($row = mysql_fetch_array($go[2])) $someTable[] = $row; echo "<b>$someTable[3]['name']</b>"; Then you can use a foreach to loop through those .. or you can access your data directly like I demonstrated at the end.
  14. HTML is not security nor is Javascript. They are both client side languages, meaning they can be changed by the user as they see fit. There are plugins out there to do just that, they are also used as debugging tools. An example is Firebug for Firefox. With it, anyone can see where the data is going, which PHP files are being included, they can change the HTML .. in a live fashion, they can execute Javascript commands live as well. Do not fret though and consider Firebug a threat. It is a very very useful tool in web development. Psycho answered your question the best... though he didn't exactly elaborate on it the best, it is indeed the answer to your question Sanitize, filter, escape, sanitize, etcetera. YOU are in complete control of what goes into your database, the same way as you are in complete control of what foods you ingest. The key here is knowledge. If you want to make sure nothing bad gets into your system, you will have to code on the side of your system... known as server-side....AKA PHP. Here are a few PHP functions to start you off.. http://www.php.net/mysql_real_escape_string http://www.php.net/trim http://www.php.net/filter_var IMO, you're pretty safe with just mysql_real_escape_string. It is the only function that actually sanitizes the input for database entry. The other two are simply a way to reject unwanted things... like extra spaces ... or a malformed email address.
  15. They all look compatible to me.. Quite a beefy (albeit expensive) computer though. Wouldn't have hurted to post what each link goes to by the way. The most important link is the motherboard and you have it as the fourth one down. You may want to get a CD/DVD drive as well if you want to put an OS on it. Although I'm sure you omitted it because, well, any kind would be compatible... just pointing it out though.
  16. This link should help you out then http://stackoverflow.com/questions/6237898/storing-time-ranges-in-mysql-and-determine-if-current-time-is-within-time-range
  17. Your PHP comparison will not work because gmdate and date or any other get date/time function will always return a string. In order to actually compare them with >'s or
  18. There's no reason to store whether a restaurant is open or closed when you already have the open and close times in there. Using SQL you can tell whether it is open or close with the TIME() BETWEEN syntax combined with a CASE statement. SELECT `r_ofrom` , `r_oto` , `rid` , CASE WHEN (TIME(NOW()) BETWEEN r_ofrom AND r_oto) THEN true ELSE false END as is_open FROM `restaurant` Then you will not have to do a double query... and the open/close value will be in something like $row['is_open'] Using a ternary statement, in PHP, you can display text or images to show its status... echo $row[´r_name´] . " is " . $row['is_open'] ? "open" : "closed";
  19. Give us an example of how you are doing it now...
  20. So what was the problem. Enlighten those who end up at this thread in a search. Seeing as you never did post the results of the print_r function like I mentioned, we have no clue what was going wrong.
  21. In order to do such a thing with one query you would need an activity table that contained .. The user id, The activity (like post or thread), an id for the post, and id for the thread, and most importantly the datetime of the action.
  22. Try taking out the return breaks in your header \r and see if it works?
  23. Hmm.. try putting this little snippet in and post back here what you get $result = mysql_query("SELECT * FROM tblCookbook where id='$frmID'"); while($row = mysql_fetch_array($result)) { print "<pre>", print_r($row), "</pre>"; ?> Displaying the info for the recipe:
  24. I will bet it has something to do with the fact that your have an open curly brace before your class declaration {class e_online {
  25. Yes, but only if you destroy the session after 15 minutes of inactivity. Otherwise, users would be declared as online/active until they click logout or they close the browser, then you would have to make sure any cookies are destroyed as well therefore they could be assumed online/active for quite some time... depending on the expiry settings you have for your sessions and cookies. Storing it in the database would allow you to create a list of who is online/active. Without the use of a database, you would have to populate some external file on every page load with a list of who is online or offline..
×
×
  • 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.