Skip to content

How to ‘really’ detect integers from DB?

I’m trying to save some code with the following. I’ve an object with variables named the same as table rows so I could create an insert like this one: $query = “INSERT INTO table “; $columns =…

Mysqli not installed?

I get the following error: Fatal error: Class ‘mysqli’ not found in my php script I have php5.3.3-7 installed and I get this when I run apt-cache show php5-mysql There is nothing about mysql at all in php info. How do I find the extention and do I have to istall it? There are many references to my…

How can I detect a malformed UTF-8 string in PHP?

The iconv function sometimes gives me an error: Is there a way to detect that there are illegal characters in a UTF-8 string before sending data to inconv()? Answer First, note that it is not possible to detect whether text belongs to a specific undesired encoding. You can only check whether a string is valid…

Remove first 2 from Array

I have this simple array and I’d like to know how I can stop the first 2 segments from showing. Any help would be great, Thanks! Answer Stop from showing or removing? for removing: Hope this helps!

Within a regex is xhh same as x{hh}?

Within a regex seems that it is the same: if(preg_match(‘/x{61}/’,”a”,$m)) //Same as just x61 print_r($m); But if you make echo both apart. echo “x61”;//Display a echo &…

Purpose of Secondary Key

What is the purpose of the Secondary key? Say I have a table that logs down all the check-ins (similar to Foursquare), with columns id, user_id, location_id, post, time, and there can be millions of rows, many people have stated to use secondary keys to speed up the process. Why does this work? And should bot…

Convert mssql datetime object to PHP string

I’m grabbing some information from a database and the record is in an MSSQL DateTime format, when I return it, it shows in my array as follows: [arrayItem] => DateTime Object ( [date] =…

RESTful API methods; HEAD & OPTIONS

I’m writing a RESTful API module for an application in PHP, and I’m a bit mixed on the verbs HEAD and OPTIONS. OPTIONS  Used to retrieve the available HTTP verbs for a given resource? HEAD Used to determine whether a given resource is available? If someone could clarify* these verbs, that would be…