Skip to content
Fix Code Error

Tag: php

What should I use to get an attribute out of my foreign table in Laravel?

July 18, 2021 by Code Error

Posted By: Anonymous I am trying to access the price of a product. I am using a orderItem table which has a foreign ID that goes to the product table. I then want to access the price of a corresponding product. When I do so it comes up with this error: Property [price] does not …

Continue Reading

CakePHP 4 – for 2 foreign keys in Table A, get corresponding data from Table B

July 18, 2021 by Code Error

Posted By: Anonymous Using CakePHP 4.1.6 I have two tables in my database called Categories and CategoryChanges. The Categories table is simple in that it contains a list with ID’s and names of several categories, e.g. id | name ———— 1 | Foo ———— 2 | Bar ———— 3 | Baz ———— My other table, …

Continue Reading

change parameter value of dependent method in phpunit

July 18, 2021 by Code Error

Posted By: Anonymous i wrote a sample test case for collection like class but weird thing about this is in my testAdd method that i add a item in CustomCollectionService and it changed my parameter too. how can this happend? class CustomCollectionService { /** * @var Collection $collection */ public $collection; public function makeCollection($arr) { …

Continue Reading

Send subscribe email as email body not as text in php

July 18, 2021 by Code Error

Posted By: Anonymous I want to send the email to the email subscriber , here is my approach $msg= file_get_contents("activate-mailer.html"); $from = $_POST[‘sunscribeemail’]; // this is the sender’s Email address $subject = "Email Subscription for the news letter "; $message = from . " " . Subscribe for the news letter:" . "nn" ; $headers …

Continue Reading

Virtual hosts not working properly in ubuntu LAMP stack

July 18, 2021 by Code Error

Posted By: Anonymous I have created virtual hosts in the following ways: Created laravel.test.conf as – cd /etc/apache2/sites-available – sudo nano laravel.test.conf And then updated laravel.test.conf as <VirtualHost *:80> ServerName laravel.test ServerAlias www.laravel.test ServerAdmin [email protected] DocumentRoot /var/www/laravel/public <Directory /var/www/laravel/public/> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> …

Continue Reading

pdo_pgsql.so and pgsql.so enabled but not showing in phpinfo

July 18, 2021 by Code Error

Posted By: Anonymous I just installed mamp pro on my macbook and i am getting this issue, i have enabled pdo_pgsql.so and pgsql.so as shown here 1.I make sure which php.ini am i using by: [email protected] ~ % php -i | grep php.ini Configuration File (php.ini) Path => /Applications/MAMP/bin/php/php5.6.31/conf Loaded Configuration File => /Applications/MAMP/bin/php/php5.6.31/conf/php.ini nano …

Continue Reading

WordPress is_tags not detecting tag clicked

July 17, 2021 by Code Error

Posted By: Anonymous I have a simple if statement that should show something different depending if tag, archive or something else. they all work apart from is_tag, for some reason when I click on a tag it shows the archive condition. I have tried multiple solutions and look around the internet, nothing seems to work.. …

Continue Reading

how to make Select function used in model dynamically select the column to export in excel in Laravel using Maatwebsite

July 17, 2021 by Code Error

Posted By: Anonymous I am working in the project using Laravel 8 and waatwebsite(to work with excel). I have one Table name Docs in my database which have 20 columns value. I dont Know how to make the select() function dynamical so that i can pass the column name from controller to extract the query …

Continue Reading

Why cookies are added rather than changed?

July 17, 2021 by Code Error

Posted By: Anonymous I am developing a site where each user should have their own id. When I went into the console, I saw that the id was duplicated instead of being one. Is this normal and should it be? if (isset($_COOKIE[‘SESSION’]) && (strlen($_COOKIE[‘SESSION’]) === 32)) { $uid = $_COOKIE[‘SESSION’]; } else { $uid = …

Continue Reading

Problem displaying dynamic data in the boostrap table

July 17, 2021 by Code Error

Posted By: Anonymous The boostrap table is inside the boostrap modal. I’m trying to display data in the table from the server which I hosted locally but the code , turns white when i introduce the while(){} loop. Below is my code. <?php while($products = $result->fetch_assoc()){ <tr class="table-success"> <th scope="row"> <div class="form-check"> <input class="form-check-input" type="checkbox" …

Continue Reading

How to save call_user_func_array() function output

July 17, 2021 by Code Error

Posted By: Anonymous i am trying to make a static site generator which works with a great routing class. if (php_sapi_name() === "cli") { foreach ($router->get() as $route) { $out = ob_get_contents(); call_user_func_array($route[‘function’], array()); ob_end_clean(); file_put_contents("./temp/" . $route[‘expression’] . ".html", $out); } } So i am trying this I can see the compiled html code …

Continue Reading

Laravel, how to display Values in DB with just given IDs?

July 17, 2021 by Code Error

Posted By: Anonymous im trying to get 5 data from DB with their ID ? HTML <input type="number" name="cid1"> <input type="number" name="cid2"> <input type="number" name="cid3"> <input type="number" name="cid4"> <input type="number" name="cid5"> Route Route::post(‘/selectCampaign’,’[email protected]’)->name(‘selectCampaign’); Controller – im Trying to get Just 1 ID and its not Working public function selectCampaign(Request $request) { $id1 = request(‘cid1’); $offers …

Continue Reading

How do I use response from an API into the controller – CodeIgniter

July 17, 2021 by Code Error

Posted By: Anonymous I tried to integrate an API that built-in laravel and now I have to use that API’s response into the Codeigniter project, I’m developing a Codeigniter project(I’m not familiar with this framework and it’s my first time working with this), I finally could do it, I’m getting a response from an API …

Continue Reading

function on Contact Form 7 submission not working

July 16, 2021 by Code Error

Posted By: Anonymous I’m using Contact Form 7 in WordPress, What I want to do is to call a specific JavaScript function when the form I created is submited show popup successful. and this my code add_action(‘wpcf7_mail_sent’, function ($cf7) { // Run code after the email has been sent $wpcf = WPCF7_ContactForm::get_current(); $wpccfid=$wpcf->id; // if …

Continue Reading

Issue Migrating Hashing Algorithm in PHP

July 16, 2021 by Code Error

Posted By: Anonymous I am looking at migrating the hashing algorithm used for all passwords in a database and looking for proof of concept. I was reading up on a concept that would be very user friendly and not force anyone to change their password here that essentially allows to migrate all passwords in the …

Continue Reading

set cookie throw curl request

July 16, 2021 by Code Error

Posted By: Anonymous I want to set cookie throw curl request. I used this code but the requested URL return You must enable Javascript and accept cookies. what Im doing wrong here? cookie.txt file is 0644 permission $curl = curl_init(); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_URL, $base); curl_setopt ($curl, CURLOPT_COOKIEFILE, …

Continue Reading

PHP S3 – How to get all versions of a specific file

July 16, 2021 by Code Error

Posted By: Anonymous I have a Laravel project and a version enabled S3 bucket. I can list the versions of all objects within the bucket using the listObjectVersions method. My attempt to list the versions of a specific object is as follows: $result = $client->listObjectVersions([ ‘Bucket’ => Config::get(‘filesystems.disks.s3.bucket’), ‘Key’ => $folder . ‘/’ . ‘test.png’, …

Continue Reading

Laravel – Missing required parameters for [Route: reset-password.index]

July 16, 2021 by Code Error

Posted By: Anonymous i’m just a newbie in Laravel, so still not that good to work on such ready projects, anyway when ever users try to reset password it fails showing that: ~/public_html$ php artisan queue:work [2021-05-29 19:52:02][182577] Processing: AppMailCoreResetPassword [2021-05-29 19:52:02][182577] Failed: AppMailCoreResetPassword and when i checked the log files, i found this error: …

Continue Reading

How to block form submissions if the message field contains certain words (PHP)?

July 16, 2021 by Code Error

Posted By: Anonymous I want to prevent the contact form from submission if the message field contains certain words. I used one, two and three as an example: //Prevent the form from submission if it contains one, two, or three $needle = [‘one’, ‘two’, ‘three’]; if (stripos($message, $needle) !== false) { echo "$message contains $needle"; …

Continue Reading

file_get_contents of .txt file on google drive

July 15, 2021 by Code Error

Posted By: Anonymous I’m trying to read the contents of a .txt file saved on google drive using PHP. I can’t seem to find a workaround for this. It keeps displaying in google’s wrapper. I just want the plain old text. I’ve tried: <?php $text = file_get_contents(‘https://drive.google.com/file/d/11dW2pOK-MXHGRzQhJWb37tlWMqazj8UZ/view’); echo $text; ?> Which displays a blank page …

Continue Reading

ErrorException: Undefined index: id

July 15, 2021 by Code Error

Posted By: Anonymous I’m trying to fetch data from this JSON URL https://api.github.com/users/Kirolos-victor/events/public but I don’t understand why am I getting this error I hope someone can help me, Thanks. public function score(Request $request) { $validator=Validator()->make($request->all(),[ ‘name’=>’required’, ]); if($validator->fails()) { return response()->json([‘message’=>’failed’,’data’=>$validator->errors()],400); } $json=Http::get("https://api.github.com/users/$request->name/events/public")->json(); $id=collect($json["id"]); return $id; } Solution looks like that end point is …

Continue Reading

How to pass variable name from controller to twig file in Symfony?

July 15, 2021 by Code Error

Posted By: Anonymous I need to display image at my twig file. I am passing filename information as below: $emailContent = [ ‘filename’ => "$filename.png" ]; $this->sendMail( ,,, … ‘Emails/content.html.twig’, $emailContent ); In my twig file, when I put the filename directly it works. <img src="{{ email.image("@images/1000.png") }}" alt="It Works!!"> But, I am not sure …

Continue Reading

How to run WordPress Query by ACF field using Select on front-end

July 15, 2021 by Code Error

Posted By: Anonymous Basically what I’m trying to do is create filters on front end, so that users can filter all posts by specific ACF field. There’s a cattery website and the owner will need to add new litters, when new generations of kittens arrive. I’ve created option page for this new field group and …

Continue Reading

How can I pass a hidden SQL ID field value alongside other data during a form lookup?

July 15, 2021 by Code Error

Posted By: Anonymous I’m doing my best to put together a basic property management app that will allow users to check out keys to contractors (and check them back in of course). I’m a relatively inexperienced coder and am currently struggling to work out how to pass an additional SQL ID value during a lookup. …

Continue Reading

Insert Excel datas on mysql with php

July 15, 2021 by Code Error

Posted By: Anonymous I’m trying to insert excel datas in mysql with php, I have a code but it’s inserting only the first line off the archive and my archive has 3 lines. Someone knows how to help me? public function incluirLote() { if (!empty($_FILES[‘arquivo’][‘tmp_name’])) { $arquivo = new DOMDocument; $arquivo->load($_FILES[‘arquivo’][‘tmp_name’]); $linhas = $arquivo->getElementsByTagName("Row"); $countlinha …

Continue Reading

simplexml_load_string asXML not empty, but children() function returns empty?

July 15, 2021 by Code Error

Posted By: Anonymous echo $xml->asXML(); Prints the following, and I am tring to access to elements here like: InvoiceStateResult <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <soap:Header> <wsa:Action>http://tempuri.org/SendEArchiveDataResponse</wsa:Action> <wsa:MessageID>urn:uuid:72e8aaf0-b36d-422f-ab0b-486c17c50c83</wsa:MessageID> <wsa:RelatesTo>urn:uuid:fc0a3e9d-40c1-4f3b-9517-8002825b7217</wsa:RelatesTo> <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To> <wsse:Security> <wsu:Timestamp wsu:Id="Timestamp-3a82271a-a910-4062-81aa-984468387047"> <wsu:Created>2021-05-28T12:12:23Z</wsu:Created> <wsu:Expires>2021-05-28T12:27:23Z</wsu:Expires> </wsu:Timestamp> </wsse:Security> </soap:Header> <soap:Body> <SendEArchiveDataResponse xmlns="http://tempuri.org/"> <SendEArchiveDataResult> <Invoices> <InvoiceStateResult> <ServiceResult>Error</ServiceResult> <UUID>11111111-2222-3333-4444-555555555555</UUID> <InvoiceId>T612014000000053</InvoiceId> <StatusDescription>INVOICE EXISTS</StatusDescription> <StatusCode>29</StatusCode> <ErrorCode>0</ErrorCode> …

Continue Reading

One to many relationship in two JSON arrays, lookup results in PHP

July 15, 2021 by Code Error

Posted By: Anonymous I have two separate JSON arrays. Array 1 is called matches, Array 2 is called participants. Participants can be in many matches. I need some direction in how to look up the player id from matches within the matches array and return the corresponding participants name from the participants array. Matches contains: …

Continue Reading

Change PORT for LDAP

July 15, 2021 by Code Error

Posted By: Anonymous I am trying to connect to LDAP. I know that default port is 389 but we have changed it to 636. I have this part of code private static $HOST = "mywebpage.com"; // Connect to LDAP $link_id = ldap_connect(self::$HOST); $bind_result = ldap_bind($link_id, self::$APP_DN, self::$SERVER_PASSWORD); error_log(print_r($link_id,true)); //returns resource id #6 error_log(print_r($bind_result,true)); //returns 1 …

Continue Reading

GD not support JPEG

July 14, 2021 by Code Error

Posted By: Anonymous I tried enabling GD JPEG with DOCKER but it doesn’t work. This is my dockerfile : FROM php:7.4-apache COPY ./app/. /var/www/html RUN apt-get update && apt-get install -y libzip-dev zip zlib1g-dev libjpeg-dev libjpeg62-turbo-dev libfreetype6-dev libpng-dev RUN docker-php-ext-install mysqli && a2enmod rewrite && service apache2 restart && chown -R www-data:www-data /var/www RUN docker-php-ext-configure …

Continue Reading

Function AFTER authentication and BEFORE view (laravel)

July 14, 2021 by Code Error

Posted By: Anonymous I’m trying to get settings from the database and put them in the config, my function need the user id so it can bring his settings only, in the service provider ( boot function ) there is no authentication yet, can you please advise me to the right place to run my …

Continue Reading

Posts navigation

  • 1
  • 2
  • 3
  • 4
  • …
  • 95
  • Next

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error