Skip to main content

Posts

Showing posts with the label php

It is not a valid class. Check the name

I set up a response form to comments posted on my music and texts that I publish to know they are suitable. My comments are posted well and I manage to retrieve the id of the comment posted to which I want to respond (via js) but when I want to save my response in my table, I get this error: The "App\Entity\Comment" entity has a repositoryClass set to "App\Entity\CommentRepository", but this is not a valid class. Check your class naming. If this is meant to be a service id, make sure this service exists and is tagged with "doctrine.repository_service". My Home controller (here are the articles and comments): // PARTIE COMMENTAIRES // On crée le formulaire vierge (on instancie) $comment = new Comment; // On génère le formulaire $commentForm = $this->createForm(CommentType::class, $comment); $commentForm->handleRequest($request); // Traitement du formulaire if($commentForm->isSubmitted() && $commentForm->isValid()){ $com

PHP code not connecting HTML to MYsql database [closed]

I'm new to PHP ...... so I want to make a program in which my HTML form inputs are stored in the database. I followed a youtube tutorial to do this this and here is the code I have written for the php file `<?php $firstname = $_POST ['firstname'] ; $email = $_POST ['email']; $admin = $_POST ['admin']; $school = $_POST ['school']; $gender = $_POST ['gender'] ; //DATABASE CONECTION $conn = new mysqli('localhost', 'root', '', 'register'); if ($conn-> connect_error){ die ('connection error : ' . $conn-> connect_error); }else{ $stmt = $conn->prepare("INSERT INTO register(firstname, email, admin, gender) values(?, ?, ?, ?, ?)"); $stmt-> bind_param("ssiss", $firstname, $email, $admin, $gender); $stmt-> execute(); echo"Registration succesfull"; $stmt-> close(); $conn-> close(); }` and here is my database and my html code <html> <head>

check if array it´s empty javascript

