Jump to content

JakeTheSnake3.0

Members
  • Posts

    137
  • Joined

  • Last visited

Everything posted by JakeTheSnake3.0

  1. I actually am extending the product class through wineproduct, it's just that the product class includes 'productaward' and 'productreview'. Sample code for class.Product.php include('class.ProductReview.php'); class Product { public $reviews; public function AddReview($info) { $this->reviews[] = new ProductReview($info); } } Sample code for class.ProductReview.php class ProductReview { public $info; public function SaveToDB() { // This is where I generate the SQL query. Seeing as how the Product class contains the barcode # I need for it, // I figured I'd use parent::barcode to get it. It doesn't work. // So in my main code, I'd use $wine->reviews[0]->SaveToDB // With the structure I have now, I'd have to pass the barcode as an argument to the SaveToDB function. If there's a way of avoiding having to do that, I'd prefer it. } }
  2. For ease of use, filters are a no-brainer! Regex would be used for complex verification. Filters are just a way of saying "I only want numbers...or I want to verify that the email address is properly formed".
  3. $tmp = explode('-', $string); $string1 = $tmp[0] . '-' . $tmp[1]; $string2 = $tmp[2]; unset($tmp);
  4. I've made several classes which pertain to product information. They are as such: 1) class.Product.php 2) class.WineProduct.php 3) class.ProductReview.php 4) class.ProductAward.php Currently class.WineProduct.php extends class.Product.php; ProductReview and ProductAward are just included in the Product class - this I know is wrong because when I try to run a function from within that class I get the error: Here's a sample of the offending code: $wine = new WineProduct(); $wine->AddAward('Gold'); // This is the bad line: foreach($wine->awards as $awd) $awd->SaveToDB(); The SaveToDB function uses parent::barcode in an SQL query. The barcode is a property of the Product class. I know this has something to do with the include() statements...but what SHOULD I have done?
  5. Looking at the replies on the PHP manual page it might have something to do with your config. I just tested a simple script on my server and it didn't work either.
  6. One thing I noticed...your while (($file = readdir($dir)) !== false) is missing its open and close braces { }
  7. Flush? http://php.net/manual/en/function.flush.php
  8. Perhaps the password you used to originally register is different from what you're using now? On your register.php form echo the $password variable just before you md5 it to verify what's being put into the md5 function.
  9. You NEED to ECHO what you're retrieving from the database! Otherwise how are you supposed to know what's going wrong?
  10. echo your $password and $dbpassword to see what you're getting from both the form input and the database. If they're different, you know something's up.
  11. Try and use another SELECT query wrapped outside of that one which uses DISTINCT on just the id of the product.
  12. Your login.php script isn't md5'ing the password when you compare the values retrieved from the database. You're comparing the actual password with the md5 password stored in the database. In any case, a better way of retrieving a result from the database would be to include the md5'ed password in the query and only return a single result. If no results are returned, the user/pass combo didn't work.
  13. Open the attachment to see what I see. I only see one product (and product image) per line. I still don't know what you mean when you say you want two images before the break. The code I gave you should have been enough to do what you intend (insert a <br /> element every X times). All you needed to do was use a counter variable. [attachment deleted by admin]
  14. Even if you store the timestamps in the database in a different way, you can use PHP's strtotime() function to convert the timestamp into a UNIX timestamp (which is just an integer). The best way to test out things like this is to make a dedicated "test page". For example: My domain is "youbetcha.net". I have a password-protected test directory right beneath it which holds a single .php file called 'index.php'. So to do simple testing, I'd go to "http://youbetcha.net/test/". In the index.php file, I'd just have a vanilla HTML layout with a simple PHP script testing whatever it is I wanted to test. So in this case, you'd put the following in your test file: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" style="width:100%"> <head> <title>File Content-Type Test</title> </head> <body> <?php $datein = 'September 5, 2010'; $dateout = 'September 6, 2010'; $di = strtotime($datein); $do = strtotime($dateout); // Seeing as how UNIX timestamps are just integers, use simple subtraction. // Keeping in mind that they are still integers, $diff will also be an integer. // Seeing as how UNIX timestamps are measured in seconds since Unix Epoch // We need to do some basic math to convert it into hours. Rounding is up // to you. See PHP's documentation on time() @ php.net/time $diff = $do - $di; echo 'Date In: ' . $datein . ' > Unix Timestamp: ' . $di . '<br />'; echo 'Date Out: ' . $dateout . ' > Unix Timestamp: ' . $do . '<br />'; echo 'Time Difference (Hours): ' . ($diff/60)/60; ?> </body> </html>
  15. To be honest, looking at the site I still don't know what you're trying to do. I only see one image (of a car) per item, even after selecting some of the dropdowns. In any case, whenever you are in a loop and you want to do something at every X (where X is a digit), use the modulo. if ($myVar % 2 == 0) // run every other time if ($myVar % 3 == 0) // run every 3rd time $myVar in those instances would be a counter variable
  16. It seems like a lot of overhead and upkeep for all that can go wrong. What you can do is have a global array which holds notices, alerts and errors. For every error encountered, add it to the array in string format right from the code...not a database. So for example: maincode: <?php if (!isset($_POST['name']) $GLOBALS['ERRORS'][] = 'You forgot the name!'; ?> lower down in the script... <?php if (count($GLOBAL['ERRORS']) > 0) { // Display errors } else { // Continue processing } ?> That way you don't need to redirect the user away from the form they were on (which is an annoyance).
  17. So....what you're saying is you want to store the actual image in the database? That is more work than necessary. I assume that's not what you mean and that you really just want to store the file's location in the database...like '/public_html/data/images/myavatar.jpg'. Even if that's the case you'd still need to actually store the image in that folder (which contradicts your assertion that you "JUST" want to store the string in the database). You need to move the uploaded file to a directory which your database string will refer to so that the < img > tag can reference that image.
  18. Where is "Request.php" stored on the server? Here's what happens with your require() line... PHP will search in any of the include_paths for "request.php" as well as the current working directory. So it will search: 1) /usr/lib/php/Request.php 2) /usr/local/lib/php/Request.php 3) /home/stodgy5/php/Request.php 4) /home/stodgy5/public_html/trackstart/Request.php If it doesn't find the file in any of those locations it will fail.
  19. If you can count on the image being a JPEG then you might be able to get away with using regular expressions to extract the URL from the description. Use the $val['link'] variable inside the regular expression search string as the jpeg URL seems to reside in the same directory.
  20. ...and you aren't getting any errors? Do you have error_reporting set to 0 (OFF)? Try var_dump($ch) and do the same for $content. The only thing I can really suggest is to go line by line and verify that the script is doing what you want it to by echoing.
  21. You don't need to use a while loop to subtract something. But given the complex nature of what can possibly go wrong with a time card (human error) you'll most likely be using a lot of IF statements. Building on what Eiolon said and what I'm implying, is that if you only have a time entry with no way to determine whether or not it was an in/out scenario, you could end up with something like this: 1) User 'punches in' at 9:00AM on Friday 2) User forgets to 'punch out' at the end of the day 3) User 'punches in' at 9:00AM on Saturday 4) ...User profits 24 hour work shift!??! If you assume that "every other" time entry is an "out", this is the scenario you get! The time table gets completely screwed up because you didn't account for human error. There's really a lot to this if you don't want to run into problems. However this all can be done in pseudo-code and really doesn't have much specifically to do with PHP.
  22. I meant something along the lines of this website turning a submitted comment with a code block of: <?php echo('This is what I want');$var1 = 'bob'; function testIt($asdf) { ... into this: <?php echo('This is what I want'); $var1 = 'bob'; function testIt($asdf) { ...
  23. Well, what about the spaces between the function names and their respective ( ) braces?
  24. Perhaps the database should just hold time-in and time-out data. The type would be INT which would hold the Unix Timestamp (generated by PHP's call to time()). You would then format the timestamp when needed using PHP's date() function. This way sorting the timestamps is much simpler as they're all just integers. Extracting duration from integers is pretty easy, no?
  25. How about automatic PHP script formatting in [ CODE ] blocks?
×
×
  • 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.