w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » PHP » Page 2
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

Submit form to action php file
A couple of things: you're using $_GET instead of $_POST isset($_POST['submit']) is not a good check, not every browser will send the submit button in its request. (Apart from the fact that you haven't even named the submit button, so it wouldn't come through in any browser, as it stands now.) it's better to use: Code: if($_SERVER['REQUEST_METHOD'] == 'POST') { }

Categories : PHP

storing file path in mysql database automatically
Php has a built in function to obtain the information stored in an mp3 ID3 tag. However as I mentioned in my comment above you will have to mitigate the situation where the information is not contained within the ID3 tag, unless of course you already know the information will always be in the tag. PHP API FOR id3_get_tag()

Categories : PHP

echo an array data from json decode
in the json you posted above 'lastChangedDate' is null means you can't access it with $input['Servers']['lastChangedDate']['ServersList'][0]['online']; First you should find why lastChangedDate is null. $input['Servers']['lastChangedDate']['ServersList'][0]['online']; The bold text is where the access conflict begins. PHP should also output you an error like "Undefined index: ServerList" so yo

Categories : PHP

PHP script suddenly outputting memory size of X bytes exhausted
This is something you wouldn't wanna use in a production environment, but usually does the trick for me for memory consuming one time operations. ini_set('max_execution_time', -1); ini_set("memory_limit",-1 );

Categories : PHP

Backbone PUT requests and Laravel
In order to get Laravel4 working with Backbone, you should create a REST interface with the back end, implementing Resourceful controllers that use the RESTful methods as prescribed by Laravel. In the front end, you should create Backbone models to store the state of the data. A PUT request occurs when you define an id on a Backbone model before you persist it to the server. Therefore I woul

Categories : PHP

password_verify hash not matching password
the hash generated is different every time pass plain text to the password_verify() function... see below $originalPassword = password_hash("THE_PASSWORD", PASSWORD_DEFAULT); // This will produce something like (taken form above) $2y$10$tolDQdeTQrTio8IJ0Wi9AuHN5Km28pSB5kUh5qfkdkOsDXP295H1K // When verifying this if(password_verify("THE_PASSWORD", $passwordFromDatabase['password'])){ echo "Suc

Categories : PHP

Result an array with the duration every half hour
$hourRange = range(strtotime('00:00'), strtotime('23:50'), 10 * 60); foreach($hourRange as $time){ $date = date("H:i",$time); echo $date . " "; } https://gist.github.com/adililhan/cc172f0eed55f6968b10

Categories : PHP

Jquery with PHP search function
Here is your issue: if (isset($_POST['name']) && isset($_POST['game'])) { All you are posting is name not game. $.post('name.php', {name: name}, function(data) {

Categories : PHP

Wordpress - Get position in query
You could use $paged to modify the $count...Something like: $current_index = $my_query->current_post; $count = ( intval($paged) * 10 - 10 ) + intval( $current_index ); echo $count; So, for example, if you're on page 2, $paged == 2. So the math would work out like the following (for the first post on the page): $count = ( 2 * 10 - 10 ) + ( 1 ); $count = 10 + 1; $count = 11;

Categories : PHP

Adding salt to hash and generating url...?
You could do a salt by doing something like $pass = md5($pass2 . $salt) However, if you want to actually do a secure hash, a function like password_hash is more suitable. Note that a hash is not just a catch-all security method. Depending on what your use-case is, this may not be very secure. It's worthwhile to look into potential security vectors before using hashes.

Categories : PHP

How to organize MVC architecture in PHP
There are few ways of doing it. You can use singleton design pattern to have one instance of the class making the connection to the database and then reuse it. http://en.wikipedia.org/wiki/Singleton_pattern Here is an example of a wrapper around PDO class to make it a singleton: http://tonylandis.com/php/php5-pdo-singleton-class/ You can also make a persistent connection in PDO (which is a bet

Categories : PHP

Smarty - How to add values from my form to mysql query?
With $smarty.get.city. If you are using post method, then $smarty.post.city. There is nothing to do with smarty. $sql = "SELECT * FROM table" . " WHERE city='" . $smarty.get.city . "'" . " AND date_start='" . $smarty.get.start_date . "'"; NOTE: Avoid sql injection by escaping your variables. See this: http://www.smarty.net/forums/viewtopic.php?p=75542 But i suggest you to do it on the PHP si

Categories : PHP

Magento doesn't index my product
Have you tried to set website of the product: $product->setWebsiteIds(array(1)) //website ID or in such way: $product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));

Categories : PHP

PHP - Building a Learderboard from MySQL data
SELECT ROUND(SUM(d.passed) / COUNT(*) * 100, 2) AS average, SUM(d.score) AS score, COUNT(*) AS total FROM user AS u INNER JOIN data AS d ON d.user_id = u.id GROUP BY u.id

Categories : PHP

How can I make a username change and also update the session?
Maybe because you get variable $logged_in and try to put back another variable with name "username". If i right understand your problem you need save logged_in: $username['name'] = $name; $this->session->unset_userdata('logged_in'); $this->session->set_userdata('logged_in',$username);

Categories : PHP

Log in script shows blank page
Use an IDE not only an Editor! Using my IDE it showed me an error right away and it was quite easy to fix afterwards: <?php $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $con = mysql_connect("localhost","root","root"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("register", $con); $que

Categories : PHP

Retrive information from list associative array in php
while($row = mysqli_fetch_row($result)) { list($id[$i],$user_name[$i],$user_pass[$i++])=$row; } ... for($i = 1; $i < count($id) + 1; $i++) { echo " <tr> " . " <td>".$id[$i]."</td> ". " <td>".$user_name[$i]."</td> ". " <td>".$user_pass[($i - 1)]."</td> ". " </tr> "; }

Categories : PHP

Send form disabled fields values to server
Its true that readonly attribute takes input from calendar.I think it will be nice if you put disabled attribute but when you will click on submit button that time you can change attribute to readonly using javascript .

Categories : PHP

Wilcard subdomain based session on multi-tenant laravel application
There are two options really. Firstly, you can hook into the start of the boot process in the application and overwrite the session.domain config option at runtime. You'd basically want an early stage process to identify the tenant for the current subdomain and the change the setting like so: Config::set('session.domain', $tenant->domain . '.site.com'); Just as further more, you can use the

Categories : PHP

Find the source of spam-script
I think, the mal-script here, is not in the usual .pl/.cgi/.fcgi/.fpl extension form, but still executing on system level as a cgi script. You need to check Apache Handlers/Apache MIME types, to see what other extensions are being run as cgi script. Once you narrow down on that, a simple grep should work.

Categories : PHP




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