-
Posts
4,704 -
Joined
-
Last visited
-
Days Won
179
Everything posted by kicken
-
Find out what the current version is, and the target version. Then read through the release notes and change logs which can be found in the mysql manual. Most likely you won't be affected by anything, but one of the best ways to find out is to setup your site on a development server with the upgraded software and test it thoroughly. Find out what doesn't work properly and then find out why.
-
Pass JS Variable to PHP variable. Please save me!
kicken replied to stevengreen22's topic in Javascript Help
Rather than complicate this process with JS and AJAX, just do the lookup to ipinfo.io using PHP before the page loads. If fopen wrappers are on, a simple file_get_contents call will suffice. Otherwise you can use CURL <?php $phones = array( 'GB' => 'blah , 'GABON' => 'foo' , 'THAILAND' => 'bar' ); $url = 'http://ipinfo.io/'.$_SERVER['REMOTE_ADDR'].'/country'; $country = file_get_contents($url); var_dump($country, $phones[$country]);- 1 reply
-
- ajax
- javascript
-
(and 1 more)
Tagged with:
-
You just have to pass the variable as a string, not as a variable. Ie: newFunc('a'); //not newFunc(a); Note that trying to create such a generic function is not that useful in any case. It would only work for global variables, not for variables inside a function/closure for example. The code necessary to check if a variable exists is not excessively long either so you do not gain much from wrapping it in a function. Whatever problem you are attempting to solve would most likely be solved better another way, but you'll have to state what your actual problem is that prompted to to want to try and create such a function.
-
Trying to add in a bunch of JS and Ajax only makes the form needlessly complex. All that needs done is to set a variable after submit which then triggers the display of said message. <?php if (isset($_POST['submit'])){ //Do all your processing //On Success, redirect to self with a variable to indicate success. header('Location: contact.php?success=1'); exit; } ?> //..html <tr> <th></th> <td><button type="submit" name="submit">✓ Submit</button></td> </tr> <?php if (isset($_GET['success'])): ?> <tr> <td colspan="2">Your message has been sent successfully!</td> </tr> <?php endif; ?>
-
How do you create a global constructor object in javascript?
kicken replied to drayarms's topic in Javascript Help
All you have to do is define a function, then call it with the new operator. function MyObject(param){ this.blah = param; } var obj = new MyObject('hi'); If you want to create a namespace you can, you'd just declare the function as a property of that object: var myNamespace = { MyObject: function(param){ this.blah = param; } }; var obj = new myNamespace.MyObject(); -
Based on the reference, I'd say try: layer.set('clickable', false);
-
Read through this thread: How to safely store passwords for some details about hashing, rainbow tables, salts, etc. That should give you a lot of good info to start with. The short answer to your questions though: The value found may or may not be the original password, but if it results in the same hash then it will work just as well. Two values resulting in the same hash is possible, and is known as a collision. On a side note, MD5 is not encryption, it is a hash. Something that has been encrypted can be readily decrypted. That is not possible with MD5 and other hashing algorithms. As such, do not reference things as being MD5-encrypted, use md5-hashed or similar.
-
Get names & values of all HTML form elements with PHP
kicken replied to cbassett03's topic in PHP Coding Help
The $_POST/$_GET arrays will contain all the name value pairs. Which you use depends on the form's method. Just do a foreach loop over the appropriate array: foreach ($_POST as $name=>$value){ //.... } -
require_once('/home/omenaa/public_html/affiliate/api/PapApi.class.php'); The path you give to reqire_once (and similar) needs to be a file-system path, you had it set as a URL path.
- 4 replies
-
- require_once
- fatal error
-
(and 1 more)
Tagged with:
-
You'll have to do a comparison of the old record value to the new value. Only run your UPDATE query if there has actually been a change. if ($oldRecord['name'] != $_POST['name']){ //Do Update }
-
Do you have a PapApi.class.php file anywhere in your directories? If yes, you need to adjust the path to point to it. If no, you'll need to acquire it somehow.
- 4 replies
-
- require_once
- fatal error
-
(and 1 more)
Tagged with:
-
Going to have to show your code if you want help. My initial guess would be you are accessing element [1] when you should be accessing [0] (arrays are 0-based)
-
SQL Server does not have a DATE_FORMAT function. The closest equivalent is using CONVERT with certain format codes. The format you are trying to get is not available with the default format codes however. In this case you'll need to query the date unformatted, and then format it using PHP's date function (or DateTime class). Other than that, your queries should move fine between each server without issue.
-
Cannot connect to SQL Server on local machine using PHP
kicken replied to bigmac90's topic in Microsoft SQL - MSSQL
Google knows if you just search the error code: http://blogs.msdn.com/b/sql_protocols/archive/2006/02/21/536201.aspx- 2 replies
-
- php
- sql server
-
(and 1 more)
Tagged with:
-
Why would you even want to do such a thing?
-
Have a table in your database that stores the user ID and the filename of the image. Each time someone uploads an image add a row to that table. When you want to display images for a particular user, query the table for the images where UserId=?
-
There is no simple answer to that. *YOU* have to decide that on your own. Think about what you want your CMS/Blog to do. What features should it have? What kind of data should it store? Once you determine what kind data you need to store, then you move into the database design aspect and determine how best to actually store that data. Reading up on Database Normalization should your first step so you can get an understanding of how to manage the data and how to properly split it up across tables.
-
The easiest thing to do would be to save a list of ID's into a $_SESSION variable (or memcache or another DB table) and then track which ID you are currently using. Even with a 2000 item list, storing only the IDs into a session variable shouldn't cause any major problems. A site I maintain has a similar feature (though the records list is typically small, 10-15 items max) and I handle it using two $_SESSION variables: $_SESSION['openItems'] = array(/* list of IDs the user has opened for viewing */); $_SESSION['currentItem'] = [0 - count($_SESSION['openItems'])-1]; /* The index of the currently viewed item. */ Previous/Next operations are just a matter of -1 or +1 to $_SESSION['currentItem'] (with appropiate overflow handling). Then $_SESSION['openItems'][$_SESSION['currentItem']] gets the ID of the record to view.
-
That's the Ternary Operator It's equivalent to: if (isset($_GET['user'])){ $user = trim($_GET['user']); } else { $user = ''; }
-
Google takes time to update. Just because you fixed the problem doesn't mean it'll be fixed on google right away. It could take up to a few months for google to de-index your 404 page or any other urls you decide to exclude.
-
I have no idea since I do not use safari, try Google. As for firefox you need to have Firebug installed and open, then you will see a tab labeled Net. You'll see the status and other headers as so:
-
I assume based on the code that you are simply changing the image from display: none; to display: block; (or inline) in order to show it. Just do the reverse with the button in order to hide it. Change it's display property to none.
-
That is invalid, unless you are using PHP 5.5, which is unlikely for most people as it's still pretty new. empty can only be used on variables in previous versions, not expressions. $user = isset($_GET['user'])?trim($_GET['user']):''; if ($user == '' || !ctype_digit($user) || $user > 1000 || $user < 1){ //Error } else { //Ok } That will assign $user to a trimmed version of the $_GET variable if it exists, or the empty string otherwise. The if then checks if:- It is the empty string or - It contains a non-digit (0-9) character or - It is > 1000 or - It is < 1 If any of those are true, you have an error condition which you'd handle in the body of the if statement.
-
Use the networking area of your favorite browser's dev tools to exam the request and response. It should show you the headers sent and headers received, including the status code. Another option is to use something like Fiddler2 to exam the request/response.