Skip to content

Selecting one row from MySQL using mysql_* API

I have the following query: and the output I am getting is: Resource id #2 Ultimately, I want to be able to echo out a single field like so: Without having to use a while loop, as since I am only trying to get one field I do not see the point. I have tried using mysql_result with no luck

MySQL commit and transaction

I have a question regarding MySQL commits and transactions. I have a couple of PHP statements that execute MySQL queries. Do I just say the following? What exactly would this do? How does it help? For updates, deletes and insertions I also found this to block other queries from reading: Would this block other…

MySQL INSERT IGNORE INTO keeps adding duplicate entries

Here’s the particular area im having an issue with when testing this it keeps adding the same entry to the table even though I have set IGNORE INTO. Answer It looks like you don’t have a UNIQUE INDEX on the IP column. In order for INSERT IGNORE to work as required, that’s neccessary. Try thi…

Check if all values in array are the same

I need to check if all values in an array equal the same thing. For example: If every value in the array equals ‘true’ then I want to echo ‘all true’. If any value in the array equals ‘false’ then I want to echo ‘some false’ Any idea on how I can do this? Answer…

How to use PHP with Visual Studio

First let me say I’ve never used PHP but I’m looking to learn it, so my question is this how do you use PHP within Visual Studio Ultimate? is it similar to how you declare JQuery i.e I’ve done multiple searches on Google, but I don’t get the answer I’m looking for. Or do I need a…

How to pass custom header to RESTful call?

There are some web service APIs that I need to connect to for my website. Most of the APIs involve something like this: But one web service requires the API key to be set in a custom HTTP header. How do I make the request to this API url and pass the custom header at the same time? Answer You

PDO were rows affected during execute statement

I have found many ways to use the exec statement for PDO, but I’m not sure it helps me. My understanding is that I have to use the execute() function for prepared statements. I am updating a row with data from user input, so I would like to use a prepared statement instead of the query() call. My code i…

Easy way to get Vimeo id from a vimeo url

I’m trying to get just the id from a vimeo URL. Is there a simpler way than this? All the vimeo video urls I see are always: https://vimeo.com/29474908 https://vimeo.com/38648446 // VIMEO $vimeo = …