Skip to content

PHP PDO::FETCH_ASSOC returns false

In this code fetch(PDO::FETCH_ASSOC) retunrs false even if $row>0. I couldn’t find why this is happening. Here session is not set as $member is null. <?php $sql = "SELECT * FROM members WHERE …

How to get some part of text from a large text

Is there any way to get get a small part of data from an array index in php? For example, I have an array of data like: Array( [title] => My title [description] =>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever…

cURL works for my REST API but Guzzle not

I am trying to connect my Laravel framework to my server using Guzzle. Every GET request without parameters but I have problems with POST. This request using cURL works fine: curl -i -X POST -H ‘…

Encoding for SMS messages

I’m currently building an application which uses Nexmo to send SMS messages to users. But I’m experiencing some problems with the encoding of messages. Probably worth metioning; I’m using the prawnsalad/Nexmo-PHP-lib library to connect with their API. A simple text messages of 160 characters…

Setting up PHPMailer with Office365 SMTP

I am attempting to set up PHPMailer so that one of our clients is able to have the automatically generated emails come from their own account. I have logged into their Office 365 account, and found …

Select box with first option empty

How can I set the first option in my select box to an empty value? I’m getting the data from my DB, and I would like to set the option by default as “Please select one option”. Answer I found that ‘default’=>’Please select’ doesn’t work with the HTML5 require…

PHP: Sort array by value length

I am trying to sort an array by the length of characters in each value (and perhaps, if possible, in alphabetical order if two values have the same length of characters). For example: Array ( [0] =&…

PHP code convert to PHP/MySQLi OOP

today i tried to convert my code to PHP/MySQLi OOP code. class Database { private $host; private $user; private $password; private $db; private $mysqli; function __construct() { $this->host = …