-
Posts
827 -
Joined
-
Last visited
-
Days Won
9
Everything posted by fastsol
-
Is there a way via php script to sync a servers time? I have a dedicated server on a webhost and I can go in a sync it manually, but I would really rather not have to remember to do that every so often. I have read that a NTP can be setup, but I have zero knowledge of doing command line stuff like all the examples show to do. I was hoping for a php version of code that could accomplish the same thing. The reason I need to make sure it's synced is I ran into an issue with a Google API last night that stopped allowing me to authorize cause the time Google saw was not within range of what it wanted. Once I synced the server time, it let me authorize with the API. I don't want my website to break periodically if I forget to sync the time, so an automatic sync would certainly be best.
-
If it takes 1.87 seconds to complete a 2 row result, that's terrible. Just think how long that would take with 100 or 1000 rows.
-
Ok so then this table is actually not needed and will only make life harder in the future. What you need is 2 reference tables to go between the users table and the hair color and body type tables. Since ethnicity should really only have one value to a user, there shouldn't be any reason to store more than a single value per user. So the reference tables have only 2 columns, the user id and the id or the hair color or id of the body type. Then you use JOIN to gather the info from all the tables by referencing the ids between them. table name -> body_types_reference +---------+-----------+ | user_id | body_types| +---------+-----------+ | 1 | 1 | | 2 | 1 | | 2 | 5 | | 2 | 9 | | 1 | 5 | +---------+-----------+
-
How to create a select query calculating 'age' by user's date of birth?
fastsol replied to thara's topic in PHP Coding Help
Here's a post with lots of examples http://stackoverflow.com/questions/5773405/calculate-age-in-mysql-innodb -
How to create a select query calculating 'age' by user's date of birth?
fastsol replied to thara's topic in PHP Coding Help
You're going to need to change the data type of the dob column to an actual date format or you won't be able to determine any kind of time difference from it's values. -
Use the css border-radius. There are tons and tons of tutorials and info out there about it.
-
It's a little confusing as to if you want this done with or without user input. Meaning do you want the server to perform this task on it's own at certain times during the day/month/year/etc, OR is a client viewing the site supposed to view this page and have the value generated for them? The first method you would use a cron job, which you can setup to run when ever you want and does not require a client to visit the page to run the code cause the server runs it itself.
-
Trying to generate a random number whilst waiting for a future date
fastsol replied to Paulp51d's topic in PHP Coding Help
Displaying the numbers before the actual end time would only confuse the clients viewing it beforehand, especially since the shown numbers have no content value to them what so ever. As stated, it doesn't prove any kind of trust. -
Is it worth storing database results in a session
fastsol replied to NotionCommotion's topic in PHP Coding Help
I put results in a session for my product list. I also put the query string in a session var. The query string would change based on different vehicle selections by the client. So I just check if the query string is different from the one in the session and only run the query if it is different. In todays web market with so many users on mobile devices, it's really best to minimize load time in any logical method you can, this method is certainly one of those methods. -
what is "Fatal error: Unsupported operand types in" mean?
fastsol replied to sigmahokies's topic in PHP Coding Help
Most likely it's cause you are dividing a string value ($num_rows) by a integer value ($columns). Assuming that $_GET['member'] is always supposed to be a full integer value, do this. $display = (int)$_GET['member'];- 9 replies
-
- vertical data
- php
-
(and 3 more)
Tagged with:
-
Using a php library like phpmailer would make this a null subject cause it will automatically build all that for you, plus helps in delivery since it builds all the needed parts automatically.
-
Selecting Correct Entries From Database
fastsol replied to NalaTheFurious's topic in PHP Coding Help
There isn't really any reason to do as much validating as you are on the first line of $page. You could shorten it to this and still come out with the same result. $page = (!empty($_GET["page"])) ? (int)$_GET["page"] : 1; Also, when type casting to number formats, there is no reason to use some thing like htmlentities() on the var too. The type cast will strip anything that is not valid for the number formatting you are casting to. -
How do you include jquery in an html page?
fastsol replied to floridaflatlander's topic in HTML Help
You can certainly call jquery in the manner you are. BUT it must be called BEFORE your plugin. -
echo '<tr><td><input type="checkbox" name="'.$data['name'].'" value='.$data['value'].'></td></tr>'; When echoing html, I find it best to use 'single quotes' to encase the string. That way you don't have to escape the double quotes in the html to concatenate the php vars in the string. This way also makes the vars stand out in the code o you can see them better.
-
If you are trying to manipulate the href AFTER the person types the value in the text field without submitting the form, then yes you would need javascript (e.g. jquery).
-
Yes, for url variables you use the $_GET superglobal. $variable = $_GET['your_url_var_name']; // If the value is supposed to be a integer only, this is best for security $variable = (int)$_GET['you_url_var_name'];
-
wamp need to authenticate something with vhost.sourceforge.net
fastsol replied to Supervan's topic in Apache HTTP Server
Are you saying it needs internet to authenticate when installing wamp or to use it in general? I have wamp with apache 2.4.9 and php 5.5.12, which i believe is the current wamp release and had no issues installing. Although I did have a internet connection when installing. -
I already have a method of sending hundreds of emails by creating a db que that a cron runs every so often. My question is, is there a better way or a way at all to run a php script just once and be able to send hundreds of emails? I run my site on a dedicated server, so I have complete control of it. I would imagine that php would timeout when trying to send that much info. I would be sending a mixture of some emails over smtp and some straight from my server depending on the domain the email is going to. Basically anything going to a microsoft address flows through a gmail smtp to ensure it delivers to an inbox and not a spambox, everything else goes out of my mail host on my server. I use phpmailer for all email sending. Since all these emails are being sent based on certain db conditions in table data, I am making a que table that a cron runs to gather the according IDs and saves those. Then another script/cron runs that actually sends the emails, which then marks the que table as sent as it goes for each ID. I do it this way cause the que table could possibly gather more IDs in a run than the sending script is set to actually send. So the sending cron runs X times more than the que cron. Now maybe trying to send more emails in a single shot is pointless when I have all this cron doing it for me anyway, but I an tired of making 2 separate scripts, crons and tables to achieve a single goal for each automatic email I want to send. Please don't suggest a email sending service as I have already looked at that option and at least as of today I have not found one that allows me to submit a chunk of data for them to send. All places I talked to make you have a customer list, blah blah blah. I only want to do this with my server, not a mail service. Any suggestions?
-
Looking for Easy setup apache PHP MYSQL on windows
fastsol replied to Supervan's topic in PHP Coding Help
Ummmm, why wouldn't you want wamp? It's certainly the easiest way to go. What else are you looking for that wamp doesn't offer? -
Assuming that you are actually getting the json response back from the server, you're not doing anything with it in your ajax success block. You could do something like this with the returned message. success: function(data) { $('#ajaxDivOk').html('Informação: Esta formação foi registada na base de dados'); if(data.status == "success"){ // That is the json returned success in your array with message $('#ajaxDivOk').append(data.message); } }
-
This is a watermarking function that I built and use. // $wm is the watermark image you want to use // $img is the image to watermark // $xy should be an array of x and y coordinates - $xy['x'] = 150 $xy['y'] = 40 // placement defaults to center if $xy is not supplied // $dest woudl be a place to save the file if you are not displaying the new image directly to the browser. function watermarkImage($wm, $img, $xy = NULL, $dest = NULL) { $watermark = imagecreatefrompng($wm); $wm_src = getimagesize($wm); $source = getimagesize($img); $mime = $source['mime']; if($mime === 'image/jpg') {$src = imagecreatefromjpeg($img);} elseif($mime === 'image/jpeg') {$src = imagecreatefromjpeg($img);} elseif($mime === 'image/pjpeg') {$src = imagecreatefromjpeg($img);} elseif($mime === 'image/png') {$src = imagecreatefrompng($img);} elseif($mime === 'image/gif') {$src = imagecreatefromgif($img);} $x = ($xy !== NULL) ? $xy['x'] : floor(($source[0] / 2) - ($wm_src[0] / 2)); $y = ($xy !== NULL) ? $xy['y'] : floor(($source[1] / 2) - ($wm_src[1] / 2)); imagecopy($src, $watermark, $x, $y, 0, 0, imagesx($watermark), imagesy($watermark)); imagealphablending($src, false); imagesavealpha($src, true); if($mime === 'image/jpg') { if($dest !== NULL) { imagejpeg($src, $dest, 95); } else { header('Content-Type: image/jpeg'); imagejpeg($src); } } elseif($mime === 'image/jpeg') { if($dest !== NULL) { imagejpeg($src, $dest, 95); } else { header('Content-Type: image/jpeg'); imagejpeg($src); } } elseif($mime === 'image/pjpeg') { if($dest !== NULL) { imagejpeg($src, $dest, 95); } else { header('Content-Type: image/jpeg'); imagejpeg($src); } } elseif($mime === 'image/png') { if($dest !== NULL) { imagepng($src, $dest); } else { header('Content-Type: image/png'); imagepng($src); } } elseif($mime === 'image/gif') { if($dest !== NULL) { imagegif($src, $dest); } else { header('Content-Type: image/gif'); imagegif($src); } } imagedestroy($src); }
-
Many of the googled posts talk about the host disabling the mail(). Can you send email with a test page using only the mail() in php?
-
I've used phpmailer for a long time and have not seen this before. I simply google "phpmailer sent.Mailer Error: Could not instantiate mail function" and a number of posts come up about it, start there.
-
PayPal IPN getting payment status and other values
fastsol replied to seany123's topic in PHP Coding Help
If your server goes down in the 30 seconds between you sending them to paypal and paypal directing them back, well you probably have much bigger problems. Plus the ipn only sends once too, so it wouldn't make any difference which method you chose, if your server is all the sudden down, the ipn won't work either. I still think you don't understand the difference between the api and ipn. The api allows you to send them to paypal to enter their payment info and then be sent right back to your site where your php processes the payment and you perform any other db update you want IMMEDIATELY. Then you redirect your customer to whatever page you want and allow them access to whatever they just paid for. The ipn works like this. You setup a button with far more details than the api button, they click and go to paypal to enter their payment info. They stay on paypal until the payment is fully finished. Paypal shows them a thank you screen and redirects them a few seconds later to the page you setup in the paypal account itself. Now in the time they are redirected, it is possible that paypal has already sent the ipn info to your page, but it's not a guaranteed to be that fast. I've seen it take upto a minute. So even if they are redirected back, the ipn may not have finished yet, so now what do you do, make them wait an unknown amount of time until the ipn finishes and keep refreshing the page and checking if it has. Do you see the difference now? The api is the better way to go. The only reason the ipn works good for me if cause I need to verify each transaction as the ipn sends to make sure I have everything on hand for the product the customer requested. So the customer is informed right away that I need to verify and get things ready for them BEFORE they are allowed to do anything else on the website. The tutorial shows you more than enough to get you going. There aren't any good ipn tutorials out there that deal with the most recent code from paypal, so you'll be left to figure alot of that out yourself, although I gave you pretty much everything you need already.