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

How to add and use multiple actions into Apigilities RPC Generated Controller
Solution 1 Try register aliases on controllers key to your controller and register each alias on zf-rpc config. Something like that: 'controllers' => array( 'factories' => array( 'TestAPI\V1\Rpc\Test\Controller' => 'TestAPI\V1\Rpc\Test\TestControllerFactory', ), 'aliases' => array( 'TestAPI\V1\Rpc\Test2\Controller' => 'TestAPI\V1\Rpc\Test\Controller',

Categories : PHP

SELECT and lock a row and then UPDATE
What you need to do is add some kind of lock here to prevent race conditions like the one you've created: UPDATE persons SET processing=1 WHERE id=:id AND processing=0 That will avoid double-locking it. To improve this even more, create a lock column you can use for claiming: UPDATE persons SET processing=:processing_uuid WHERE processing IS NULL LIMIT 1 This requires a VARCHAR, index

Categories : PHP

HTTP code 302 error when requesting URL vie PHP Curl
May be script use redirect for check cookies or may be for other features. You can see redirect URL in $s output. Just insert echo $s; to end of your script. Also you can set CURLOPT_FOLLOWLOCATION and then curl will fllow by redirect in automatic mode.

Categories : PHP

Laravel's URL::previous() not working properly
URL::previous uses the header information stored within referrer, meaning the page that brought you to the page you are currently on will be the page you go back to. Not only this, the referrer header is not always filled, so can be empty, which will in-turn lead to errors. My solution is to come away from using this. Either redirect back using a route of your particular choice i.e. explicit

Categories : PHP

Call to undefined method IlluminateDatabaseEloquentCollection::whereHas() in laravel
You're calling get too early and this is running the query before you wanted to. Moving it after the foreach loop solves it: $usersCount = User::where('activated', '=', 1) ->where('group_id', '=', 1) ->where('availability_date', '<=', $opportunity_date); foreach ($locations_array_result as $param) { $usersCount = $usersCount->whereHas('desiredL

Categories : PHP

How to access key/value of the array in Laravel 4?
The short answer is you can't, or at least not in the way you're expecting. When an item is selected and posted back to you, all that is sent back is the value of the <option> element, not it's content. Note that: {{ Form::select('size', array('L' => 'Large', 'S' => 'Small'), 'S') }} produces HTML a little like this: <select name="size"> <option value="L">Large<

Categories : PHP

Why does my Authorisation header disappear when using stream_get_contents?
The 'header' key in your context array must be a string. See the example in PHP docs here $method = 'GET'; $contextOptions = array( 'http' => array( 'method' => $method, 'header' => array( 'X-Forwarded-For: ' . $_SERVER['REMOTE_ADDR'], 'Authorization: Basic ' . base64_encode($apiKey . ':' . $flags), ), ) ); if ('POST' === $m

Categories : PHP

undefined ssh2 in php with apache on debian
I use phpseclib's libssh2-compatibility-layer to avoid having to install libssh2. You can use all the libssh2 functions without having it installed thanks to the use of phpseclib. If you're writing your application from scratch maybe try just using phpseclib from the onset intsead of libssh2.

Categories : PHP

php mysqli_insert_id() error
Try looking at the example supplied by PHP.net: <?php $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } $mysqli->query("CREATE TABLE myCity LIKE City"); $query = "INSERT INTO myCity VALUES (NULL, 'Stuttgart', 'DEU', 'Stuttgart', 617000)"; $mysq

Categories : PHP

How to filter for php error in ajax response?
You don't really. You could expect a certain response (the correct one) and if it is anything other than that. An error has occurred. Most frameworks will set the HTTP header to 500 if a non-compile error happens. So you could check for that. But if a compilation error occurs that would not work. Of course in production you shouldn't have compile time errors.

Categories : PHP

ZEND framework Google Calendar Shutdown - php web app
you can't use Zend anymore to list, add, delete event. You have to use google api v3. Here is an example of class you can use to manage events: Authentification Zend Gdata (403 forbidden)

Categories : PHP

Rewrite rule in .htaccess does not work as requested
It should be like this , RewriteEngine On RewriteRule de/spieler-([^-]*)-([^-]*)-([^-]*).html$ player.php?Name=$1&Surname=$2&id=$3 [L,NC] Correction: ^ was the problem & I removed '/' slash in front of player.php

Categories : PHP

Check and Merging two array
I think what you want is something like this Array( [0] => array( "title" => "Home" ), [1] => array( "title" => "About", "sub_page" => array( [0] => "Our Work" ) ), [2] => array( "title" => "Contact" ) ) Above result can be achieved by doing this $pageArray = array(); foreach($result as $row){

Categories : PHP

PHP: Best way to Generate an unique numeric ID
Nothing can guarantee 100% uniqueness. You need to know uniqueness comparing with what do you need. And use any algorythm plus check each value in list of all used values. In the world of programming what you need is called pseudo random number. So it's name actually explains what I mean.

Categories : PHP

CSV output is dublicated
That's becouse when you retrieve the data it gives you a mix between an associative array and a normal array More info. So your $row var is something like: array( [0]=>4cd87b00dddca780fcaf66d0108b25f6 [onlineId]=>4cd87b00dddca780fcaf66d0108b25f6 [1]=>1 [paramId]=>1 [2]=>11 [paramValue]=>11 ) So your solution could be: while ($row = $statement->fetch()) {

Categories : PHP

From PHP to Play Framework with Scala server
For the query string and path info I found in request.headers which returns a map where you can find different mappings. Query string is also directly returned by request.queryString. However the other two I still could not find

Categories : PHP

php and mysql dynamic breadcrumps
u have to use recursive function. means check for ex: function show_breadcumb($cat_id) { $q = mysqli_query($link, "SELECT * FROM foods WHERE cat_id = $cat_id"); while($r = mysqli_fetch_assoc($q)) { $name = $r['cat_name']; $string.= $name .">".$string } //check if this category has any parent again call this fucntion if( has parent ) { show_breadcumb($cat_id) } els

Categories : PHP

Newline at top of PHP output
Anyone got a idea that I haven't tried yet? Well, as we cannot see the code, and while this is not an ideal or robust testing scenario, in your case this might be useful. In the files where you think the error may be, starting with the first file which runs, add something like exit('Here');. Then run the code and see if the new line is there before the exit message, if not the issue is

Categories : PHP

Retain dropdown box selection after submit - PHP
The problem is with your HTML. The select tag does not have a value attribute, you need to set selected on the appropriate option element. Similarly radio buttons use the attribute checked="checked".

Categories : PHP

PHP cURL Proxy Inquiry
There is an option called CURLOPT_COOKIEJAR where you can set the file that contains the cookie: curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); Once you get the cookie you have to use the same $ch variable to keep the connection. You can found a complete example of cURL usage here: http://blog.binacube.com/2014/08/complete-curl-example-login-proxy-and.html

Categories : PHP




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