-
Posts
354 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Irate
-
Problems transferring a PHP array to JavaScript
Irate replied to Darkranger85's topic in Javascript Help
What do you get when you alert success: function(data){ alert(data); }? -
That'd be HTTP_CLIENT_IP. Anyway, you can realize what you're trying to do with a getIP() function, something similar to this. function getIP() $ip; { if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR != "unknown") // test forwarded_for and if not unknown { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif(isset($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } else { $ip = $_SERVER['REMOTE_ADDR']; } return $ip; }You can then use the return value of getIP() as INSERT for your MySQL query. require_once('getIP.php'); $mysqli = new mysqli(...); // initialize new MySQLi connection $mysqli->query("INSERT INTO `yourtable` (ip) // assume you have a field named ip VALUES ( `".getIP()."`);"); // carry on with your code
-
Javascript not firing correctly when called in PHP
Irate replied to farmallnerd's topic in Javascript Help
You are sure that you have jQuery and the appropriate plugin installed on your Operating System? You can try echoing out the script via PHP if that doesn't work, too. -
Following errors occurred: PHP Warning: include(copyright.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in C:\inetpub\wwwroot\index.php on line 143 PHP Warning: include() [<a href='function.include'>function.include</a>]: Failed opening 'copyright.php' for inclusion (include_path='.;C:\php\pear') in C:\inetpub\wwwroot\index.php on line 143
-
Object-orientated programming is a feature of PHP since PHP 3, but it got upgraded in PHP 5 to be an actual key feature of PHP and as such, the PHP parser now treats objects differently than it did with PHP 3. As mentioned before, unless you want to write programs with objects, you will most likely never use it. You'll stumble across the mysqli class with XAMPP, so I do recommend learning about objects.
-
Psst, try checking if you covered yourself against these vulnerabilities
-
Also, when you're operating with values of input field, parseFloat() or parseInt() the valu and save it in a variable, that way, you don't need to iterate over the same value over and over again.
-
javascript: URLs are hopelessly outdated and shouldn't be used. Try to use unobstrusive JavaScript, or, ideally, use jQuery, that's much easier.
- 3 replies
-
- javascript
- help
-
(and 3 more)
Tagged with:
-
Maybe the friends of Times New Roman? Web designing is the second priority one must set when building a web site; while web development takes care of the major and important security features and functionality, web designer make the site attractive and a feast for the eyes which almost equals the importance of actual programming. Shortly said, CSS is not to be underestimated, but in a forum full of PHP freaks, I'd say that PHP is still our priority
-
Could you show us the code to the ShareCount object?
-
Yeah, it should work with arrays and objects, but since I usually work with JavaScript, I return objects when possible.
-
You can return an object and work with it in other functions, like you have an object defined and assigned to a variable, you return the variable and you can use all the methods you need.
-
<?php $obj = new ShareCount( the_permalink() ); ?> should work if you have the function working in the same scope and have the function return an URL via return.
-
Mmm, you're welcome. If you need more help with array_push(), go here: http://php.net/manual/en/function.array-push.php
-
Functions shouldn't affect global variables. You can define the variables outside of the functions and pass a reference to the variables inside of the function.
-
difference between require_once(), require(), include()
Irate replied to matrixinfologics's topic in PHP Coding Help
require_once() requires a file to be loaded only once so that no redirect loops occur and, like require(), it requires the file referenced to exist, otherwise it throws a fatal error and the script breaks. include() and include_once() work analog to require_once() and require_once(), just that script parsing is not stopped if the file is not found (it'll display a warning E_NOTICE, though).- 2 replies
-
- differnce
- reqire_once()
-
(and 3 more)
Tagged with:
-
Try using a for loop. <?php $array1 = array(...); $array2 = array(...); for($i = 0; $i < 4; $i++) { array_push($array1[i], $array2[i]); return $array1; } ... ?>
-
Pretty straightforward, the URL you are redirecting to keeps redirecting itself to its URL. Look into how an URL is made and post again?
-
What part do you not understand about the jQuery and how do you think this could work with MySQL?
-
thatmsg = $("#msgdialog"); Right there. Edit: Sorry, didn't see the globally part.
-
Make of 2 regular expressions 1 regular expression
Irate replied to phpuser2013's topic in Regex Help
Why would you even need to have 2 regexps for that? You can test for two conditions with an if statement... -
Both options are possible as there is never only one solution to a problem. But I'm glad that you could be helped here.
-
Basically, the ternary operator is like an if ... else ... statement. $array['key'] ? echo "Array key exists." : echo "Array key does not exist."; could be written as if($array['key'){ echo "Array key exists."; } else { echo "Array key does not exist."; }
-
If you do not intend to place anything inbetween the <div>s, add a style attribute, set it to display: none; and change it at runtime with JavaScript if you need something displayed in it. That way you can be sure the document stays the same unless you want something to be displayed.
-
Oh, I'm just asking if you knew where it was saved. Is it a unique entry for each member? If so, you can easily select it with an SQL Query.