Jump to content

dadamssg87

Members
  • Posts

    218
  • Joined

  • Last visited

Everything posted by dadamssg87

  1. Products IdUsernamecodepriceiteration 14xyz1.990 24xyz4.991 34xyz2.992 47asgprice0 56ewrprice0 64123price0 SELECT id, username, code, price, iteration FROM Products where iteration = ( SELECT MAX(iteration) FROM table WHERE username = Products.username ) The above code would produce the following? I'm not sure what the "t" represents in your query and also don't see how your query gets the max() iteration of each product code. IdUsernamecodepriceiteration 34xyz2.992 64123price0
  2. sorry, id: bigint (11) username: bigint(11) code: varchar(50) latin1_bin title: varchar(150) description: text iteration: int(11)
  3. I have a table products: id, username, code, price, description, and iteration. The "code" column is an alphanumeric string unique to that product. Instead of having a form to update that row, i was thinking i could add an "iteration" column and create a whole new row with the updated information. This way i could track how the product changes and progresses over time. The "iteration" would be an integer and increase +1 every time that product gets updated. Could someone help me write a query that selects the latest iteration of all products with a certain username? I have no idea how to incorporate the code and iteration together. Any help would be MUCH appreciated.
  4. i use file_get_contents() to grab entire web pages to send as html emails. How can i error check that the url i use in file_get_contents() actually exists. I thought i could put it in an if statement like cURL but that doesn't work. <?php if($email_body = file_get_contents($url)) { $config['mailtype'] = 'html'; $this->email->initialize($config); $this->email->from('support@test.com', 'Testing'); $this->email->to($email); $this->email->subject("Confirm Reply-To Email"); $this->email->message($email_body); $this->email->send(); }
  5. I have a "created" column in my table that uses CURRENT_TIMESTAMP. Can somebody help me write a query that pulls rows that are at least 30 days old? <?php $query = "SELECT * FROM Accounts where DateDiff(day,date(created),curdate()) > 30"; ?> I get this error with the above. #1582 - Incorrect parameter count in the call to native function 'DateDiff'
  6. i'm a newbie when it comes with messing with apache. Excuse my ignorance, but where is the file with the virtual hosts typically found? And can you rewrite it with php?
  7. and if so how? I've read a few articles and the vast majority talk about subdomains and just have you create an index.php file and use an .htaccess file to look at the domain being called and use the index.php file to display information pertaining to that domain. I want to know how to pragmatically add a domain as if you were going through cPanel's Add Domain process. It wouldn't be as simple as just creating a "newdomain.com" directory in public_html , would it?
  8. I know cURL is primarily for fetching data from remote sites. Should you use cURL to get data from local urls that use POST data? For example, i have a page the displays a receipt. i use this to send html emails and also for the customer to view the receipt in their browser if their email client isn't displaying it correctly. If POST cardholder data is present it will display the first name, last name, address, city, state, zip, phone, email, and method of payment in the receipt. I use the file_get_contents() function to retrieve that web page and send the email. The problem: No POST data is present when doing that so if you're the one getting the receipt email, your billing information won't be on it. There's no way to prove that the receipt is actually yours. I'm trying to comply with PCI standards so i'm trying to avoid storing cardholder data in sessions or a database table.
  9. is there a character limit that you need to stay under? Also, are all urls called logged in your server somewhere?
  10. Yeah i think i'm going to change that(storing cardholder data in my db even if it is only for an instance). I think i'll rework it to use POST data in the emails instead of session data. That should be way less risky. Also, LiquidWeb has a PCI compliant hosting solution. Its an extra $50/mo. They take of scanning and maintaining and updating the server. I'd do it myself i just don't know anything about running a server.
  11. I've noticed you can send emails with PHP coming from any email address. So it seems like i could spam a ton of people with email addresses with "donaldtrump@trump.com" or something like that. I understand emails are trackable so i'm sure i would get in trouble if i spammed enough people. I was wondering though if theres any issue with sending emails for your app users? For example, say i come up with a service to design and send emails. My user would customize a template and enter some text and then enter the email address they want to send from and the email addresses they want the email sent to. So pretty much like mailchimp. Would i run into any problems with sending emails "from" email addresses i don't own, technically or legally?
  12. i realize that but if i only order by last name, the first name doesn't get taken into account if there are several names with the same last name
  13. Is there a way in sql to order rows by a last name and then within the blocks of the same last name, by first name? For example, Abe Adams Corey Adams Terry Alberts Christi Baron John Bellamie Zachary Bellamie Travis Mathews Jon Morgan You'll notice Adams and Bellamie both have two people and they then ordered by their first name.
  14. I'm developing an e-commerce website. It's integrated with authorize.net. Once a customer submits their payment information i encrypt(MCRYPT_RIJNDAEL_256) that data(first name, last name, address, city, state, zip code, but NOT the card number or exp date) and store it in a session. My sessions are stored in a database table. I do this so i can repopulate the form if authorize.net encounters an error and also i keep it just long enough to send a receipt email with the customer information on it. Once the submission is successful and the email gets sent the data gets wiped. So it all happens pretty much instantly. With an SSL cert i feel like this shouldn't raise any security concerns. Your thoughts?
  15. awesome. thanks everybody. I used mjdamato's suggestion and its working great. thanks!
  16. I've been using php's strstr() function to find data before an @ character in a string. Work fine for my local ide. I just uploaded all my files to a host to start debugging emails and it came to my attention that my hosting environment is running version 5.2.9 and strstr() isn't fully supported. Heres a bit of code from the manual to show i'm talking about <?php $email = 'name@example.com'; $domain = strstr($email, '@'); echo $domain; // prints @example.com $user = strstr($email, '@', true); // As of PHP 5.3.0 <-- echo $user; // prints name ?> I can't use the third argument apparently. Is there another way to go about doing this?
  17. I don't really think it's legal to use another websites background image but i really like pinterest.com's linen/watercolor image. I've seen this type of image elsewhere. Is there a freeware version of this?
  18. I wrote this bit of code to get the next six datetimes of a certain date. It was working perfectly until this week. <?php $start = "2011-11-06"; $num_days = 6; for ($i = 0; $i <= $num_days; $i += 1) { $stamp = strtotime($start) + ($i * 86400); echo date('l - n/d/Y - h:i a',$stamp)."<br/>"; } ?> The 2011-11-06 is a Sunday so i would expect to get the following: Sunday - 11/06/2011 - 12:00 am Monday - 11/07/2011 - 12:00 am Tuesday - 11/08/2011 - 12:00 am Wednesday - 11/09/2011 - 12:00 am Thursday - 11/10/2011 - 12:00 am Friday - 11/11/2011 - 12:00 am Saturday - 11/12/2011 - 12:00 am instead it is producing: Sunday - 11/06/2011 - 12:00 am Sunday - 11/06/2011 - 11:00 pm Monday - 11/07/2011 - 11:00 pm Tuesday - 11/08/2011 - 11:00 pm Wednesday - 11/09/2011 - 11:00 pm Thursday - 11/10/2011 - 11:00 pm Friday - 11/11/2011 - 11:00 pm How should i go about fixing this so it doesn't happen again?
  19. thanks guys. i was wondering if they was a mysql function for that. IN looks like what i'm looking for. As far as the dates go. I'm feeding a function a check_in and last_night dates and room_ids. I need three select queries to pull rows of bookings to do this. 1. One to pull bookings that have both check_in and last_night within the provided dates. 2. One for when the booking starts before the check_in date and ends after the last_night date. 3. One for when the last_night is before the provided last_night date and ends after the provided last_night date I'm using a UNION for the three queries <?php function get_all_bookings_for_user($first,$last,$username) { $year = substr($first, 0, 4); $month = substr($first, 5, 2); $query = $this->db->query("SELECT * FROM Bookings WHERE DATE(check_in) AND DATE(last_night) BETWEEN '$first' AND '$last' AND username = '$username' AND deleted = '0000-00-00 00:00:00' UNION SELECT * FROM Bookings WHERE MONTH(check_in) = '$month' AND YEAR(check_in) = '$year' AND DATE(last_night) > '$last' AND username = '$username' AND deleted = '0000-00-00 00:00:00' UNION SELECT * FROM Bookings WHERE MONTH(last_night) = '$month' AND YEAR(last_night) = '$year' AND DATE(check_in) < '$first' AND username = '$username' AND deleted = '0000-00-00 00:00:00' UNION SELECT * FROM Bookings WHERE DATE(check_in) < '$first' AND DATE(last_night) > '$last' AND username = '$username' AND deleted = '0000-00-00 00:00:00'"); $bookings = array(); $num = 0; foreach ($query->result() as $row) { $num ++; $bookings[$num] = array( 'id' => $row->id, 'name' => stripslashes($row->name), 'check_in' => $row->check_in, 'last_night' => $row->last_night, 'clean_up' => (int) $row->clean_up, 'room_id' => $row->room, 'first_name' => stripslashes($row->first_name), 'last_name' => stripslashes($row->last_name), ); } return $bookings; } ?> Its probably not the most efficient way of doing it but if anyone has suggestions , i'm all ears.
  20. yes i do. It's in the $sql variable. Deleted is a timestamp
  21. I have this query, but it's not working how i want it. The deleted field holds the timestamp of when the booking was "deleted". Its pulling up bookings that have been deleted and i think it is because i'm misusing the "OR" part in the $sql string. I want to pull bookings between the dates(this part is fine), not deleted, and belong to $rooms that are in the $room_ids array. Anybody know how i can correct this? <?php $sql = ""; foreach($room_ids as $key => $id) { if($key == 0) { $sql .= "room = '$id' "; } else { $sql .= " OR room = '$id'"; } } $query = "SELECT * FROM Bookings WHERE DATE(check_in) AND DATE(last_night) BETWEEN '$first' AND '$last' AND deleted = '0000-00-00 00:00:00' AND $sql";
  22. eh i ended up having to delete the old database and reloading a previous .sql file and working from that. My application was still able to pull data from the 'dropped' table but it wasn't showing up in phpmyadmin and when i tried to create a new table with the same name it said there was already an existing table with that name. Weird.
×
×
  • 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.