I have a form into which the visitor can enter data, and I want to store this data in a mysql database via the $_POST variable. What do I need to prevent sql injection?
Hello,
I have a table containing last_updated_1 and last_updated_2 columns, used respectively for text and images update time on a post.
I wish I could get a result set of 10 rows based on all time last updated records contained in the 2 columns, ex. row 1 = last_updated_1 record, row 2 = last_updated_2 record, row 3 = last_updated_1 record, etc.
How could I compare inside a MySQL query the both columns values, to get unique & mixed result set ?
Thank you in advance for your help
I am passing in command line arguments to my Lisp program and they are formatted like this when they hit my main function:
("1 1 1" "dot" "2 2 2")
I have a dot function and would like to call it directly from the argument, but this isn't possible because something like (funcall (second args)...) receives "dot" and not dot as the function name.
I tried variations of this function:
(defun remove-quotes (s)
(setf (aref s 0) '""))
to no avail, before realizing that the quotes were not really a part of the string. Is there a simple way to do this, or should I just check each string and then call the appropriate function?
Thanks!
Hi,
Is this possible, can a trigger in mysql can do a select first and then based on its result do a delete?, both on the same table.
Am struggling to get it right.
There are duplicate entries in a table, i need to have a trigger which selects and then deletes.
Any ideas or thoughts will be really helpful.
Good day!
Please, can you help me to translate such a mysql query into nhibernate
SELECT sales_id, service_id,dayofyear(dt), max(dt) FROM clients.statistics group by sales_id, service_id,dayofyear(dt);
Yes it's Windows sorry.
I'm using mysqldump with the option -T which creates a sql and a txt file per table.
mysqldump -u user -ppass db -T path
I use that option to be able to restore easily one table.
Now I'd like to restore all the tables.
mysql -u user -ppass db < path/*.sql
Obvously doesn't work
Also, I don't know where do my funcs/procs go.
Thx
I'm executing the following query
SELECT COUNT(*)
FROM table
WHERE field1='value' AND (field2 = 1000 OR field3 = 2000)
There is one index over field1 and another composited over field2&field3.
I see MySQL always selects the field1 index and then makes a join using the other two fields which is quite bad because it needs to join 146.000 rows.
Suggestions on how to improve this? Thanks
I have a mysql table set up like so:
user_id | document
44 [blob]
44 [blob]
44 [blob]
46 [blob]
I'd like to export all of user_id 44's data to an SQLite3 file.
Best way to go about this without writing a script that reads the data and dumps it into a SQLite file?
Hey guys
how can i query my mysql database and fetch rows which are posted in earlier 3 days
i know how to fetch todays's rows but not 3 days ago
time will save in my table like this :
2010-01-20 19:17:49
and this is what i know :
SELECT id FROM pages WHERE date=now()
but i need to show posts in 3days
and im looking for a simple and straight solution ,because i know how to do so in long php codes
Hi,
I'm very new to JQuery, but I was told the one of the cool things about it is you can query a mysql database right from an html page(or in my case a smarty template)with out needing php.
I have not found any examples of this so I am asking if someone has one? Thanks
I would like to split a column of strings on the first two colons, but not on any subsequent colons:
my.data <- read.table(text='
my.string some.data
12:34:56:78 -100
87:65:43:21 -200
a4:b6:c8888 -300
11:bb:ccccc -400
uu:vv:ww:xx -500', header = TRUE)
desired.result <- read.table(text='
my.string1 my.string2 my.string3 some.data
12 34 56:78 -100
87 65 43:21 -200
a4 b6 c8888 -300
11 bb ccccc -400
uu vv ww:xx -500', header = TRUE)
I have searched extensively and the following question is the closest to my current dilemma:
Split on first comma in string
Thank you for any suggestions. I prefer to use base R.
I am wanting to use "keywords" within a large string. These keywords start and end using *my_keyword* and are user defined. How, within a large string, can I search and find what is between the two * characters and return each instance?
The reason it might change it, that parts of the keywords can be user defined, such as *page_date_Y* which might show the year in which the page was created.
So, again, I just need to do a search and return what is between those * characters. Is this possible, or is there a better way of doing this if I don't know the "keyword" length or what i might be?
Q:
I have the following case :
set of letters (grades)
A,A+,A-,B,B+,B- stored as strings in
the database i wanna to order these
grades logically from the small
one to the big one ,, but this not
what happen in real.. because these
are strings the order is:
A,A+,A- i wanna
ASC
A-,A,A+
DESC
A+,A,A-
i bind those grades in drop down list
and i wanna these grades with this
logical order in it..
is there any idea how to do something
like this..
Search for: 'chemist'
Problem: query which will match a string like 'onechemist' but not 'chemist'.
SELECT id,name FROM `records`
WHERE name LIKE '%". mysql_real_escape_string($q) ."%'
This alternate try won't work:
SELECT id,name FROM `records`
WHERE name LIKE '%". mysql_real_escape_string($q) ."%'
OR name LIKE '". mysql_real_escape_string($q) ."%'
OR name LIKE '%". mysql_real_escape_string($q) ."'
How could I compile the above into one single query that will match any field which has the string or optimize the query into a better expression?
I'm starting to develop an application using MySQL and although I've developed apps before using databases, I've normally gone to the incrementing id method. The other day I was reading a posting somewhere and saw someone being picked apart for this, for not properly "normalising the database". I'm not a big database person, but I wanted to make sure I'm doing this right.
Any ideas, help / guidance?
Hi guys, I've got this table
CREATE TABLE `subevents` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(150) DEFAULT NULL,
`content` text,
`class` tinyint(4) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=MyISAM
Each row can have a different value in the 'class' field.
I'd like to select any number of rows, ordered randomly, as long as the sum of the values in the 'class' field is equal to 100.
How could I accomplish it directly in the MySQL query without doing it later in PHP?
Thanks everybody!
I was wondering how can I validate a single checkbox using PHP and MySQL.
Here is the HTML.
<input type="checkbox" name="privacy_policy" id="privacy_policy" value="yes" />
Two tables:
table_a
-------
table_a_id: (primary, int)
table_b
-------
table_a_id: (index, int, from table_a)
table_b_value: (varchar)
A one to many relationship between table_a_id and table_b_value.
Given a query like this:
SELECT DISTINCT(table_a_id) FROM table_a
JOIN table_b ON table_a.table_a_id=table_b.table_a_id
I want to order by the number of occurrences of table_a_id in table_b. I'm not really sure how to write this in MySQL.
I some php code which gets info from a mysql database. The problem is that the date is coming out in the format : 2010-02-03 22:21:26
Does anyone know a simple solution to make the date more user friendly format. e.g 2nd march 2010 at 22:21.
Thanks
I get the following error in the query below:
#1064 - You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near ')))' at line 1
Code Snippet:
INSERT INTO test_bans( ip, Expiration )
VALUES (
"0.0.0.0", DateAdd(
"d", 1, Date( )
)
)
Table creation query
CREATE TABLE test_bans (
ID smallint(6) NOT NULL AUTO_INCREMENT,
IP text NOT NULL,
Expiration DATETIME NOT NULL,
PRIMARY KEY (ID)
) TYPE=MyISAM;
What am I missing?
Can any one please let me know, that, i need to fetch last 4 rows from a result-set using mysql. The result-set returns totally 6 records.
but, i need the records to be fetch from last4...i.e,
Record-3
Record-4
Record-5
Record-6
Lets say I'm starting a site that users can enter content but all my categories are empty except one or two, how should the empty categories be displayed to my users if at all using MySQL & PHP?