Tag Archives: php

Image to base64 encoding issue – PHP

Questions: <?php header(“Content-type: image/jpeg;charset=utf-8′”); $path = ‘example/source.jpg’; $da = file_get_contents($path); $base64 = base64_encode($da); $src = ‘data:image/jpeg;charset=utf-8;base64,’.$base64; echo ‘<img src=”‘.$src.'”>’; ?> php v5.6.2 I tired copying the $src value in debug and pasted in img src value. still its not showing up. what did i missed here?. thanks in advance Answers:

Getting error while setting up mongodb with php 7.0.27

Questions: I am trying to setup mongodb with php i am getting error as defined below Warning: PHP Startup: Unable to load dynamic library ‘C:\xampp\php\ext\php_mongo db.dll’ – %1 is not a valid Win32 application. here are the steps what i haev done I have downloaded the dll file from here pasted in C:\xampp\php\ext and added… Read More »

how to protect index.php file to override by any method on server

Questions: Actually, my server is hacked by someone and replace the index.php file, however, I have not used any form in the project but still this is hacked, I am in trouble please help me to protect my file as well as give me a solution to no one can replace the index.php file. Answers:

php artisan migrate stuck at the beginning of the command

Questions: [MacOS 10.14.0] When I create a new project (Laravel new blog) Then create a table in MySQL (create database blog) And then update my .env file with the correct userame, password and database. After creating a project, I will run php artisan migrate But my terminal stays empty, I can type in my terminal.… Read More »

check for a JSON string inside of a larger string in PHP

Questions: Here is an example of a log file entry: [22-Aug-2017 16:19:58 America/New_York] WP_Community_Events::maybe_log_events_response: Valid response received. Details: {“api_url”:”https:\/\/api.wordpress.org\/events\/1.0\/”,”request_args”:{“body”:{“number”:5,”ip”:”192.168.99.0″,”locale”:”en_GB”,”timezone”:”America\/New_York”}},”response_code”:200,”response_body”:{“location”:{“ip”:”47.197.97.47″},”events”:”5 events trimmed.”}} The {“api_url”:”https:\/\/api.wordpress…. portion is valid JSON, but obviously the entire string itself (the log entry line) isn’t. I’m hitting a wall with a way to essentially pull out that JSON without messing up any… Read More »

Save with phpexcel to temporary file

Questions: I have to save an excel in a temporary file but I do not know how Originally this way I keep the excel file header(‘Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet’); header(‘Content-Disposition: attachment;filename=”Autolarte.xlsx”‘); header(‘Cache-Control: max-age=0’); header(‘Cache-Control: max-age=1’); header (‘Expires: Mon, 26 Jul 1997 05:00:00 GMT’); header (‘Last-Modified: ‘.gmdate(‘D, d M Y H:i:s’).’ GMT’); header (‘Cache-Control: cache, must-revalidate’); header (‘Pragma:… Read More »

Optimize PHP Function and SQL Queries to extract dependent data from MySQL database

Questions: If I have two tables with their respective columns: product_catrgories: id, name products: id, category_id, name And I have the following PHP functions: function getProducts() { … } // Returns an array of all rows from the products function getProductCategory($category_id) { … } // returns the corresponding row to the given id of the… Read More »