2,113 Posted Topics
Re: Be aware with this solution: a client could overwrite any index of the `$_SESSION` array through the `$_POST` keys. For example, if you set the *user id* and the *status* in the session, like this: $_SESSION['user_id'] = 34; $_SESSION['is_logged'] = 1; then a user can submit a form to your … | |
Re: If the are columns with the same name, for example `id`, when using the wildcard character the database will return error `1052`: * http://dev.mysql.com/doc/refman/5.6/en/error-messages-server.html#error_er_non_uniq_error Solution is to define each column: SELECT property.id, personal.id, spouse.id FROM property JOIN personal ON personal.id = property.id JOIN spouse ON spouse.id = property.id; As explained … | |
Re: The problem here is that you are defining the array of options for curl without including the POST data: CURLOPT_POSTFIELDS => $curl_data, `$curl_data` is not defined anywhere, and you're including the input in the url so this becomes a post request with an empty body and the variables in the … | |
Re: Follow these instructions: http://dev.mysql.com/doc/refman/5.6/en/time-zone-support.html But you should always save as UTC and then convert the _datetime_ to the client local timezone. | |
Re: Hi, what error do you get when you try the above commands? And have you tried to stop the service? For example: sudo service vsftpd stop sudo apt-get remove vsftpd | |
Re: The problem is given by the closing bracket `}` of the very first `IF` statement: if(isset($_GET['question'])){ $question = preg_replace('/[^0-9]/', "", $_GET['question']); $next = $question + 1; $prev = $question - 1; } // <-- this is missing | |
Re: Have you tried open source solutions? Here's a list: * http://en.wikipedia.org/wiki/Comparison_of_Internet_forum_software | |
Re: On/off status for what? The website? Then you can use **artisan** from the command console: php artisan down The website will go in maintenance mode. With `up` it will go back online. If you wish something different then, please, explain it better. | |
Re: It happens because you are defining these variables only when a POST request is submitted to the script, while on GET request (i.e. when you open the page) these variables are not defined. So, initizialize them on top of the script: <?php session_start(); $submitted = FALSE; $name = ''; $email … | |
Re: Follow this link http://windows.php.net/download/ You can choose the NTS (Non Thread Safe) version if IIS is serving PHP as fastcgi module, more information on http://php.iis.net/ | |
Re: This is defined by server configuration, if using Apache this can be declared also in the .htaccess context, for example: DirectoryIndex index.html index.php * http://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex | |
Re: **@Ine_1** Hello, in practice you have to escape the quotes of the html code. If you use double quotes then you can write: echo "<span class=\"smile\">hello</span>"; Notice how the class quotes are escaped by the backslash `\"`. This can be rewritten in many ways: echo "<span class='smile'>hello</span>"; echo '<span class="smile">hello</span>'; … | |
Re: If you use prepared statements then it's not a problem, create the list of queries: <?php return array( "query_cities" => "SELECT * FROM cities WHERE name = ?", "query_address" => "SELECT * FROM addresses a JOIN cities c ON c.id = a.city_id WHERE street_name = ? AND zipcode = ?", … | |
Re: There are few errors in the CSS, first at line `17` of the HTML page fix this: header h1 { font-size: 48px; } type="text/css"> By removing `type="text/css">`. Then inside the css file at line `79`: nav li:hover { background: blue; nav li:nth-child(even) a { color: red; } You are not … | |
Re: I don't understand: you're talking about the data you want to save into the `custreg` table? If yes, where are the form, the insert query and the table definition? | |
Re: Assign `height` and `width` to the **#banner-background**: #banner-background { width:100%; height:100px; background: url('/images/banner.jpg') no-repeat top left scroll; } Then, if you want, you can assign the background directly to the parent div of the inputs: <div id="banner-background"> <input type="text" class="form" name="email"> <input type="text" class="form" name="password"> </div> | |
Re: Maybe: $xor1 = gmp_init(md5('test'), 16); $xor2 = gmp_init(decbin(rand(0, 100)), 2); $xor3 = gmp_xor($xor1, $xor2); echo gmp_strval($xor3); ? | |
Re: **@Lokesh_4** open a new thread, explain the issue and show the code. | |
Re: Yup, use the Geocoding API, you can use cURL or simply `file_get_contents()`, an example: <?php # geocoding $api = 'YOUR_SERVER_API_KEY'; $url = 'https://maps.googleapis.com/maps/api/geocode/'; $format = 'json'; $paramenters = array( 'address' => $_GET['address_line'], 'key' => $api ); $submit = $url . $format . '?' . http_build_query($paramenters); $response = json_decode(file_get_contents($submit), true); print_r($response); … | |
![]() | Re: Hi! Define the namespace in **Spotify.php**: <?php namespace Foo\Bar\Baz; class Spotify { public function __construct() { echo "yes"; } } Then it should work fine. ![]() |
Re: The `real_escape_string` method is part of mysqli, so to use it append it to the database object: `$conn->real_escape_string($uname)`. But don't rely on this for security you have to validate the input, then sanitize and use prepared statements: $uname = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_SPECIAL_CHARS); $pword = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_SPECIAL_CHARS); $query = $mysqli->prepare("SELECT … | |
Re: > Cannot find column [year] Does the column `year` exists it the queried tables? Have you tried to perform the same queries directly in a MySQL client? | |
Re: `login1` is the **database** name or the **table** name, or both? Instead of: if(!$conn){ echo "Connection not established"; } Do: if ($conn->connect_errno) { printf("Connect failed: %s\n", $conn->connect_error); exit(); } As suggested in the [documentation](http://php.net/manual/en/mysqli.connect-error.php). And return the error here. | |
Re: You could use the **DOMDocument** class: * http://php.net/manual/en/class.domdocument.php An example: <?php $file = "./test.html"; $imgs = glob('../images/*.jpg'); $dom = new DOMDocument(); $dom->loadHTMLFile($file); $container = $dom->getElementByID("container"); foreach($imgs as $img) { $basename = pathinfo($img, PATHINFO_BASENAME); $tag = $dom->createElement("img"); $tag->setAttribute('src', '/images/'.$basename); $container->appendChild($tag); $tag = null; } $dom->saveHTMLFile($file); By using the method `getElementByID()` you … | |
Re: Can you post the exact error? Undefined index regarding which array: $_GET, $_POST, $row? ![]() | |
Re: In order to perform multiple updates you have to submit the fields of the form as array groups, for example: <form action="" method="post"> <table> <thead> <tr> <th>ID</th> <th>Name</th> <th>Size</th> <th>Qty</th> <th>Price</th> </tr> <tbody> <tr> <!-- group 0 --> <td><input type="text" readonly name="product[0][id]" value="23" /></td> <td><input type="text" name="product[0][name]" /></td> <td><input type="text" … | |
Re: Hi Dani, this is used in Windows 8.1 with IE 11 to add tiles to the desktop: * [http://msdn.microsoft.com/en-us/library/ie/gg491731(v=vs.85).aspx](http://msdn.microsoft.com/en-us/library/ie/gg491731(v=vs.85).aspx) | |
Re: From `require` documentation: > require is identical to include except upon failure it will also produce a fatal E_COMPILE_ERROR level error. In other words, it will halt the script whereas include only emits a warning (E_WARNING) which allows the script to continue. Links: * http://php.net/manual/en/function.require.php * http://php.net/manual/en/function.include.php Please, next time … | |
Re: Try also: <?php $input = "ls -lh"; $command = escapeshellcmd($input); $command .= '^M'; shell_exec("screen -X stuff '$command'"); If the "stuff" screen is attached you should see the execution of the command. But keep in mind this is really unsafe action, depending on configuration it can run with webserver privileges. It … | |
Re: With `.reload()`, when possible, you can try to force the reload from the browser cache: > Reloads the resource from the current URL. Its optional unique parameter is a Boolean, which, when it is true, causes the page to always be reloaded from the server. If it is false or … | |
Re: Add one of the table aliases to the column, so: WHERE br.patron_ID = '$patron_ID'"; The error happens because your using two tables with the same column name. | |
Re: **@vizz** hi, you should pay the license and respect their copyright: http://www.menucool.com/ otherwise switch to the free version. | |
Re: Are you appending the query string to the form used to submit the new query? Can you show how you apply the pagination class in your **results** script? | |
Re: As suggested by the error message: check the error log for Apache. If you have doubts paste or attach a file with the contents here. | |
Re: You could also try with Composer: create a private repository and use a php/batch script to run the install or update process for your application, the only requirement for the clients it to have the composer binary installed. Read: https://getcomposer.org/doc/05-repositories.md#hosting-your-own The same can be done with PEAR, but some of … | |
Re: > PHP-Nuke 8.3.2 fix some security issues and become compatible with PHP 5.3. By the way, this is not even completely true, most of their filters are based on the **ereg** functions, which are deprecated since 5.3 and vulnerable to the **null byte** attack. For example check their validate mail … | |
Re: Try with `preg_match()`: function validateScore($score) { $score = trim($score); $pattern = '/^\d{1,2}[\s]?-[\s]?\d{1,2}$/'; return preg_match($pattern, $score) == 1 ? true : false; } Valid inputs are: var_dump(validateScore('2-0')); var_dump(validateScore('2- 0')); var_dump(validateScore('2 -0')); var_dump(validateScore('2 - 0')); Spaces around the string are removed by `trim()`. To validate only those without spaces between the dash … | |
Re: Check the default index for XSP2, inside `/usr/share/asp.net-demos/` there is an `index.aspx` and two directories `1.1` and `2.0`. So, as test, you can try to call them directly: * `http://127.0.0.1:8080/index.aspx` * `http://127.0.0.1:8080/2.0/index.aspx` | |
Re: You can use PHP SDK from Facebook, check here: * https://developers.facebook.com/docs/graph-api/reference/v2.1/user/feed * https://developers.facebook.com/docs/reference/php/4.0.0 | |
Re: You can use **mysqldump**: mysqldump -uUSER -pPASSWORD DATABASE > backup.sql Change `USER`, `PASSWORD` and `DATABASE` to match yours, you can add `--routines` to backup user defined functions and procedures. More information here: * http://dev.mysql.com/doc/refman/5.6/en/mysqldump.html | |
Re: Add the brackets to extend the statement, otherwise the `IF` condition will apply only to `$IC2= $_SESSION['IC2'];` because it finds the `;` character, so: if ( isset($_POST['BMK81A']) && isset($_POST['BMK81']) && isset($_POST['DL3']) && isset($_POST['DL2']) && isset($_POST['DL1']) && isset($_POST['S1']) && isset($_POST['S2']) && isset($_POST['S3']) && isset($_POST['S4']) && isset($_POST['S5']) && isset($_POST['S6']) && isset($_POST['S7']) && … | |
Re: Check this link: - https://developers.google.com/maps/articles/phpsqlsearch_v3#findnearsql In practice you have to save the current position for each user and calculate the distance through a database query. **Note** MySQL supports spatial indexes only with MyISAM and InnoDB engines, the latter since `5.7.5`. But you may want to consider [PostGIS](http://postgis.net/) also. | |
Re: You have to set the validation rule in the `submitform()` method: $this->load->library('form_validation'); $this->form_validation->set_rules('frmDt', 'Date', 'callback__checkdate'); Then you have to add an argument to the `_checkdate()` method because `set_rules()` will submit the value of the field specified in his first argument: function _checkdate($date) { $format = 'Y-m-d H:i:s'; # Must match … | |
Re: You have to initialize the variables: if `$submit` is not set then `$sql` is not initialized and the query will fail. Also for the query you can use the `column BETWEEN value AND value` condition. So change your code to: $submit = $_POST['submit']; # all code under this condition if($submit) … | |
Re: Can you show the table schema and an example of the query you want to perform? Have you tried the `column BETWEEN min AND max` statement? Are you saving the timezone differences for each user? Documentation: * http://dev.mysql.com/doc/refman/5.6/en/comparison-operators.html#operator_between | |
Re: It happens because the url opening the page does not set the **id** parameter: yourpage.php?id=123 To prevent this error you can add a check. `array_key_exists` will not consider if id is empty or not `?id=` vs `?id=21`, but only if the key exists: if( ! array_key_exists('id', $_GET)) { die('Error: missing … | |
Re: It happens because this is the data directory used by the server. If you want to change it then modify the `datadir` value in the **my.cnf** file, and then restart MySQL. **Note apart** I don't know how it works with Windows permissions, but in linux the new data directory **must** … | |
Re: Chech the version of the remote PHP. DateTime::diff requires version 5.3.*+ * http://php.net/manual/en/datetime.diff.php | |
Re: You can use `DateTime::sub()`: <?php $dt = new DateTime('2014-08-31 23:06:00'); $dt->sub(new DateInterval('P30D')); echo $dt->format('Y-m-d G:i:s'); Docs: * http://php.net/manual/en/datetime.sub.php * http://php.net/manual/en/dateinterval.construct.php * http://en.wikipedia.org/wiki/ISO_8601#Durations | |
Re: It happens because MySQL doesn't seem to really support ISO 8601, but the date is parsed and inserted if the server is not in strict mode, it will generate only a warning that looks like this: show warnings\G *************************** 1. row *************************** Level: Warning Code: 1292 Message: Truncated incorrect datetime … |
The End.