Questions tagged [php]

407340 questions
1

votes
2

answer
2.1k

Views

Yii2: How add a symbol before and after an input field

How can I add a symbol before and after of an input text? Just like the image attach. My code: SOLUTION I modify my code following ActiveForm documentation and it works! Code modified:
Alexandra
1

votes
1

answer
253

Views

How fetch_assoc know that you want the next row from the table?

If we would have code like this: $result = $conn->query('SELECT username FROM users'); $row1 = $result->fetch_assoc(); echo $row1['username'], ''; $row2 = $result->fetch_assoc(); echo $row2['username'], ''; Second echo would show username from second row in table, but why? How fetch_assoc() know tha...
Remniscate
1

votes
3

answer
220

Views

Checking if variable is date with PHP?

I have the following string: 08/07/2012 04:17:18 How can I check if it is a date data type by using PHP? For example, if I was checking for integer, I would do this: if(is_int($checkVar). How can I do the same for date format of this kind?
birdybird03
0

votes
0

answer
27

Views

Pull data from database using AJAX on html form multi select

I have 3 columns in my database table, viz. name, category, city. Here is the link where the form is located : http://sms.thetelityellowpages.com/sms/send.php There in category and city are multi select fields which are being pulled by database. Now the actual issue is that when I select 2 categori...
-1

votes
1

answer
16

Views

MYSQL: How to use Multiple OR on WHERE Clause?

I am having a problem with my MYSQL statement Warning : mysqli_num_rows() expects parameter 1 to be mysqli_result, bool given in C:\Users\R.B.Lara\Documents\My Projects\focalnews\index.php on line 188 $sqltype = 'SELECT * FROM focalnews_items ORDER BY datime ASC limit $last,20 WHERE (likes >= 5 OR...
Christian Read
0

votes
1

answer
11

Views

PHP session has already been started

I have a page on my website that calls a php file using ajax. I require the user to be logged in to access either page, and use session_start() on the page that calls the php file (let's say main.php calls bg.php). I include a session_start() on bg.php as well, because I need to access the session v...
k97513
-2

votes
0

answer
15

Views

: Undefined variable: FILES of image, PHP [duplicate]

This question already has an answer here: “Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP 28 answers HTML & PHP - Undefined variable: FILES to upload file [duplicate] 4 answers I'm trying to make an admin page for a website, when in thi...
roudy rahme
1

votes
4

answer
31

Views

PHP - Having trouble inserting dates from a date column with null values. Values are inside an array

I'm making a SQL Server to MySQL program that allows me to sync contents between two identical tables. However, I'm having trouble with inserting date values from a date column that has some of its cells set to NULL. The way this should work is that it should convert each value from the date column...
YMSmash
1

votes
2

answer
3.6k

Views

Php Auto Refresh Data in HTML

I want to ask a question in php. I want to make a plan and changing values over it. I put a image and I put some datas over it. I want to refresh auto this values. $data1 kWh $data2 kWh $data3 kWh $data4 kWh This is my getting data php code in same file; $servername = 'localhost'; $username = ''...
Selim Erkan
1

votes
2

answer
455

Views

Call to a member function addEagerConstraints() on float LARAVEL

My objective is to get average review of the courses available. But when i am trying to get the average review of the course its throwing me an error saying 'message': 'Call to a member function addEagerConstraints() on float' My Course Model public function rating(){ return $this->hasMany(Rating::c...
user7747472
1

votes
2

answer
2k

Views

Retrieving facebook user access token with socialite on laravel 5.4

I am trying to get user access token so I can send CURL request through Guzzle to Facebook's Graph API to get user's friends that are using the app. But I can't seem to be able to obtain it. Here's my controller:
Mihail Pernichev
1

votes
2

answer
2.8k

Views

wp_new_user_notification not working

I'm trying to customise the default wordpress user notification using wp_new_user_notification and I have included this in the mu-plugins folder so it gets priority. However, when I create a test user with my email address it sends me this template Username: test To set your password, visit the fo...
Shaun
1

votes
2

answer
277

Views

Crontab isn't running Laravel scheduled jobs

I've set up crontab on my AWS-EC2 instance to hit the Laravel scheduling endpoint every minute via the root account using sudo crontab-e: * * * * * php ~/htdocs/artisan schedule:run >> /dev/null 2>&1 However, despite to the cron logs showing it is indeed running every minute: Jan 26 12:02:01 ip-172-...
nomaki
1

votes
3

answer
40

Views

Trying to get rid of a part of a string (used as file path) in order to go back a directory

My problem is as follows. My PHP code relies on a string to determine a file directory, by removing the last part of the path. I want to go back a directory. Consider the following example: Original Input: $dir = 'this/is/a/files/location' Desired Output: $dir = 'this/is/a/files' Basically, I nee...
Karl Schmidt
1

votes
1

answer
296

Views

How can I find whole words only in a LIKE query Laravel?

How can I find whole words in a LIKE query in Laravel's Eloquent? For example, if someone searched SA the following results can come up with LIKE %sa%: My name is Sam I live in SA But I need a search that only returns: I live in SA How can I accomplish this while at the same time preventing SQL inje...
Oliver Kucharzewski
1

votes
2

answer
1.7k

Views

Dompdf not generating pdf properly from SVG

I am having trouble generating pdf keeping design with SVG content. SVG is linked inside html, and using html to generate pdf. But not working properly. This is the code: $dompdf = new DOMPDF(); //HTML Content $html = setPaper('A4', 'portrait'); $dompdf->set_option( 'isRemoteEnabled', true ); $dompd...
тнє Sufi
1

votes
2

answer
1.1k

Views

Laravel 5.5 Class 'Doctrine\DBAL\Driver\PDOPgSql\Driver' not found

I am working in laravel 5.5 with postgras 9.6, I manage to run all migration and rollback, but when I want to run migration for rename a column in Table i get the Class 'Doctrine\DBAL\Driver\PDOPgSql\Driver' not found error, hire is migration file: class CreateRenameApplicantIdInBillToApplicationId...
Joshua Kisanga
1

votes
1

answer
2.2k

Views

phpspreadsheet composer not installing

I am running composer locally to generate the necessary files that I will then deploy separately to server. Therefore I am running: composer require phpoffice/phpspreadsheet --ignore-platform-reqs However, it is failing: Problem 1 - The requested package phpoffice/phpspreadsheet No version set (par...
AntG
1

votes
2

answer
364

Views

Best way to write Group routes with prefix in laravel 5.5

What is the best and correct way to write the following routing: Route::group(['middleware' => ['web']],function (){ Route::prefix('user')->group(function () { //this address shows the login page Route::any('login', '[email protected]_page'); //others address that control the login action Route::prefix('lo...
Mahdi
1

votes
2

answer
2.1k

Views

PHP Warning: session_start(): Cannot start session when headers already sent

Im getting an error in my wp-debug log saying 'PHP Warning: session_start(): Cannot start session when headers already sent in ...hooks.php on line 228'. Here is a code snippet from the file function _action_fw_flash_message_backend_prepare() { if ( ! session_id() ) { session_start(); } } sess...
user2730011
1

votes
2

answer
308

Views

What condition to use Bollinger Bands?

I need to trigger a sales order when an asset touches the top row. I need to trigger a purchase order when the asset touches the bottom line. Looking at the chart I know the right moment to fire these orders, but in the programming that I wrapped, I do not know what criteria to use to know if an ass...
viniciussvl
1

votes
3

answer
2.1k

Views

Laravel: laravel.log permission denied

When I try to open my Laravel app I get the following error: UnexpectedValueException The stream or file '/laravel/storage/logs/laravel.log' could not be opened: failed to open stream: Permission denied Why is this and how can I fix it?
Masoud Khani
1

votes
2

answer
122

Views

DI - How to refactor constructor with lots of dependencies

I'm fairly new to dependency injection, and I've come upon a situation where I have a class which is basically just functional programming -- one method in it (createPayment) requires 9 dependencies, and the other method (paypalApiEndpoint) only requires 1 of those dependencies: class Paypal { priva...
KayakinKoder
1

votes
2

answer
8.7k

Views

How to solve Cross-Origin-Request-Block issue while fetching data using angular2 and php?

Please read the question in detail since it is a long one with various edits and extended updates as per the request of other users. I am trying to send data to php file using angular2. I am doing the angular project in Unix and the var/www/html/ is the php Xampp folder locations for running the ph...
Saswat
1

votes
3

answer
610

Views

how to implode array of values for sql in clause?

I have an array of fruits. I am trying to get all rows that contains any of these three fruits in the column 'fruits' $fruits = array('apple','banana','orange'); $imploded_fruits = implode(',',$fruits); $sql = 'SELECT * FROM market WHERE fruits IN ('$imploded_fruits');'; this is not returning expec...
codec
1

votes
1

answer
226

Views

oop php what is the best practice for database access? [closed]

I code as a hobby so i do not have a formal education on this topic so please excuse me for this question. I really have done a lot of research on this topic but wasnt able to get a clear answer. what class structure should i choose for database acess in php? class DatabaseObject and one child class...
J. Doe
1

votes
1

answer
540

Views

Class 'PragmaRX\Tracker\Vendor\Laravel\ServiceProvider' not found

I had installed PragmaRx\Tracker package several months ago into my project. I started to deleting the package from laravel project through following steps: 1. composer remove vendor/PragmaRx/Tracker 2. remove package name form composer.json file 3. removing package from provider and aliases list in...
blank94
1

votes
1

answer
539

Views

403 Forbidden error using ajax in CodeIgniter

I am displaying the first name in my textbox autocomplete using ajax but my ajax URL is not working. It's every time showing in the network tab 403 Forbidden. I tried ajax URL like this url:baseUrl + '/index.php/Employee_control/search_with_emp_name', url:baseUrl +'/Employee_control/search_with_emp...
user9437856
0

votes
0

answer
22

Views

How to fix the Add function?

I'm doing a php based project and I did it using php, PDO. And I created the code with OOC. But There's a if else part in main HTML page. In that part the else part is running. But I didn't even click the insert button. When the page is loading the else part is running. Here's the code.. Insert.php...
Gagani Senarathne
0

votes
2

answer
23

Views

Merge two array and create new

I have problem to create array. I have form. Form's inputs are tag inputs. First input is option name. When you put any option name the new tag input added in the form. I post data in controller and create auto variations for product. Eg. Red-S Red-M Blue-S Blue-M ... The Code which i'm using gives...
Energy40
1

votes
0

answer
15

Views

how to fix pre tag in Response

I'm getting a response enclosed inside pre tag.(like) result.. Note: Getting response 200 ok. but the format is not correct I saw the function which is responsible for getting values from server, with I went up to SQL query their also. path : /widgets/?action=get-add-modal-content&dashboard-id=548&...
Kiran
0

votes
0

answer
14

Views

Passing the language parameter to the next page (url) when submitting the form

I'm having problems with getting the right language parameter in the url when submitting a form. My application has two possible language parameters: de and en. I've made a middleware called setLocale.php with this function: public function handle($request, Closure $next) { $locale = $request->seg...
ofmiceandmoon
-1

votes
0

answer
11

Views

Fetch JSON data based on email using PHP

HI there What I want is to fetch the User Data based on the email ID From The JSON File. the Json Data is in this Format . [ { 'id': 1, 'name': 'Leanne Graham', 'username': 'Bret', 'email': 'Si[email protected]', 'address': { 'street': 'Kulas Light', 'suite': 'Apt. 556', 'city': 'Gwenborough', 'zipco...
Abnit Chauhan
0

votes
0

answer
23

Views

i am unable to insert data into my database using php

I am trying to insert data into my database table using php. but I am facing this error: Error: INSERT INTO vacancies (name,description,location,salary) VALUES ('','','',) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to u...
Zain Tahir
1

votes
1

answer
253

Views

How to get the search History in Elasticsearch?

There is any way to get the search history in Elasticsearch. In this I want to get the search queries which are searched by customers in last one month.
Tomas
1

votes
2

answer
328

Views

Converting SVG to another format fail due to delegate not being found

I have PHP code running on Debian stretch with ImageMagick. It tries to convert SVG to another format. Here is how it starts $im = new Imagick(); $im->readImageBlob($svg); The variable $svg contains valid SVG code in a string. If I copy this string to a text file with a .svg extension then it opens...
Gherman
1

votes
1

answer
436

Views

Yii2 on beforeSend modify statusCode to 200, but browser accept statusCode still is 500

I control API access by Yii2 RBAC. I want to always return 200 as status code, though 403. So I added some code to response config in main.php: 'components' => [ 'response' => [ 'class' => 'yii\web\Response', 'on beforeSend' => function ($event) { $response = $event->sender; if ($response->statusCod...
J.Tired
1

votes
4

answer
760

Views

Symfony PHP Logout not working

I have a logout function that worked in another project but for some reason doesn't work in the project I am currently working on. It looks like it just refreshes the page. I checked the official documentation of Symfony https://symfony.com/doc/current/security.html but to no avail. Hope you guys ca...
Mr J.
1

votes
1

answer
30

Views

Can I get the table id of a file uploaded earlier in the same function?

I wanna set the parent_id of images that are gonna get uploaded using a loop to the id of an image I uploaded earlier in the function. I could just make a query to the database but I was wondering if there's a better solution. $image = new Image(); $image->name = $title; $image->description = $descr...
Bobimaru
1

votes
2

answer
148

Views

How to get entire MongoDB collection with PHP

Using the following code, I can grab a node from a collection: However, what I'm really looking to do is get everything from the DBCOLLECTION. I'm kind of at a loss on how to do this. A few searches either go over my head or are for older versions of the PHP driver, such as this one fetch all data...
lowcrawler

View additional questions