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

Changing " to ' in PHP - HTML Form
There's one really really simple solution to this: use HTML5 placeholders: <input type="text" name="Name" placeholder="Name"> (This will automatically be a lighter color than the original, so the style attribute is not required here) This is supported by all modern browsers, as seen here. Only IE versions 9 and lower don't support this, and those browsers only have 5% of all browser usag

Categories : PHP

PHP ZF2 - multiple sites with separate public folders
You can have as many public folder as you want. Just put in index.php valid include of zf2 core and everything should work without any special modifications (what module to display can be specified by domain path or via global configuration you will put inside index.php). Still I think is perfectly fine to have one public folder and change active modul per domain, also use some asset manager with

Categories : PHP

Laravel:how can I pass a variable from a controller to another?
There are many ways to share variables across controllers: If you share variables across views just like you did, simple use the variable $milite in other controllers. It should be just fine. You may define a static variable in your base class so that the variable could be used among all classes that extend base class. In the constructor of AgendaController, just pass firefighters'agenda as a pa

Categories : PHP

bindParam with foreach strange results
You are missing the data type , Correct format for PDOStatement::bindParam, should be like this $sth->bindParam(':calories', $calories, PDO::PARAM_INT); //note PDO::PARAM_INT here EG, $sql = "INSERT INTO movies(filmName, filmDescription, filmImage, filmPrice, filmReview) VALUES ( :filmName, :filmDescription,

Categories : PHP

Laravel using WHERE in eloquent ORM
I may be wrong. I was un-aware of magic query builder setup. That is a custom query scope. IE: A post model with a query scope to get all posts with 'status' = published. class Post extends Eloquent { /** * Get all posts with 'status' published * * @param IlluminateDatabaseQueryBuilder $query * @return Builder $query */ public function scopePublished(Builder $q

Categories : PHP

Htaccess redirect query string + force redirect
You can use this rule that will support query parameters in any order: RewriteEngine On RewriteBase / RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteCond %{QUERY_STRING} (?:^|&)lang=([^&]*) RewriteCond %1::%{QUERY_STRING} (.*?)::(?:|.*&)p=([^&]*) RewriteRule ^(index.php)?$ /%1/%2? [L,NC,R=302] RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-z]+)/(w+)/?$ index.php?lang=$1&

Categories : PHP

Plugin for editable table list
You can try with this one: http://www.datatables.net/ If you could have more specifications please update your question and I'll be glad to update this answer.

Categories : PHP

How to customize comment functionality in wordpress?
Are you try to automatically approve every comment without moderating them? If so just uncheck the following settings under Settings > Discussion Comment must be manually approved Comment author must have a previously approved comment

Categories : PHP

Getting Fatal Error: Call to undefined method
You execute the function get_user_function instead of using the variable $get_user_function. Change: $query = $this->Users_model->get_user_function($login); Into: $query = $this->Users_model->$get_user_function($login);

Categories : PHP

Custom template for OpenCart
You could create an information page via Admin > Catalog > Information. However, you wouldn't be able to include any PHP. To create a new template you need to add a few files to your project. OpenCart is based on MVC architecture. If you aren't familiar with MVC visit this page. http://docs.opencart.com/introduction-to-mvc-l Controller: Create a file named calculator.php and add it to catalog

Categories : PHP

Unexpected token D
Thats not a JSON String. You should inform about JSON http://en.wikipedia.org/wiki/JSON Return a JSON string from your server. With PHP you can use json_encode to encode an array to a json string.

Categories : PHP

how to pass php value as parameter in anchor tag href
Just change: echo "<td align=center width=100><a href='client_details.php?id=".echo $id."'>Edit</a></td><td><a href=''>Delete</a></td>"; To: echo "<td align=center width=100><a href='client_details.php?id=".$id."'>Edit</a></td><td><a href=''>Delete</a></td>"; Because you already used the echo. You

Categories : PHP

Line break not working when concatenating strings
will only be visible in the source as a newline. Use <br /> in stead, or use nl2br() on your $row ['technischgereed'] when echoing it out to convert your newline characters to <br />.

Categories : PHP

PHP Form with only E-mail field won't send, while full form works fine
No 2 fields in the same page should have the same name and id. Try giving full url for form action attribute,ie with site url ex site_url/page. <fieldset> <form class="subscriptionForm" method="post" action="mail.php"> <input name="email" id="subscriptionForm" class="inputForm" type="text" value="Your Email" onFocus="if (this.value=='Your E

Categories : PHP

Eloquent Object - Method Chaining
A simple way around: I compare my primary key to something non-existing (not an OPTIMAL solution), would be interested to see the other solutions, though I thought this could help: $foo = EloquentFoo::where('id','!=','0'); // id is the primary key and there is no row with value 0 // so basically above I am searching everything // Perform Chaining Operation if(true) { $foo->whereHas('eloqu

Categories : PHP

Php File_exists not working properly
Use, the exact physical path for the file. For that, use following: $_SERVER['DOCUMENT_ROOT']; And using this, get the exact path: e.g. $pictodelete = $_SERVER['DOCUMENT_ROOT'] . "/Images/" . $id_to_delete.".jpg"; Hope this works.

Categories : PHP

Returning the string after manipulating html by DOMDocument
You have to filter post_content with content_save_pre as function replace_content_image($page) { if($page->ID == 7){ $image = wp_get_attachment_image_src( get_post_thumbnail_id(7), 'single-post-thumbnail' ); $dom = new DOMDocument(); @$dom->loadHTML($page->post_content); $imgs = $dom->getElementsByTagName("img");

Categories : PHP

Call to a member function whereHas() on a non-object in laravel
$usersCount is already a number from the 1st line of your sample. You want instead to replace $usersCount->whereHas with User::whereHas in your foreach loop.

Categories : PHP

Why isset and not empty doesn't work in this Solarium object iteration
Because those properties are existent, but filled with an empty string or null... so isset() is always true for them... if you are not 100% sure, that they are always there, you could combine both checks (isset($result->title) && $result->title). The alternative would be something like (isset($result->title) && !empty($result->title)), which should work too

Categories : PHP

What is the correct way to store, increment and reuse an index
The best way to do this is to have three tables: Surveys Questions Answers Surveys would probably have a survey ID, user that created the survey, so on. Questions would have a question ID, the survey ID that the question is for, and what the question is asking. Lastly, Answers would have the answers to the questions, most likely having an answer ID, question ID, user who answered it and their

Categories : PHP




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