w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
  Home » PHP » Page 1
Using SHA1 to verify user's email - PHP
Sufficiently close to zero to ignore. However, you should additionally add some randomness using mt_rand. The exact time on your server is easy to guess, and email and UID are known to malicious users.

Categories : PHP

Check if todays date is between two other dates
You can stick with timestamps. Don't convert back to dates. You are making invalid comparisons such as the assumption that 30-01 is less than 28-02. The computer will compare the very first 3 to the 2 and tell you that 30-01 is CORRECTLY greater than 28-02. So... $startSummer = mktime(0,0,0, 6, 1, 2000); // The year doesn't matter according to your code $endSummer = mktime(0,0,0, 8, 31, 2000);

Categories : PHP

Look for phrase in string, and also look for wildcards after the phrase
You should use regex: (getting-started)$ // gets the phrase at the end of the string (getting-started)(.*) // gets the phrase + anything else You could combine this with preg_match()

Categories : PHP

Deploy application on Amazon AWS using BeanStalk API and LoadBalancing API
Amazon Elastic Beanstalk for PHP is somehow documented here. As for your setup, here are the basic steps: 1. create an RDS instance manually. don't set Elastic Beanstalk do it for you as it poorly manages it. in the Beanstalk setup wizard make sure you use your preset RDS and not let the wizard create one. 2. start the Elastic Beanstalk wizard, define it as a web server and ensure the Environme

Categories : PHP

php password functions not working
Might want to read the README This library requires PHP >= 5.3.7 OR a version that has the $2y fix backported into it (such as RedHat provides).

Categories : PHP

PHP : How to customing URL
PHP variables will not be parsed inside of a single quoted string. You should use "admin/user/$user_id" if you want the variable's value to be used. So you could write it like this: $response = $client->delete("admin/user/$user_id",[ Or simply by concatenating the string and user id variable using .: $response = $client->delete('admin/user/'.$user_id,[

Categories : PHP

How use HWIOAuthBundle Symfony
You can just create a link to any of the "login-check" pages and that route should handle the authentication like... <a href="{{ path('facebook_login') }}">Login Using Facebook</a>

Categories : PHP

Insert stmt with a Select and additional Params
It is unnecessary. Just use insert . . . select: INSERT INTO tblquestions(userID, questionText, questionAnswer) Select userID, ?, ? FROM tblusers WHERE userEmail = (?);

Categories : PHP

Selecting correct radio button in PHP from SQL query
Your PHP firstly get which one you want to be checked then do this lets say you have it as "pre" $radio = "pre"; then $checked[$radio] = "checked"; Your HTML <label for="arrival">When will you arrive?</label><br /> <input type="radio" id="arrival1" name="arrival" value="pre" <?=(isset($checked['pre']))?$checked['pre']:"";>/>Pre-KG<br /> <input ty

Categories : PHP

Facebook API Real Time update v2.2 read update
According to the Facebook documentation [link]: Note that real-time updates only indicate that a particular field has changed, they do not include the value of those fields. They should be used only to indicate when a new Graph API request to that field needs to be made. So, you don't get the updated data instead you get the updated feild name. On receiving an update, you should extract the chang

Categories : PHP

How can i read the amount result of a specific column within a line/row? Mysql + php
If I understand your question correctly: SELECT SUM(status) FROM user_registration Here more info on MySQL aggregate functions: http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html P. S. As Jay suggested in comments, consider moving away from mysql_* functions.

Categories : PHP

Display cost of product description to work on every line
You don't need to use a variable class name. Just use <td width=60px><label class="line_item"></label></td> and then $container.find(".line_item").html(data); in your jquery success. Let me know if this not what you want, your question is a little confusing (do you want all rows to update or just the changed row? This should only change the changed row). Edit Okay,

Categories : PHP

