Skip to main content

Posts

Showing posts with the label laravel

Docke 502 Bad Gateway nginx (Mac)

I'm trying to work out whats causing a 502. When I run docker-compose up, it shows 502 Bad Gateway. Why is that? in the docker logs write: 2022/01/03 18:35:13 [error] 115#115: *7 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.18.0.5, server: _, request: "GET /typo3/install.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "retro.vm52.iveins.de" docker-compose.yaml version: '3.5' volumes: global-db: services: global-nginx-proxy: image: jwilder/nginx-proxy restart: ${RESTART:-unless-stopped} ports: - "${HTTP_PORT:-80}:80" - "${HTTPS_PORT:-443}:443" environment: - HSTS=off volumes: - /var/run/docker.sock:/tmp/docker.sock:ro - ./.docker/config/global-nginx-proxy/additional_nginx.conf:/etc/nginx/conf.d/additional_nginx.conf - ./.docker/data/global-nginx-proxy/certs:/etc/nginx/certs:ro - ./.docker

Create short links for each product in the subdomains

Merry Christmas I'm working on a multi-vendor project using php mvc, using wildcard to create a subdomain for each vendor. Keep this link in mind: http://asdasdasd.tbuy.biz/FastCart/order/4867 I use this link: http://sgsh.me/00hmRo I will be redirected to the link I showed above The link is different for each user and how can I implement such a system? Thanks for your tips source https://stackoverflow.com/questions/70558491/create-short-links-for-each-product-in-the-subdomains

Submit woocommerce order tracking form from My Account custom tab

So I created a new custom tab in My Account menu called "Shipping Tracking" and the content inside this page is the form-tracking.php template. My problem is when I press the submit button to track an order it redirects me to my account dashboard page. So I tried to create an ajax form submission with no success based on this post WooCommerce track order submit AJAX I don't mind if the form submission will be in ajax or with page refresh , I just want to stay in Shipping Tracking page My code: /* * Step 1. Add Link (Tab) to My Account menu */ add_filter ( 'woocommerce_account_menu_items', 'shippingTracking_link', 40 ); function shippingTracking_link( $menu_links ){ $menu_links = array_slice( $menu_links, 0, 5, true ) + array( 'shipping-tracking' => 'Shipping Tracking' ) + array_slice( $menu_links, 5, NULL, true ); unset( $menu_links['downloads'] ); return

Good day. Im trying to make a Student log in form using php and xampp to run the code. I already have a database in phpMyAdmin and I get this error [duplicate]

Fatal error: Uncaught Error: Call to undefined function mysql_query() in C:\xampp\htdocs\attendancemonitoring\student\controller.php:58 Stack trace: #0 C:\xampp\htdocs\attendancemonitoring\student\controller.php(11): doInsert() #1 {main} thrown in C:\xampp\htdocs\attendancemonitoring\student\controller.php on line 58 My Code <?php require_once(LIB_PATH.DS.'database.php'); class Student { protected static $tblname = "tblstudent"; function dbfields () { global $mydb; return $mydb->getfieldsononetable(self::$tblname); } function listofstudent(){ global $mydb; $mydb->setQuery("SELECT * FROM ".self::$tblname); return $cur; } function find_student($id="",$name=""){ global $mydb; $mydb->setQuery("SELECT * FROM ".self::$tblname." WHERE StudentID = {$id} OR Lastname = '{$name}'"); $cur = $mydb->exec

generating a random number and send to the header

In my login form, if email or password is wrong I set header ('Location: login.php?Err=284613'); . Then using Javascript I capture it and give the error code to the page using if (window.location.search == "?Err=284613"){} . The issue is that I don't want the user to type login.php?Err=284613 and trigger the error code manually. Can I generate random numbers with PHP and show different numbers each time in login.php?Err="random numbers" . Of course, then I need to capture that random number with javascript in order to show the error on the page. <?php if (!isset($_POST['username'], $_POST['password'])) { exit('Please fill both the username and password fields!'); } if ($stmt = $con->prepare('SELECT id, Password FROM users WHERE Email = ?')) { $stmt->bind_param('s', $_POST['username']); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows > 0) {

Laravel Eloquent Relationship Join

