Skip to content

Tag: mysql

SQL get results 21-30?

This seems like a really simple question but I can’t seem to find information on it. If I have 100 results, and I only want to get the results results between 21 and 30 (from the order my SQL query is grabbing them), how would I accomplish this? Answer You can use this: E.g.,

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…

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…

Storing application permissions in a database

I’m developing an application for our company that eventually will have lots of ways of restricting users to particular sections/modules. While the application is still small, I’d like to move to a new method of storing permissions that, as the application grows, will remain easy to maintain and q…

PDO MySQL: Use PDO::ATTR_EMULATE_PREPARES or not?

This is what I’ve read so far about PDO::ATTR_EMULATE_PREPARES: PDO’s prepare emulation is better for performance since MySQL’s native prepare bypasses the query cache. MySQL’s native prepare is better for security (preventing SQL Injection). MySQL’s native prepare is better for …