PHP OOP - how to call the overriding method of the child class
I am knowing this is not an answer, but i want to make clear, what OP asking, and want to formatting the code. Class A { public function A1() { echo "Class A, method A1 <br />"; $this->A2(); } public function A2() { echo "Class A, method A2 <br />"; } } Class B extends A { public function A2() { echo "Class B, method A2 <b

Categories : PHP

Laravel URL Generation Not Including Parameters
The problem is that you don't have names/aliases for the routes so it's defaulting to the first one it comes across. Consider this an alternate route structure: Route::group(array('domain' => '{subdomain}.domain.com'), function() { Route::get('profile/{id}/{name}', [ 'as' => 'tenant.profile.index', 'uses' => 'ProfileController@index' ]); }); Route::get('profile/

Categories : PHP

Symfony2 Form Component mutable Form Data for Survey
Use the power of Listeners. You can use almost the same flow that CollectionType uses with ResizeListener. public function preSetData(FormEvent $event) { $form = $event->getForm(); $data = $event->getData(); ... foreach ($data as $name => $value) { $form->add($name, $this->getTypeByClass($value), array_replace(array( 'property_path' => '['.$n

Categories : PHP

Folder delete error - can't delete folders extracted from zip
You'll have to chmod everything in that directory. try this $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($pathname)); $filemode = "0777"; // Set the permission // Foreach item found set the permissions foreach($iterator as $item) { chmod($item, $filemode); } if you're going to do rmdir($dirPath); be sure to remove all of the files from the directory first, oth

Categories : PHP

how to create a cookie in php to exist in a different domain
I figured it out. My first code with just the path was correct. The issue was that I was in the Chrome incognito mode. I knew that and I had assumed that all tabs in incognito mode would be part of the same session and be able to pass cookies, but I guess not.

Categories : PHP

Yii Framework 2.0 Uploading Files Error finfo_file(): failed to open stream: No such file or directory
I was having the exact same problem, and I solved it by calling $model->save(); before $model->file->saveAs() I don't know how your model looks like, but if you are just saving the actual file on the server, and only the path to the image in the DB, it should work. I think what happens is that when you call file->saveAs() before model->save, the model validation fails because 'f

Categories : PHP

Cannot connect to remote MSSQL from OSX Apache/PHP
As soon as I posted this I found where the issue is coming from, my PHP installation cannot find the FREETDS config file, to work around this I have set: putenv('FREETDSCONF=/usr/local/etc/freetds.conf'); I need to find a more permanent work around for this (possibly just rebuild PHP) but it is working for now anyway. Many thanks

Categories : PHP

Laravel 4 - object retrieval from database
The problem is that you are saving (and overwriting) your data on position $category->depth = '0' of your array $categories Not familiar with Laravel, but this should do the trick: public function getIndex() { $categories = array(); foreach(Category::all() as $category) { //If depth equals zero if ($category->depth == 0) { //append $category->name to

Categories : PHP

Laravel PHP: Creating Data with unchecked checkbox results in 'cannot be null' error
$newVideo->video_active = Input::get('video_active'); Input::get('video_active'); will return null if it hasn't been defined. Use a ternary statement like this $newVideo->video_active = (Input::get('video_active') !== null) ? Input::get('video_active') : ""; this is equivalent to if(Input::get('video_active') !== null) { $newVideo->video_active = Input::get('video_active'); } els

Categories : PHP

PHP preg_match_all capture all patterns at front of string not mid string
How about: $str = 'AB: CD:DEF: HIJ99:message packet no capture or: this either'; preg_match_all('/(?<![^:]{7})([0-9a-zA-Z]{2,5}):/', $str, $m); print_r($m); Output: Array ( [0] => Array ( [0] => AB: [1] => CD: [2] => DEF: [3] => HIJ99: ) [1] => Array ( [0] => AB [1]

Categories : PHP

Flatten 2D Array Into Separate Indexed Arrays
I believe that your $total array is multi-dimensional array with numeric indexed. So yo can try like this $count = cartesian($total[0], $total[1], $total[2]);

Categories : PHP

Cake PHP Plugin Call Routing Problems
I found the following solution: Renamed the Controller ... plugin_one/admin => plugin_one/poAdmin plugin_two/admin => plugin_two/ptAdmin etc ... Now it works ... seems like CakePHP does not like multiple same namend controllers within different plugins

Categories : PHP

Error in Saving Lat/Long
Add quotes around your $_POST keys. $fname = $_POST ["fname"]; $lname = $_POST ["lname"]; If there are no single or double quotes, php recognize fname and lname as constants, what you definitely do not has. NOTE: Do not use mysql functions they are deprecated. Use mysqli or PDO instead. Avoid sql injection by escaping your variables, or use prepared statements.

Categories : PHP

PHP Query To Filter Many-To-Many MySQL
I think you want this query SELECT Names FROM all_uk INNER JOIN cat_uk ON all_uk.Ref = cat_uk.Ref INNER JOIN res_uk ON all_uk.Ref = res_uk.Ref WHERE (cat_uk.Cat_Ref IN (25, 35)) GROUP BY Names HAVING SUM(res_uk.Res_Ref = 1)>0 AND SUM(res_uk.Res_Ref = 2)>0

Categories : PHP

How to make the same database query on two different databases?
You should make sure the resource is updated and used: $link = mysql_connect(HOST,USER,PASSWORD); mysql_select_db(DB_1, $link); mysql_query("some query", $link); mysql_select_db(DB_2, $link); mysql_query("some query", $link);

Categories : PHP

submitting text with Yii
First of all, the below code always submits form to Create page" echo CHtml::button('submit',array('submit' => 'Create')); As Yii's official document says: submit: string, specifies the URL to submit to. If the current element has a parent form, that form will be submitted, and if 'submit' is non-empty its value will replace the form's URL. If there is no parent form the data listed in '

Categories : PHP

How can I verify success status of a thread in PHP?
OK, I'll attempt to steer you in the right direction. From what I know about posix threads, the pthread_join() suspends the calling context until the referenced thread terminates. Once that's done, any resources allocated to that thread are freed - anyone with better understanding, please correct me here. Now, that's opposite of what you want. What you want, also correct me if I'm wrong, is tha

Categories : PHP

How to update a VARCHAR value with a simple increment using MySQL?
You are using the MySQL variable as a column name in your UPDATE query. Before: SET @rownum:=0; UPDATE wp_posts SET post_name = @rownum:=rownum+1 WHERE post_status="publish" AND post_type="post" ORDER BY post_date After (see line 3): SET @rownum:=0; UPDATE wp_posts SET post_name = @rownum:=@rownum+1 WHERE post_status="publish" AND post_type="post" ORDER BY post_date

Categories : PHP

PHP - output form text as .txt file using AJAX
Make sure you don't load the code via AJAX, but via a normal request. In your case, the easiest way to achieve this, is to add a target to the form you are using to post the data like so: <form method="post" action="script.php" target="_blank"> %%_inputelements_and_submitbutton_%% </form>

Categories : PHP

SonataAdminBundle resource not found
ok weird. when I installed the sonataUserBundle it seems to have fixed this issue. part of that process was to manually install doctrineormadminbundle with composer rather than putting the reference in the .json file. Im presuming that was what fixed it.

Categories : PHP

writing with variables in select statement does not work?
$sql = "SELECT DISTINCT cat2" . " FROM products" . " WHERE cat1 = '" . mysqli_real_escape_string($connection, $cat1) . "'"; Add single quotes around your string, and escape it to avoid sql injection.

Categories : PHP

json to php array cdnjs
This is what you are doing: Download a string of JSON Encode that string into JSON (you now have a JSON string containing a JSON object) Decode that JSON back to a string of JSON Print the string You need to skip step 2.

Categories : PHP

PHP if condition doesn't work for urls matching
if($referby<>$link1 || $referby<>$link2) means if $referby does not match $link1 or $link2, proceed. Since it can't match both it always evaluates to true. You need to use && (and): if($referby != $link1 && $referby != $link2)

Categories : PHP

Wordpress Visibility: Password Protected pages (case insensitive?)
The quick solution for this is to install a plugin: https://wordpress.org/plugins/case-insensitive-passwords/installation/ This one seems to do the trick and says it's compatible up to version 4.0 I've also found this one here Edit showing the actual Code (confirmed working, just not for the password protected page because it uses other function http://codex.wordpress.org/Function_Reference/po

Categories : PHP

yii2 ActiveDataProvider in combination with ActiveForm?
There is something wrong here, which is: $disease = Disease::find()->where(['id'=>1]); That should be: $disease = Disease::find()->where(['id'=>1])->one(); To know why you get this error: You are passing ActiveQuery to your ActiveForm by $disease = Disease::find()->where(['id'=>1]) which is wrong. ActiveForm does not accept ActiveQuery.

Categories : PHP

PHP in page calculations
This is usually achieved with AJAX, to resume this for you, AJAX sends data to server and recieve responses from server without refreshing page. You need to learn about it to achiev this. Take look at some of this links xmlHttpRequest jQuery ajax

Categories : PHP

Display different content using different access level
You could use an || (or) operator: <?php if ($_SESSION['MM_UserGroup'] == 'j' || $_SESSION['MM_UserGroup'] == 's' || $_SESSION['MM_UserGroup'] == 'g' || $_SESSION['MM_UserGroup'] == 'h') {?>

Categories : PHP




© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.