scootstah
Staff Alumni-
Posts
3,858 -
Joined
-
Last visited
-
Days Won
29
Everything posted by scootstah
-
Building Your Own Server vs Using a Service
scootstah replied to thetylercox's topic in Application Design
I usually don't like to have my domains with the same company I have webhosting through. I usually recommend namecheap for domains if someone asks me, they seem to have a good reputation. EDIT: http://css-tricks.com/this-sites-domain-is-stolen/ That's GoDaddy's fault how? Just to clarify, that was in no way GoDaddy's fault. The same thing happened to several other registrars. But, I don't believe GoDaddy did their best to help their customers during the event. -
Building Your Own Server vs Using a Service
scootstah replied to thetylercox's topic in Application Design
I use namecheap, 9.50 /each (and they often have promos) Is that only new domains or recurring price? -
Building Your Own Server vs Using a Service
scootstah replied to thetylercox's topic in Application Design
- They overload their servers, resulting in terrible performance - Their customer support sucks - Their website is just horrendous as far as usability is concerned - The control panel they use is just terrible... it sometimes takes a long time for simple changes to take effect and, again, terrible usability Just off the top of my head. There is plenty of better webhosts - there's no reason to suffer the headache of GoDaddy. With that said, I still use them for my personal domains because I can get .com's cheaper than anywhere else that I've found (<$8 each). Although lately this has proven to be a little time consuming and frustrating (finding promo codes that work) so I may end up transferring them at some point. -
Something like this: UPDATE table SET column='N/A' WHERE column=''
-
This may not be the prettiest solution but it works: $array = array( array('Advair' => '40mg'), array('Advair' => '50mg'), array('Dulera' => '50mcg'), array('Flovent' => '20mcg'), array('Symbicort' => '120/4.5'), array('Symbicort' => '140/4.5') ); $new_array = array(); foreach ($array as $arr) { foreach($arr as $key => $val) { if (array_key_exists($key, $new_array)) { $new_array[$key] .= ', ' . $val; } else { $new_array[$key] = $val; } } }
-
This seems to work: $string = '<a href="mysite/user/39">Pooja</a><a href="mysite/user/58">Harsha</a>some text here'; $string = preg_replace('/<a href="(.+?)">(.+?)<\/a>/i', '<a href="$1" title="$2">$2</a>', $string);
-
How can we help when you don't provide any code? There are many things that can prevent file uploading from working properly. For starters, put this code in your script in the area where you process the form (the form has to be been submitted when this code fires) and post the output here: echo '<pre>' . print_r($_FILES, true) . '</pre>';
-
Ah. Well, I usually let my DB abstraction layer deal with that, I normally don't explicitly escape anything.
-
Yeah, you could do it that way if you wanted to create your own function. Something like: function slashit($array) { $slashed = array(); foreach($array as $key => value) { $slashed[$key] = mysql_real_escape_string($value); } return $slashed; } However, the PHP functions I listed above basically do that for you, and array_walk_recursive will handle multi-dimensional arrays.
-
They were possibly talking about magic quotes, which automatically adds slashes to all $_GET, $_POST, and $_COOKIE data. However, it does more harm than good. It doesn't take different character sets into consideration, and so it isn't as good as mysql_real_escape_string(). But, you can run a function against all of the elements of an array using array_map, array_walk or array_walk_recursive.
-
I just told you how. Do you have any code so far? Are you stuck on something?
-
You can only use CURRENT_TIMESTAMP() if the field is of type "timestamp". If it is "datetime" (which it is) you have to manually insert the current date/time using NOW(). There are a couple things wrong with the code you posted though. 1. You are inserting unchallenged user input. NEVER DO THAT! Your script is vulnerable to SQL injection. You need to run any user input that interacts with the database through mysql_real_escape_string first. 2. When you are pulling data from an array you need to use quotes around the index. Currently your code will give a notice. It should be $_POST['Subject'] and $_POST['Content']. Also, since you (presumably) didn't see that notice you are coding without the proper error reporting set. When developing you should be displaying ALL errors. To set the proper error reporting, place this at the top of your script: ini_set('display_errors', 1); error_reporting(-1);
-
You need to put the "fetch" function into the while loop, like this: while ($row = mysql_fetch_assoc($result)) { // ... } Notice also that I used mysql_fetch_assoc instead of mysql_fetch_array. Generally you do not need mysql_fetch_array(), and it isn't good to use it because you get back double the amount of data, and thus double the amount of memory (despite the fact that you almost always only use one set of data). The difference is that mysql_fetch_assoc() returns an associative array (like what you are using), and mysql_fetch_array() returns both an associative array and a numerical array. (If you want only a numerical array you can use mysql_fetch_row). A lot of beginner tutorials use these functions incorrectly and instill bad habits. EDIT: And about the timestamp thing, can you show us how you are inserting the data?
-
You're either going to have to use an AJAX script which triggers when the URL is clicked, or you're going to have to point the URL at a PHP script with the destination as part of the query string. Your best bet for storing the results in either case is to use a relational database, like MySQL.
-
The result won't be the same. Using an asterisk selects all columns, specifying columns only gets data from the ones you specify.
-
It works for me, but I don't want to miss an opportunity to hate on ImageShack. Why people still use it is beyond me. Imgur is > every other image sharing website right now in my opinion.
-
Here's a quick example using jQuery to execute an AJAX request when you change the dropdown value: http://jsfiddle.net/D46Kn/ More information on the AJAX method: http://api.jquery.com/jQuery.ajax/
-
You seem to have this sorted but I figured I would leave this anyway. I like to use a function like the one below to handle redirects so that I know the script is always terminated. Plus, the shorthand is nice. function redirect($url, $type = 'location', $delay = 3) { if ($type == 'refresh') { header("refresh:$delay;url=$url"); } else { header("location:$url"); } exit; } // usage redirect('http://google.com'); // sends "location" header redirect('http://google.com', 'refresh', 1); // sends "refresh" header with a 1 second delay
-
This is untested but try something like this: $ch = curl_init(); $post = array('input_stock_code' => 'your value here'); curl_setopt($ch, CURLOPT_URL, 'http://www.gretai.org.tw/ch/stock/statistics/monthly/st42.php'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); curl_close($ch);
-
excluding characters from the htmlspecialchars function
scootstah replied to basher400's topic in PHP Coding Help
Convert it back afterwards. $str = 'a string with & in it'; $str = htmlspecialchars($str); $str = str_replace('&', '&', $str); -
What if you want to use the same data from the model in a different environment that needs different sanitation? Then you'd have to have different models/methods to fetch identical data but format it differently. No, that should be handled in the controller or the view. It makes your application more flexible and more extensible.
-
I don't think there would be any copyright issues because Google doesn't host the content it finds. Plus, it is easy enough to tell Google not to find things if you don't want it to.
-
I'd just like to know why you think that is necessary.
-
You could sanitize it on output for that. I think it would be better to maintain data integrity in this case because it might help you to see if anyone is attempting to exploit/attack the system.