QuickOldCar
Staff Alumni-
Posts
2,972 -
Joined
-
Last visited
-
Days Won
28
Everything posted by QuickOldCar
-
This post is for anyone to tell about their bad experiences or blunders. Could be related to coding, website design, server management, freelancing, computer related or even something else. Everyone has had those bad days, I know I've had my share. Sometimes everything goes wrong and no matter how much you try it just gets worse. Other times is just a brain fart and do something moronic. Here are just a few of my experiences I can remember. As I'm coding in my office/basement at the time, my electric dryer behind me suddenly bursts into flames with drenched clothes in it. You can read that story here Experimenting with code, ended up doing an endless loop maxing out the memory and cpu, everything just frozen. Had to yank the plug. At the same time that server was doing an insert and corrupted the database, had to wait out a 9 hour repair process. To top off that day the electric company had a huge power spike, so big it melted my memory away and a hole in motherboard, caught on fire. I had it through 4 surge protectors, obviously they don't help for these. New server build in order. Next garbage day saw a pile of computers and monitors for blocks, lots had a bad day. Accidentally deleted an important database with no backups available. Good thing is harddrive recovery programs. Setting up a server for a client, took forever, once completed I hit update, but instead did an upgrade to a new kernel and wiped everything out, had to start over. Home server acting up, thinking is a corrupted drive saved all data to a new external harddrive. Sure enough the original harddrive unable to get any data from, whew am I lucky. Plug in new external other server and find out the new harddrive is faulty and no longer works. Being the smart person that I am....I have another exact same new external, so swapped the platters. Ends up still doesn't work. So 3 toasted drives and loss of data same day. The next day the cpu that server stopped working, another 400 bucks. Ever hear the saying "dog ate my homework", try telling a client "dog ate your video card". I went for a coffee and had the clients computer all apart, when I came back my cane corso was still gnawing on the video card in little pieces and slobber all over. Ended up paying 3x more than what original job was for. I'm a computer overclocker at heart, when amd came out with the xp palomino I decided to do a new build and crank it up. Problem with these and similar cpu packaging is you have to cut and join some bridges on the cpu. razor blade and using a windshield defrost repair kit. Basically liquid copper. Got online followed which bridges to cut and connect. Got all the work done, had the motherboard laying the hood of my car in garage on cardboard, ran an extension cord to the psu with it hotwired to turn on. I plug it in and exploded, the heatsink hit my 15 foot garage ceiling, parts flew everywhere. Never once found any part resembling a cpu. Was a big hole in motherboard and a scorched mark my hood. Confused I went back online to see what could have gone wrong, turns out they changed the power bridge this particular package and put 10x more voltage to the cpu than required. Ordered all new parts, did again but the right way and worked. Out for a sunday drive my old barracuda with my girlfriend. Out in the boondocks somewhere when I hear a knock in the engine then a few backfires and stalls. I get out and look over the engine but nothing obvious, cranking and hearing the backfires I assume my timing chain went. I pushed the car while my girlfriend steered what seemed like 5 miles until I found a safe large spot to park the car. Placed a white flag on my window and a note saying will be right back with parts to fix it. We walked probably another 5 miles to a gas station. Called my moms boyfriend, told him what needed and he brought me the parts.(pre cell phone days) He met me at the gas station, then we drove to where the car is...um was?? My car is gone!!! Now what in the hell, did someone steal it or what. So we drive around for a few hours going up and down local dirt roads hoping to find it. We gave up, I called every state police, local police, garage and towing company I could find. All said had nothing to do with it, filed a stolen car report with the state police. So here I am with no car for work, my pride and joy missing. Bought a beater fifth ave to get around, every day when got out of work drove around where my car went missing and outwards trying to find it. 8 days later I get a call from state police that a local garage towed my car. Was no reason for them to tow it, and why did it take them so long? They tell me location and I shot out there with my trunk full of tools and parts. The scraggly man at the desk said had my car, after an argument over daily storage fees, the tow and why he towed my car in first place....I paid his con artist fees and he leads me to the car. He asks me if I need it towed, I said no, and shouldn't have towed it in the first place, the man walks back inside fearing my anger. I quickly just started ripping it apart, slammed in a new timing chain and water pump, topped it off with antifreeze, started the car looking for leaks. Guy comes back out, he asks me if I just changed the timing chain, I said yes, he asks me if I wanted a job, I said no. Not sure if he was feeling guilty or getting on my good side but he said he'll just charge me the tow now. I was happy for that. Then I ask him if he wanted to buy my beater fifth ave, he looked it over and bought it for 3x what I paid for it. I have more stories, that's enough for now.
-
The most appropriative way of using data formats
QuickOldCar replied to web_craftsman's topic in PHP Coding Help
Use a text editor like ckeditor or tinymce -
php.net , mysql and here are the only sources you need Lots out there is outdated or bad practices.
-
concatenation of the string $orderitems = "INSERT INTO order_items (order_item_product, order_item_price, order_item_order_id) VALUES ('".$fproduct[$g]."', '".$fprice."', '".$orderid."')";
-
First off you are using $wholedate2 and $date2, pick one. If you used datetime your way could have worked, since is a timestamp needs like this. This has to do calculations on everything and is a waste. $query_rsUser = "SELECT COUNT(*) FROM quotes WHERE quotes.quote_user = 'username' AND DATE(quotes.quote_complete) = CURDATE() AND quotes.quote_status = 'Complete'"; Instead something like: $query_rsUser = "SELECT COUNT(*) FROM quotes WHERE quotes.quote_user = 'username' AND quotes.quote_complete BETWEEN '".$wholedate2." 00:00:00' AND '".$wholedate2". 23:59:59' AND quotes.quote_status = 'Complete'";
-
Where is the screenshot your database?
-
jazzman1 answered what do do in response #34 and correction in #35 Nowhere in your code do you attempt to make a query and check if a user already posted that day. select * from db_name.tbl_name where (tbl_name.date_record >= current_date() - interval 1 day) and tbl_name.user_name = 'some username'
-
When is content.php called in wordpress twentyfifteen theme?
QuickOldCar replied to colap's topic in Applications
get_post_format() actually returns a true/false boolean. Wordpress theme functions consider this as standard. get_template_part('content',get_post_format()); would be get_template_part('content',false); Since get_template_part expects a string, you would leave it empty or add a string name there. If you wanted to keep it the same throughout a theme could define format as standard with a check. $format = get_post_format();//boolean true/false //do a check for true or false and assign it a string if ( false === $format ) { $format = 'standard'; } get_template_part( 'content', $format ); The second function variable is optional, but if used the code above would look for content-standard.php, adding it to the content area. So add a file named content-standard.php If you want to assign get_template_part() with different strings, should use get_post_format_string() get_post_format_string('standard'); And here is the function within wordpress post-formats.php for that to see your available options function get_post_format_strings() { $strings = array( 'standard' => _x( 'Standard', 'Post format' ), // Special case. any value that evals to false will be considered standard 'aside' => _x( 'Aside', 'Post format' ), 'chat' => _x( 'Chat', 'Post format' ), 'gallery' => _x( 'Gallery', 'Post format' ), 'link' => _x( 'Link', 'Post format' ), 'image' => _x( 'Image', 'Post format' ), 'quote' => _x( 'Quote', 'Post format' ), 'status' => _x( 'Status', 'Post format' ), 'video' => _x( 'Video', 'Post format' ), 'audio' => _x( 'Audio', 'Post format' ), ); return $strings; } -
When is content.php called in wordpress twentyfifteen theme?
QuickOldCar replied to colap's topic in Applications
In index.php of that theme or other wordpress themes usually, unless they include other files or functions special for a theme. get_template_part() is the function that includes other files into the template. In twentyfifteen theme it's get_template_part( 'content', get_post_format() ); -
wamp php mail is not working
QuickOldCar replied to colap's topic in PHP Installation and Configuration
I'll agree, phpmailer would be better. Slipped my mind and remember using hmailerserver for a windows box and worked. -
wamp php mail is not working
QuickOldCar replied to colap's topic in PHP Installation and Configuration
hmailserver is your best option for windows. Please don't ask configuration, they have it documented or google it, information is all over for it. -
error with youtube player for joomla
QuickOldCar replied to treybraid's topic in Third Party Scripts
Youtube ended support for version 2 api, need to sign up now and use version 3 with a key. Which means your module needs editing plus make an api account. https://developers.google.com/youtube/2.0/developers_guide_protocol Note: The YouTube Data API (v2) has been officially deprecated as of March 4, 2014. Please refer to our deprecation policy for more information. Please use the YouTube Data API (v3) for new integrations and migrate applications still using the v2 API to the v3 API as well. -
foreach ($items['choices'] as $choices) { echo "<li id='price'>" . $choices['prices']['min'] . "</li>"; }
-
Is it worth storing database results in a session
QuickOldCar replied to NotionCommotion's topic in PHP Coding Help
I agree, can even devote more memory to it if need to. Also agree. When doing many new inserts constant it becomes useless, depends how often the data is changed. So if doing complex queries such as sorting or searches might want to look into caching it yourself to lessen doing the query. -
Is it worth storing database results in a session
QuickOldCar replied to NotionCommotion's topic in PHP Coding Help
I have some bigger queries that I cache the mysql results. For some items I do only id's, other things is full arrays of all the rows. I've tried it in json format and also php and seems to work fine. -
I'll help a bit more in case not familiar with what to do the rest. You can assign variables, style as want, however you would like to use the data. <?php $client_key = 'c3sbrpbtkbs5gverurfkxpemc'; $sig_key = 'PkkJXNRpO2l0r5u6u0PlCNme1KA8akGejMIjHI5Gkj8'; $base_url = '/locations/horse-inn/menus/?client=' . $client_key; $url = hash_hmac('sha1', $base_url, $sig_key, true); $str = urlencode(base64_encode($url)); $fnl_url = 'http://publishing-api.singleplatform.com' . $base_url . '&signature=' . $str; $ch = curl_init($fnl_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $result = json_decode($response, true); //echo "<pre>", print_r($result), "</pre>"; if ($result['data'] && $result['code'] == "200") { foreach ($result['data'] as $data) { //echo "<pre>", print_r($data), "</pre>"; echo $data['id'] . "<br />"; echo $data['location_id'] . "<br />"; echo $data['name'] . "<br />"; echo $data['description'] . "<br />"; echo $data['menu_type'] . "<br />"; echo $data['footnote'] . "<br />"; echo $data['order_num'] . "<br />"; echo $data['currency'] . "<br />"; echo $data['created'] . "<br />"; echo $data['updated'] . "<br />"; echo $data['attribution_image'] . "<br />"; echo $data['attribution_image_link'] . "<br />"; foreach ($data['sections'] as $sections) { echo $sections['order_num'] . "<br />"; foreach ($sections['items'] as $items) { echo $items['name'] . "<br />"; echo $items['description'] . "<br />"; //got lazy, you can keep going echo "<pre>", print_r($items['choices']), "</pre>"; } } } } ?>
-
More like this and now can access any array or loop through them. <?php $client_key = 'c3sbrpbtkbs5gverurfkxpemc'; $sig_key = 'PkkJXNRpO2l0r5u6u0PlCNme1KA8akGejMIjHI5Gkj8'; $base_url = '/locations/horse-inn/menus/?client=' . $client_key; $url = hash_hmac('sha1',$base_url, $sig_key, true); $str = urlencode(base64_encode($url)); $fnl_url = 'http://publishing-api.singleplatform.com'.$base_url.'&signature='.$str; $ch = curl_init($fnl_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec( $ch ); $result = json_decode($response, true); //echo "<pre>", print_r($result), "</pre>"; if($result['data']){ foreach($result['data'] as $data){ echo "<pre>", print_r($data), "</pre>"; } } ?>
-
Beat me to it.
-
Maybe you want unset($_SESSION['criteria']);
-
Set them as associative named arrays. //make sure starting session session_start(); if(isset($_POST['submit'])){ //is a database connection started? //trim and consider pdo or mysqli_* functions $employment = mysql_real_escape_string($_POST['employment']); $mstatus = mysql_real_escape_string($_POST['mstatus']); $agefrom = mysql_real_escape_string($_POST['agefrom']); $ageto = mysql_real_escape_string($_POST['ageto']); if(!$_SESSION['criteria']){ $_SESSION['criteria'] = array(); } if($employment !='') { $_SESSION['criteria']['employment'] = $employment; } if($mstatus !='') { $_SESSION['criteria']['status'] = $mstatus; } if($agefrom !='' && $ageto !='') { $_SESSION['criteria']['agefrom'] = $agefrom; $_SESSION['criteria']['ageto'] = $ageto; } if(!empty($_SESSION['criteria'])){ echo "<pre>"; print_r($_SESSION['criteria']); echo "</pre>"; } }
-
//Simple: must contain 0 to 9 or dash all the way throughout $telephone_exp = "/^[0-9-]+$/"; But lets expand on that a bit, have some examples below <?php $error_message = ''; //city codes $telephone = "+11 (555) 123-4567"; //10 digit $telephone = "555-123-4567"; $telephone = "(555) 123-4567"; //must contain 0 to 9 or dash all the way throughout $telephone_exp = "/^[0-9-]+$/"; //International which includes city codes $telephone_exp = "/^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/"; //10 digit format with optional parenthesis, separated space or dash $telephone_exp = "/^(\+0?1\s)?\(?\d{3}\)?[\s-]\d{3}[\s-]\d{4}$/"; //make sure you trim the number beforehand for whitespace $telephone = trim($telephone); if(!preg_match($telephone_exp,$telephone)) { $error_message .= 'The Telephone you entered does not appear to be valid.<br />'; } ?> When it comes down to it is many ways someone can type a phone number into a single text area. Maybe the right way to do it is to separate each number field in the form and force them to use only numbers, making the city code and area code as optional.
- 1 reply
-
- 1
-
Listing the username is helping hackers with half the battle, I would have them insert the username and password. Having passwords hashed in the database is what you want. Look into password_hash() and password_verify()
-
Memory continues to increase causing the need for a restart
QuickOldCar replied to scotkersten's topic in MySQL Help
More information would need to be known about how you are saving and inserting the new data. Looking at your settings they seem low This is only 3 gig which could be 70% your total memory innodb_buffer_pool_size 25769803776 This is 1MB and could be around 10MB key_buffer_size 8388608 You may want to break this data up into each table by using a client id or the date. You could always join tables to get a clients full data. Instead of all the shuffling around of data, I would separate tables most likely. If current table named by date does not exist create and populate it. I think of in the future, do you need to be accessing a database with old records you may not need, chances of data corruption, table limits and so on. One idea to continue as you are is to insert into a temporary table daily and merge x amount until is no more left. Not do all 250,000 one shot. You can set a cron job to initiate it start of the day until it completes. -
storing multipe session variables for a cart
QuickOldCar replied to Kevinh's topic in PHP Coding Help
Sessions are arrays, the users session will already have a session id assigned. It's session_id() Anything you add to the session as an associative or named array key is a potential array or a single key value if that's what you desire. I made a little demo can test out and experiment with. <?php //start session session_start(); //unset($_SESSION);//unsetting session for testing //ensure session is set with id if (session_id() != "") { //users session id $session_id = session_id(); //define session array if doesn't exist if (!$_SESSION[$session_id]['cart']) { $_SESSION[$session_id]['cart'] = array(); } //make dynamic values to add into array $product = "bread"; //product name $product_id = 3456; //product id $qty = 2; //quantity to add //add a different item /* $product = "poultry";//product name $product_id = 555;//product id $qty = 1;//quantity to add */ //add additional same items if ($_SESSION[$session_id]['cart'][$product_id]['quantity']) { $qty = $_SESSION[$session_id]['cart'][$product_id]['quantity'] + $qty; } $_SESSION[$session_id]['cart'][$product_id] = array( "product" => $product, "quantity" => $qty ); echo "<pre>"; print_r($_SESSION); echo "</pre>"; } else { echo "No session for cart"; } ?> My results: Array ( [8ba04fc430043d8902928f41b5a83b2e] => Array ( [cart] => Array ( [3456] => Array ( [product] => bread [quantity] => 2 ) [555] => Array ( [product] => poultry [quantity] => 3 ) ) ) )