I´m traying to create function to validate my form with jquery by response ajax and laravel backend. in my backend i have this: /** * SEARCH DATA CLIENT FOR CREATE PRECONTRATO */ public function searchClient(Request $request) { $client = $request->get('documento'); $clientSearch = Cliente::where('CIF_NIF', $client)->get(); if($clientSearch->count() > 0){ return $clientSearch[0]; } return $clientSearch; } this function return client or empty collection if query don´t return any result. My problem it´s that i can´t check this condition. If i put one data that in my database don´t exists, return this: [] No properties it´s ok don´t exists, but i have that in my success function ajax and this it´s wrong I have this in ajax: $.ajax({ url: "", method: "POST", data: { "tipo_documento": tipoDocumento, "documento": document

How can I resolved syntax error in Moodle?

I have the Eguru theme installed in Moodle, but the images are not displayed. I get this error: Excepción - Call to undefined function sibil@gmail.com() error/moodle/generalexceptionmessage What can I do? Thanks for your advice. source https://stackoverflow.com/questions/70475445/how-can-i-resolved-syntax-error-in-moodle

Write sql query in PHP that fetch data randomly one by one from database. but if first record is displayed it does not need to display again [closed]

$sql = "SELECT Name FROM register ORDER BY RAND () Limit 1 BUT First Record Never Display Again if it come first ; "; source https://stackoverflow.com/questions/70475331/write-sql-query-in-php-that-fetch-data-randomly-one-by-one-from-database-but-if

Appropriate permissions for cache cleaninig in laravel 8 / bagisto e-commerce platform

I can't properly clear my store cache *Error handled like:             Make sure you have appropriate permissions for cache clearing However I've give chmod 0777 command "Linux/Ubuntu18.04" to all folders in project directory P.s I'm a newcomer to Laravel)) Thanks a lot! source https://stackoverflow.com/questions/70466201/appropriate-permissions-for-cache-cleaninig-in-laravel-8-bagisto-e-commerce-pl

how to set CSS for MPDF in yii2 on generating pdf file

I am using yii2 basic and I need to generate a pdf report file which is styled with CSS file, I get the pdf well but CSS is not working on the generated file. Here is how I have implemented. in my controller.php file public function actionPrintReport($student_id,$exam_id,$total_subjects,$exam_date){ $model = new Results(); $examReportData = $model->getExamReport($student_id,$exam_id,$exam_date); $htmlContent = $this->renderPartial('_report', [ 'model' => $model, 'total_subjects' => $total_subjects, 'examReportData' => $examReportData ]); $pathfile = "Student_exam_report"; $mpdf = new \Mpdf\Mpdf([ 'tempDir' => Yii::getAlias('@runtime/') . 'mpdf2/tmp', 'format' => 'A4-L', 'margin_right' => 5,'margin_left' => 5, '

PHP socket_recv unable to read from socket

I am making a little project for myself, a website with remote control of my wifi bulb; I have to send datagram to $address:$service_port and then listen to this socket for the request. It should be something like a list of devices and their options. But I am stuck with this: OK. Trying connect to address '239.255.255.250', port '1982'... OK. Sending request(M-SEARCH * HTTP/1.1 HOST: 239.255.255.250:1982 MAN: "ssdp:discover" ST: wifi_bulb) OK. Receiving request... Warning: socket_recv() [function.socket-recv]: unable to read from socket [0]: Operation completed successfully. in Z:\home\x1.loc\www\header.php on line 125 Cant execute socket_recv(). Reason: Operation completed successfully. Result: And if I didnt define 'MSG_DONTWAIT' at beginning, it also crashes. 'MSG_WAITALL' dont work at all, page never stops reloading. This is my 1st php project, so maybe errors connected with settings. <?php if(!defined('MSG_DONTWAIT')) defi

How do I run a local Xampp server using files from a network drive?

There is a Xampp server running on a network location that I have limited access to. The htdocs folder within Xampp (on the network location) is on a git repository, and I am working on my own branch off of that. I want to be able to run a local server using Xampp of the branch I am working off of. I can't run my changes on the main server. Sorry if this explanation sucks, I can clarify any details. My first idea was to do a symbolic link from my local installation of Xampp to the network drive folders, but I'm not sure if it will work. Or I could just run Xampp and make it look elsewhere for it's files besides the C drive? Any help is greatly appreciated, I'm a bit stuck on this. source https://stackoverflow.com/questions/70440127/how-do-i-run-a-local-xampp-server-using-files-from-a-network-drive

htaccess redirect POST message to php file in subfolder

I hope someone can help me to correct my htaccess problem in a shared hosting scenario, so I don't have access to httpd.conf. I am trying to redirect a POST to /process-dev.php to the file in the correct subfolder as shown below, but instead my POST gets redirected to index.php The POST comes from the webpage itself (actual domain replaced with subdomain1.com) https:://www.subdomain1.com. / |- .htaccess |- css |- clientscripts |- php |- site |- subdomain1.com |- language |- default |- process-dev.php |- index.php My htaccess file <FilesMatch "^\.ht"> Require all denied </FilesMatch> Options +FollowSymlinks Options -Indexes RewriteEngine on # Enforce SSL RewriteCond %{HTTPS} !=on # Handle non-www URLs RewriteCond %{HTTP_HOST} ^subdomain1\.com [NC,OR] # Handle www URLs RewriteCond %{HTTP_HOST} ^www\.subdomain1\.com [NC] RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteCond

Show doctor appointments in one option dropdown [closed]

I have to Show Doctor's appointment in option dropdown Suppose Doctor sit's Two times in a day Morning 10 A.M. to 1 P.M. (30 minutes) Evening 4 P.M. to 6 P.M.(40 minutes) Output should be 10:00-10:30 10:30-11:00 11:00-11:30 11:30 - 12:00 12:00-12:30 4:00-4:40 4:40-5:20 5:20-6:00 source https://stackoverflow.com/questions/70440035/show-doctor-appointments-in-one-option-dropdown

ci4 waiting a lot on page load

This is the error I got, I couldn't find the solution. The project is loading too late. Can you help me? Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 20480 bytes) in D:\Program Files\XAMPP\htdocs\app\Helpers\sdc_helper.php on line 193 Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 32768 bytes) in D:\Program Files\XAMPP\htdocs\vendor\codeigniter4\framework\system\Log\Handlers\FileHandler.php on line 1 scd_helper.php line 193 $str = preg_replace(array_keys($options['replacements']), $options['replacements'], $str); if ($options['transliterate']) { $str = str_replace(array_keys($char_map), $char_map, $str); } $options['replacements] function sdc_slug_creator($str, $options = array()) { $str = mb_convert_encoding((string)$str, 'UTF-8', mb_list_encodings()); $defaults = array( 'delimiter' => '-', 'limit'

Custom Form Request Validation with unique validation not working on update

I'm not sure what I'm doing wrong, but I have a custom form request validation that I'm using in for Create and Update record with unique column validation. It's working fine for creating new record, but not for updating a record. Custome Form Request <?php namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; class ServiceTypeRequest extends FormRequest { public function authorize() { return true; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return [ 'service_name' => ['required', Rule::unique('service_type', 'Service')->ignore($this->service_type) ], 'type' => ['required', 'string'], 'view_availability' => ['required', 'boolean'], ]; } } Controller Update public function update(ServiceTypeRequest $request, ServiceType $se

PHP/JS only outputting content for 1 second [duplicate]

I am creating a website where if you input the year you were born in, the website will output your age in days. The code works for the most part. When I press the submit button, the age outputs for 1 second and then leaves the screen. I want the text to stay there. Here's my JS Code: function ageInDays() { // variables var birthYear = <?php echo $_GET["name"];?>; var thisYear = new Date(); var ageInDayss = (thisYear.getFullYear() - birthYear) * 365; //text if (isNaN(birthYear) == false) { if (birthYear<=1920 || birthYear>=2022) { var h1 = document.createElement('h1'); var textAnswer = document.createTextNode("Invalid Input. Please Try Again."); h1.setAttribute('id', 'ageInDays'); h1.appendChild(textAnswer); document.getElementById('flex-box-result').appendChild(h1); } else if (birthYear>1990 &am

Accessing data in an associative array in CodeIgniter 3

I'm using CodeIgniter 3 and I'm passing an associative array from the controller to the view. In the view I'm trying to render a chart using ChartJS so I need to get the data of 0th and 1st indexes separately. {"label":["A+","AB-","B+","B-","O+"],"data":["6","2","5","2","3"]} is the associative array I'm passing. Below is the code in the controller. public function bloodTypesChart() { $totalPackets = $this->db->count_all_results(); $chartData = []; $blood_types = $this->db->query("SELECT (BloodType) as blood_type FROM packets WHERE (isAvailable) = '1' GROUP BY blood_type")->result_array(); $record = $this->db->from('packets') ->select('count(PacketID) count, BloodType blood_type') ->group_by('blood_type') ->

returning validation fail like response in none validation scenario [duplicate]

so lets say i have 2 functions , i send a ajax request to init function and init function calls check function function init(Request $request){ $this->check($request); } function check(Request $request){ $request->validate(['something' => 'required']); } in this scenario if validation fails laravel returns a response to ajax call with Status Code: 422 , and i dont need to return any response now if i want to check something else and if that fails i want to response just like validation fail response function cehck(Request $request){ if($somethign_else_failes) { return response()->json(['errors' => ['email' => ['The email is invalid.']]], 422); } } but this wont return back the ajax call response ... it will just return it to init function and i need to add another return in the init function basically i dont want to have multiple returns in nested functions , if it failes at any level

Give access to pages to specific user types PHP

In my application I have 2 user types, admin and manager. I want the manager to have access to the dashboard.php only. For this in my users table I've set usertype as column and while signing up they have to mention what type of user they are. Based on this, after logging in the manager dashboard, I have a button that goes to dashboard.php . And in dashboard.php I'm checking the $_SESSION['usertype'] == 'manager') . If it is it'll allow the user to access that page otherwise it'll take him to login page. But it isn't working. Every time it is taking me to the login page and anyone can access the dashboard.php by putting in the URL. manager.php <?php // Initialize the session session_start(); // Check if the user is logged in, if not then redirect him to login page if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){ header("location: login.php"); exit; } echo $_SESSION["usertype&q

PHP8.1 - how do I get imageavif() to work?

I recently upgraded my PHP version to 8.1-fpm and also upgraded Debian to Bullseye. I read somewhere that Bullseye comes with avif support but when I try to use imageavif(), I get the following error: PHP message: PHP Fatal error: Uncaught Error: Call to undefined function imageavif() I ran "php -i | grep AVIF" on my server and it returns: ImageMagick supported formats => 3FR, 3G2, 3GP, AAI, AI, APNG, ART, ARW, AVI, AVIF, AVS, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CR3, CRW, CUR, CUT, DATA, DCM, DCR, DCX, DDS, DFONT, DNG, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, FAX, FILE, FITS, FRACTAL, FTP, FTS, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GROUP4, H, HALD, HDR, HEIC, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, J2C, J2K, JBG, JBIG, JNG, JNX, JP2, JPC, JPE, JPEG, JPG, JPM, JPS, JPT, JSON, K25, KDC, LABEL, M2V, M4V,