Jump to content

djones

Members
  • Posts

    74
  • Joined

  • Last visited

    Never

Everything posted by djones

  1. I'm allowing the user to turn on SSL for the checkout page. I am checking if the file is writable via PHP, if it is I want PHP to add these lines, if it's not I am telling the user they need to add these lines manually.
  2. I need to add these lines to my .htaccess file via PHP RewriteCond %{REQUEST_URI} checkout RewriteRule ^(.*)$ https://myurl.com/checkout/$1 [R,L] RIGHT after this line: RewriteBase / AND before this line: RewriteCond %{REQUEST_FILENAME} !-f This is how the current file looks w/o the new line addition: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ index.php [L,QSA] It needs to look like this when the new lines are added(extra line breaks not necessary): RewriteBase / RewriteCond %{REQUEST_URI} checkout RewriteRule ^(.*)$ https://myurl.com/checkout/$1 [R,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ index.php [L,QSA] The line numbers may not match up, so I cannot use the line number.
  3. Wow, I'm made that real hard for myself. That's it. Thanks.
  4. I forgot the IGNORE in the INSERTs above. They all include that...
  5. In Oracle (*ducks*) I can do this. I was hoping for a way in MySQL. So is this not possible? I can work around this, but this would save me several lines of PHP code.
  6. I'm trying to insert unique data based on 2 fields. The product_id and the value_id combined should be unique. I'm not sure how to do this. I have: ID(primary key) -- not shown below PRODUCT_ID(unique key) VALUE_ID(unique key) VARIATION_ID I need product_id and value_id to be unique together. When I insert this data it only insert one row and I'm assuming it's because It's just looking at each unique fields by itself thus stopping at the next '37' insert. For example 37 and 11 should not insert twice, 37 and 3 ...etc INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '11', '4') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '3', '2') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '10', '4') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '3', '2') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '9', '4') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '5', '2') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '11', '4') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '5', '2') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '10', '4') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '5', '2') INSERT INTO table (product_id, value_id, variation_id) VALUES ('37', '9', '4')
  7. A friend was able to help. I'm posting it here for others to see. // Put each variation set into an array // i.e $set[0] is your Sizes, $set[1] is your Colors /* Sizes array(4) { [0]=> string(2) "SM" [1]=> string(3) "MED" [2]=> string(2) "LG" [3]=> string(3) "XXL" } Colors array(3) { [0]=> string(4) "Blue" [1]=> string(5) "Green" [2]=> string(3) "Red" } */ $options = array(); $current_index_path = array(); $variations = -1; function variation_matrix($variations, $current_index_path, &$options, &$set) { $variations++; if ( $variations == count($set) - 1 ) { //you are at the last group for ( $i = 0; $i < count($set[$variations]); $i++ ) { $option_string = ""; for ( $j = 0; $j < count($current_index_path); $j++) { $option_string .= $set[$j][$current_index_path[$j]]. " : "; } $option_string .= $set[$variations][$i]; $options[] = $option_string; } } else { for ( $i = 0; $i < count($set[$variations]); $i++ ) { $cip_copy = $current_index_path; $cip_copy[] = $i; //append index from this variation variation_matrix($variations, $cip_copy, &$options, &$set); //dig deeper } } } variation_matrix($variations, $current_index_path, &$options, &$set); /* Output array(12) { [0]=> string(9) "SM : Blue" [1]=> string(10) "SM : Green" [2]=> string( "SM : Red" [3]=> string(10) "MED : Blue" [4]=> string(11) "MED : Green" [5]=> string(9) "MED : Red" [6]=> string(9) "LG : Blue" [7]=> string(10) "LG : Green" [8]=> string( "LG : Red" [9]=> string(10) "XXL : Blue" [10]=> string(11) "XXL : Green" [11]=> string(9) "XXL : Red" } */
  8. I'm struggling with how to dynamically loop through a product's list of options. Let's day I have the variations, Size(variation_id = 2) and Color(variation_id = 4) assigned to product A. Which produces these arrays: // Sizes array(4) { [0]=> string(2) "SM" [1]=> string(3) "MED" [2]=> string(2) "LG" [3]=> string(3) "XXL" } // Colors array(3) { [0]=> string(4) "Blue" [1]=> string(5) "Green" [2]=> string(3) "Red" } I know I can hard code the loop, but that will not work if I add another variation. How can I build the loop to work with any amount of variations? // Get the variations from the product_id A // $sql = "SELECT variation_id FROM product_variations WHERE product_id = 'A' / ... // I can query for the variations and loop through to get the variation values // ... // $set1 is the Sizes array from mysql query // $set2 is the Colors array from mysql query $count1 = count($set1); $count2 = count($set2); for ($a=0; $a < $count1; $a++){ for ($b=0; $b < $count2; $b++){ $options = $set1[$a].' : '.$set2[$b]; echo $options.'<br />'; } } // Output /* SM : Blue SM : Green SM : Red MED : Blue MED : Green MED : Red LG : Blue LG : Green LG : Red XXL : Blue XXL : Green XXL : Red */
  9. Cannot get my brain around what strtotime it looking for. I need to echo the same day for each month for the next 12 months. This is not working. for($i=0; $i<=12; $i++){ $date = date("Y-m-d", strtotime('17 +'.$i.' months')); echo $date.'<br />'; }
  10. I've read that article before and cannot find a way to create a dynamic menu from it. This part of the article where it shows the concat()... SELECT CONCAT( REPEAT( ' ', (COUNT(parent.name) - 1) ), node.name) AS name FROM nested_category AS node, nested_category AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt GROUP BY node.name ORDER BY node.lft; ... illustrates the idea but to create a valid <ul> list is different. You have to nest the tags correctly, and I cannot figure that part out.
  11. This works perfect for me, but I have another row with a page sort id. How do I sort the array with the page sort id? $page_sort_id = $row['page_sort_id'];
  12. I got it. I needed to change $content to $page_content.
  13. I can't seem to get my mind on this correctly. I need $page_content to go through each function, but It seems to either replace itself or duplicate itself. $filter is an array of function names $count = count($filter); if($count > 0){ foreach($filter as &$func){ $page_content = $func($content); // where the function returns the content. see sample functions below // $page_content .= $func($content); // not working either } } function replace_text($content){ $content = str_ireplace('test', 'WORKING', $content); return $content; } function replace_text_again($content){ $content = str_ireplace('page', 'THIS AN EXAMPLE', $content); return $content; } echo $page_content;
  14. I got lucky and tried to use the time offset from each timezone in seconds then use DATE_ADD/DATE_SUB based on the integer and corrected the time in the SQL statement to relfect the user's timezone. And it worked. Shew.... timezones area a headache. Went ok up until this point.
  15. I'm inserting/displaying date/time based on this flow: INPUT User input -> convert to server time -> insert date/time into table OUTPUT select date/time from table -> convert to user's date/time - > display date/time to user The above part works great until I need the events for a full day. My problem is when I need to get events based on a day, month, year and not the time. I need to get the full days events. If a user picks Jan, 28th 2010 at 00:00:00 time it will insert into the table for the 27th 23:00:00 (server time). When I query the database or events on the 28th I do not have the time. Only the month,day,year. So its looking for events on the 28th when it was inserted as 27(server time). How can I get around this?
  16. On that note... When I run this query: SELECT DATE_FORMAT(CONVERT_TZ(p.page_date, 'CST', 'EST'), '%M %d, %Y at %h:%i %p') AS f_date FROM tablename f_date is returning NULL
  17. I live in EST US. My server is in Central US. Which is the better way to display the date/time for my time zone. Should I convert it going into the database via INSERT, or convert it during the SELECT query? I will eventually have users that will set their own time zones. Any insight would be greatly appreciated.
  18. The reason why I do not want to pass it in the function is because the function will be a configuration function for a user, I was trying to make is as clean as possible. I did not want the user to have to worry about what the other variable was for. // easier for user function nav($id){} // Do not wish todo function nav ($id, $oClass){} With that, is a global safe? Or should I re-initialize the class again in the function?
  19. What is the best way to accomplish this? I need to reuse a class inside a function. Is it ok on performance to intialize the class again in the function? See below. $oClass = new cClass(); // ... Use class for tasks ... // Use class in function without passing $oClass // Want to do this without having to initialize the class again. OR is this OK? function nav($id){ // Would not like to initialize class again. // $oClass = new cClass() // do stuff with $oClass } // I do not want to do this function nav($id, $oClass)[ // Do stuff with $oClass }
  20. *Face palm* I'm an idiot.... case sensitive.
  21. Trying to parse some XML using simplexml_load_string. When I do a var_dump of the XML I get object(SimpleXMLElement)#3 (2) { ["AuthResponse"]=> object(SimpleXMLElement)#4 ( { ["ReturnCode"]=> string(2) "40" ["Status"]=> string(1) "F" ["ActualStatus"]=> object(SimpleXMLElement)#6 (0) { } ["AuthMsg"]=> string(57) "The Quantity field must be greater than 0 - Line item = 1" ["AuthCode"]=> object(SimpleXMLElement)#7 (0) { } ["CCType"]=> string(4) "VISA" ["AVS"]=> object(SimpleXMLElement)#8 (0) { } ["PCode"]=> object(SimpleXMLElement)#9 (0) { } } ["SubmittedData"]=> object(SimpleXMLElement)#5 (7) { ["TranNum"]=> string(7) "1008854" ["TotalAmt"]=> string(4) "7070" ["DbCr"]=> string(1) "D" ["AuthType"]=> string(1) "A" ["OrigTran"]=> object(SimpleXMLElement)#10 (0) { } ["U1"]=> object(SimpleXMLElement)#11 (0) { } ["U2"]=> object(SimpleXMLElement)#12 (0) { } } } Using this is not returning anything. $return_code = $xml->authresponse->returncode;
  22. For some reason the nested query is stopping the parent from completing. What am I over looking? Of course this is not the actual query but an example that fails too. public function list_stuff(){ $sql = "SELECT id FROM project"; $this->query($sql); while ($row = $this->rs->fetch_assoc()) { echo $row['id'].'<br />'; echo $this->pull_more_stuff($row['id']).'<br />'; } } public function pull_more_stuff($id){ $sql = "SELECT project_name FROM project WHERE id = '".$id."'"; $this->query($sql); $row = $this->rs->fetch_row(); return $row[0]; } If I comment out echo $this->pull_more_stuff($row['id']).'<br />'; the parent query will complete and I will get the results (project ids): 1 2 3 When I leave that line in I get: 1 Project Name
  23. I'm forwarding subdomains to a certain page. The problem is it won't give me access to other pages outside that. For example if I try to go to login.php it keeps sending me to company.php. This is what I have so far Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^(mydomain\.com)$ [NC] RewriteRule .* http://www.%1%{REQUEST_URI} [R=301] RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$ [NC] RewriteRule .* - [L] RewriteCond %{HTTP_HOST} ^(^.*)\.mydomain.com RewriteRule (.*) company.php?company=%1 [QSA,L]
×
×
  • 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.