Skip to content

Tag: php

SHOW COLUMNS from multiple tables

I am trying to get the column names from 2 tables. I tried a query like: (SHOW COLUMNS FROM users) UNION (SHOW COLUMNS FROM posts) but that does not work & returns a syntax error. I tried the same query using DESCRIBE but that did not work either. How can I get all the column names from multiple tables in

converting to PDO, problems

So I am working on converting an old tutorial I did a while back from mySQL to PDO. This way I can better understand the concepts. I seem to of run into a wall however. The following function is …

File Not Found when running PHP with Nginx

Recently I installed the latest version of Nginx and looks like I’m having hard time running PHP with it. Here is the configuration file I’m using for the domain: } Here is the error I’m getting on the error log file: Answer Try another *fastcgi_param* something like

Can I add a base64 image to the $_FILES array?

Is there a way to add a base64 image string to the $_FILES array (the array that you get when you upload a file)? Basically, I want to fake a file upload from a base64 string. The base64 string comes from an email attachment. I don’t wish to use file_get_contents(), because I want to save the image in a datab…

Display table values vertically while keeping table structure

Been checking out other ways used to order array values vertically for use in a table but most of them were the equivalent of flipping your table 90 deg to the right. I’ve been trying to think of a way to properly implement this but I think I need some help. For example, the table (horizontal order): Is…

PHP Cleaning special characters from string

so I made this scraper and it returns strings from multiple sites. I want to check if the strings match, so I use php to clean the string and check. However, the & and other special characters appear in 2 ways, one as & and the other as &. How do I go about removing each type. I already have

PHP Difference between array() and []

I’m writing a PHP app and I want to make sure it will work with no errors. The original code: Would the following work with no errors or is not recommended for some reason? Are there any difference? I’ve looked again the data about array() and the short array method with square brackets [] in PHP.…

PHP – imagecreatefromjpeg uses 100M memory for <1M image

The image is less than 1MB but the size is roughly 5500×3600. I am trying to resize the image down too something less than 500×500. My code is pretty simple. I found out that to process this image, the imagecreatefromjpeg uses 100M using memory_get_usage. Is there a better way to do imagecreatefromj…