Skip to content

Tag: sql

Separate merged SQL rows with a comma

I’m having a bit of trouble getting my retrieved values from an SQL query into the correct format. I’ve managed to join multiple rows into the one value, however I am not sure how to make it separate each of the values with a comma. Essentially I need all the ID’s of a product to be retrieve…

Unknown Column in Field List. PHP + Mysql

I’m trying to add values to a table in phpmyadmin and I get the error: Unknown column ‘…’ in ‘field list’. Here’s my code: so when I enter fds as name in the form on the previous page I get : Unknown column ‘fds’ in ‘field list’. This never hap…

Change time zone of gmdate PHP function

I am using the gmdate PHP function to insert the current date to the database but it shows GMT time , can I change it to my time zone +3 ? this is the code Answer “+3” is not a “timezone”. It’s an offset from UTC/GMT, which may change throughout the year based on DST settings. A …

mysql sanitize row name

I’m currently writing a php framework with focus on security. I use a query builder to generate SQL-statements, so that it is not bound to MySQL. (Or SQL in general) I found certain posibilities that user could inject row names, so it has to escape them somehow. Because of how the query builder works, i…

Do Not Duplicate VALUE if already exist on MySQL

I’ve been trying to accomplish this, but as other issues I just can’t figured it out. I’ve been reading around for posibles solutions but non of them goes along with my code, or if they do I can’t figure out how or where to use them. I have a DB where a user sends records. The database…

PDO and MySQL ‘between’

I’m trying to get PDO to work with a MySQL ‘between’. Below is my code: What gets returned is an array with ‘0’ or ‘NULL’ for values. When I hard code the end date, it acts as if start_date is set to -1, retuning me all rows before the end_date. So, what am I doing wr…

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.,