carts:- id product_name price ratings:- id product_id user_id I have these two table. And i have defined a relationship in product model for geting rating of particular product. and output of the code is this:- "data": [ { "id": 4200, "name": "Anti gravity Beer Cake", "modal": "", "price": 1800, "discount": 0, "quantity": 20, "discription": "Good Quality Product!", "p_status": "active", "m_id": 664, "product_link": "anti-gravity-beer-cake--6040c2b317894", "product_picture": " ", "weight": 0, "weight_type": "Kilogram", "rating": { "id": 4,

Best way to minimise/streamline/use synergies of code to populate several webpages with different content but same layout? [closed]

sorry for the non-specific title but my question relates to coding strategy and best practice. I'm new to coding and I'm working on a website on a local server. I'm learning a lot of new coding languages (html, css, php, jquery, javascript, ajax and mysql) as I need them but I'm conscious that I'm a complate amateur when it comes to the best way to apply them. Background My website has header and footer pages that include all the menu navigation, login system, css/js link type of things. Every other webpage leverages the header and footer pages, therefore the other webpages only contain content (I'll call these pages "article webpages" for clarity below). The layout of all the article webpages is the same but headings, images, colour schemes and text will vary from one article webpage to another. Lastly, I also have one other over-arching webpage that includes buttons and each button sends the user to an individual article webpage when clicked.

Issue while trying to receive message notifications from Slack

About I am trying to receive message posted on my server as soon as user post message the message in group or channel or direct in slack. App Status Code in the verified file where challenge was posted. header('Content-type: application/json'); $myfile = fopen("test.txt", "w") or die("Unable to open file!"); $data = json_decode(file_get_contents('php://input'), true); fwrite($myfile, $data["challenge"]); fclose($myfile); $json = '{"challenge":' . $data["challenge"] . '}'; echo json_encode(["challenge" => $json]); Question Now that the above url has been verified successfully, I am still not able to receive the posted messages. I was expecting messages posted at same url which was used to verify challenge parameter. Is that correct? Am I missing anything retrieving the messages posted on my server? source https://stackoverflow.com/questions/70535363/issue-while-trying-to-r

Converting Time with timezone PHP

I'd like to convert value/date/time that I got from callback raw value that I got is like this $value='2021-01-20T19:03:52.355+0300'; I need to convert it into like this $value='20-01-2021 23.03.52,355000 +07:00'; what I've done some substr and concat but unfortunately it ends up with string and my db datatype format is timestamp and i can't insert the value to db read some about DateTime::createFromFormat and I can convert the time format but still no clue for converting to another timezone source https://stackoverflow.com/questions/70529737/converting-time-with-timezone-php

Force browser to display PDF file instead of download

I found some solution for my issue by googling but none of them worked for me. I want to show a PDF file in a webpage but browser makes user to download it! How can I solve this? My code is below. <?php session_start(); $name = $_SESSION['src']; $file= 'usr/'.$name.'/out.pdf' ?> <!DOCTYPE html> <html> <page size="A4"><embed src=<?php echo $file?> type="application/pdf" width="800px" height="1100px" /></page> </html> source https://stackoverflow.com/questions/70524443/force-browser-to-display-pdf-file-instead-of-download

php handling character set

I have an issue with encoding json to sent to datatable.net. I received DataTables warning: "table id=varietyTable - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1." Checked the development tool. I found out that there is no response. There apparently there is something wrong with json_encode. I look at the record. it seems to have problem handing ascii code 160. The same code running on my local machine (running xampp). There is no problem. I tried to echo the page. I see unreadable character on the remote server but no local host. output on remote server: Alma�� output on local host: Alma (note that there are spaces behind the word Alma). The php code are identical. I am just wondering whether the local php setting is different so that the special characters can handle properly. Thanks. here are some code from php code that receiving the records and return as Json. The code is rather long. I am posting the parts the

Braintree PHP How To Get Nonce Without DropIn for Vaulting

For our use case, we have an existing form that captures the customer's credit card information. To smooth out the transition from one payment processor to the next since we're not sure when that will happen, we would like to vault the payment method in Braintree without charging the card but keep our existing form. I see how to vault the nonce that we receive from the Drop-In UI, and I was able to find an answer on SO that described how to pass the payment information directly to Braintree and charging it, however, I have had no luck in finding a way to just pass the card information to braintree for the purposes of vaulting the payment method (with or without the intermediate step of receiving a nonce). source https://stackoverflow.com/questions/70511004/braintree-php-how-to-get-nonce-without-dropin-for-vaulting

How do I pass the values of my checkboxes with PHP to mySQL database?

Now the value in my database is just "Array". Because, well it is an array. It can see whether I checked at least one thing, or no things at all. If I don't check any checkboxes it returns nothing, if I check at least one thing it returns "Array". I haven't worked with PHP before, and we didn't get any classes about this, but after a few days of trying I couldn't figure it out. <?php // Show all errors (for educational purposes) ini_set('error_reporting', E_ALL); ini_set('display_errors', 0); // Constanten (connectie-instellingen databank) define('DB_HOST', ''); define('DB_USER', ''); define('DB_PASS', ''); define('DB_NAME', ''); date_default_timezone_set('Europe/Brussels'); // Verbinding maken met de databank try { $db = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=utf8mb4', DB_USER, DB_PASS); $db->

Select a record when the timestamp has passed by a certain amount of time MYSQL/PHP

I'm trying to select sessions that are younger than 6 hours old with this query like so: "SELECT * FROM sessions WHERE members=1 AND ipRCreator != '$usn' AND tStamp < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 6 HOURS"; The problem is that the query condition is always false and never manages to find the sessions even when a record actually has a timeStamp of a few seconds ago. obviously I am very sure that the problem is in the condition of the: tStamp < DATE_SUB (CURRENT_TIMESTAMP, INTERVAL 6 HOURS) I insert the data records in the table like this: $timestamp = date("Y-m-d H:i:s"); $mysqli->query("INSERT INTO sessions (sessionId, members, ipRCreator, tStamp) VALUES('$sId', 1, '$usn', '$timestamp');") ; I thought the problem was the formatting of the date but I don't think since the insert works well and the date is correctly inserted in the DB. This is the sql structure of the table: `sessionId` tex

getting internal error 500 while using google signup method [duplicate]

my _config.php <?php session_start(); require_once 'vendor/autoload.php'; $google_client = new Google_Client(); $google_client->setClientId('16194638744-qm9esnsemf65s3ghch246sprp7jimrcp.apps.googleusercontent.com'); $google_client->setClientSecret('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'); $google_client->setRedirectUri('http://localhost/houzz/partials/g-callback.php'); $google_client->addScope('email'); $google_client->addScope('profile'); ?> my g-callback.php <?php require_once "_config.php"; if(isset($_GET['code'])){ $token = $google_client->fetchAccessTokenWithAuthCode($_GET['code']); $_SESSION['access_token'] = $token; }else if(isset($_SESSION['access_token'])){ $google_client->setAccessToken($_SESSION['access_token']); }else{ header('Location: localhost/houzz/partials/_otp.php'); exit(); } $Oauth = new Google_Service_

How do I ckeck if the column contains the $_POST of the form?

I have an issue with the following code : $recherche = $_POST['recherche']; $recherche = '%'.$recherche.'%'; $selecPrepare = self::$bdd->prepare("SELECT culmn where column LIKE '%{$recherche}%'"); $tab = array($_POST['recherche']); $selecPrepare->execute($tab); return $tab; I'm sorry if someone asks the same question before, let me know if you find something about it. Thanks. source https://stackoverflow.com/questions/70499683/how-do-i-ckeck-if-the-column-contains-the-post-of-the-form

How to process insane date inputs with php

I have a code in php for processing the personal details of a person. I need code to handle the date input such that when the user inputs a year like 1900 and below then the program outputs That is impossible . I have successfully handled how the program should respond if the date input is in the future . The program takes date input from the user in the European Date Format for example 21-10-1990 , Am having a hard time processing this because the php in-built function time() returns a unix timestamp measured since January 1st 1970 . Is there a way I can circumvent this to achieve detection of years startimg from 1900 and below without applying a conditional structure to the year directly? Code <?php class User{ //initialize the user properties public string $name=""; public string $dob=""; public string $national_id=""; public string $tel=""; public string $email=""; public function User($user_nam

How can i convert the PHP string into an integer, but php string is fetched from javascript written in the same page?

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>if else in php</title> </head> <body> <script> var a = 123; //to send the prompt value to php, reference taken from stack overflow </script> <?php $a = "<script>document.writeln(a)</script>"; echo $a; ?> </body> </html> in the code above, i fetched the value of javascript variable 'a' in PHP i successfully get it in the variable $a and i tried to print it then also it got printed successfully. As $a would be containing number '123' in string i tried to convert it into an integer using intval() function but, it always shows me value of $a as 0 when i

PHP Echo with html inside, not working on mobile browser

Anyone know why this code not working? if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == "appname") { echo 'webview'; }else{ echo '<style>header {display:none !important;}</style>'; } This part only work if used PC browser, but not if used the mobile browser: echo '<style>header {display:none !important;}</style>'; source https://stackoverflow.com/questions/70482237/php-echo-with-html-inside-not-working-on-mobile-browser