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" />
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!
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?
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?
main_product table
productid outward shopid
333 2 44//present
343 4 44//present
353 5 44//present
363 1 44//present
373 2 44//not present
min_product table
productid outward shopid
333 1 44
343 1 44
353 1 44
363 1 44
SELECT DISTINCT (A.productid),A.outward, B.productid,B.outward FROM main_product A INNER JOIN min_product B on B.productid=A.product_id where A.shopid='44' and B.shopid='44'
my question how can i INSERT OR UPDATE in one query using mysql by checking if it is present or not
if present update else insert
something like this?
INSERT
INTO mytable (key, value)
VALUES ($newkey, $newvalue)
ON DUPLICATE KEY UPDATE
SET value = $newvalue
Basically I want the books to be text book based, ie, author discusses the background,philosophy,syntax,semtantix for every language AND after every section there are questions what you learned so far and mini projects. Is there any books like this, I'm absolutely new to php/mysql/javascript and web development in general. Thanks in advance.
I have a MySQL table with a column called "priority". The column can have two values: high or low. I want to select 8 records from the table at random, but I want 6 of them to be high priority, and 2 of them to be low priority. If possibly, I would like to do it in one SQL statement. Is there any way to do two LIMITS in one query based on this kind of criteria?
I have a MySQL query which gets including some vars like that:
messages TABLE receiver cols
user1 rows : 1,3,5
user2 rows : 2,3
user3 rows : 1,4
I want to get rows which includes '3' value. So I will get 'user1' and 'user2'.
I tried that but naturally it doesn't work.
mysql_query("SELECT * FROM messages WHERE receiver='3'");
How can I do this?
Hello,
I have a datetime field in mysql table and i am using JPA for persisting data but only date goes in database. Time always shows 00:00:00. What should i do?
I am not doing any manipulation with Date. All i do is to assign new Date() to a variable and store it in database.
What am i doing wrong?
I just started using mysql and I just can see myself woking with strings!
I mean the compiler cant catch errors like this... and its just a mess!
is there a wrapper or some kind of class i can add that does something as simple as making a function that adds a table and asks for args?
I'm sure there is a tool like that but i cant find it or know its name.
plz help.
I need to make an installer for a MySQL 5.1 Database, but I'm totally a noob when it comes to installers.
I've been looking at NSIS and learned a little but I don't really know how to use it to just to execute a script.
Anyone out there has experience installing database schemas in multiple computers?
thanks
Is it possible to merge these two mysql queries into one? I want to get NOW() returned to a php variable.
mysql_query('INSERT INTO translate (IDRef, RefType, Lang, Text, LastChangeTS) VALUES ('.$id.', \''.$reftype.'\', \''.$lang.'\', \''.$text.'\', NOW()) ON DUPLICATE KEY UPDATE text = \''.$text.'\', LastChangeTS = NOW()');
mysql_query('SELECT LastChangeTS FROM translate WHERE IDRef = '.$id.' AND RefType = \''.$reftype.'\' AND Lang = \''.$lang.'\'');
I have a webapplication linked to a mysql database with the following fields:
field 1:trip_id
field 2:trip_destination
field 3:trip_description
field 4:trip_duration
In the webapplication I have a listbox based on the following:
ListBox value =1: trip duration 1 - 5 days
ListBox value =2: trip duration 6 - 10 days
Listbox value =3: trip duration 11 -20 days
ListBox value =4: trip duration over 20 days
How do I put this in the sql select statement?
I never remember how to do this properly - can you help me fix this query?
SELECT * from log where now() - EventTime < '1 day'
Note - this question seems identical but there's no solution there for mysql.
Hi All,
I created a webservice in RDB with .Net.I able to transfer data from iphone to mysql and it returns the data.
But i need to transfer data from RDB to iphone whenever i need
(i am strucked by the ip address of iphone which one is dynamic to connect the device from a RDB)
Please tell me how i will do it otherwise tell is any other way.
Thanks in Advance
I have to write mysql query for fetching result from my database with a specified date and code like ABH18 or ABH17 or ABH19.I write the querly like below.
select * from tbl_transaction where trans_name like 'ABH19%' or trans_name like 'ABH18%' or trans_name like 'ABH17%' or trans_name like 'ABH15%' and date_of_vazhipad='2013-11-20' and trans_status='Completed successfully.'
There are no result in the DB satisfying all above conditions.But i got result with different dates.But i want to ensure the date_of_vazhipad='2013-11-20' so that the query may work properly
Thanks in advance
I have a mysql table of 3 integer fields. None of the fields have a unique value - but the three of them combined are unique.
When I query this table, I only search by the first field.
Which approach is recommended for indexing such table?
Having a multiple-field primary key on the 3 fields, or setting an index on the first field, which is not unique?
Thanks,
Doori Bar
Maybe i have the wrong context but...
Is there a corelib site for mysql like http://corelib.rubyonrails.org/ for ruby on rails RoR?
Would be nice to have 1 stop shop. thx.
I wont to do insert to one mysqll server to and get the data or do the select part
of the insert into select from anther mysql server
not just copy entire tables is this possible in my sql
I know that in MS Sql server you can do a linked server
thanks
I was wondering if the code below is the correct way to use mysqli_real_escape_string() when storing users data in a database.
Here is the PHP & MySQL code.
if (mysqli_num_rows($dbc) == 0) {
$mysqli = mysqli_connect("localhost", "root", "", "sitename");
$dbc = mysqli_query($mysqli,"INSERT INTO info (user_id, url)
VALUES ('$user_id', 'mysqli_real_escape_string($url)')");
}
if ($dbc == TRUE) {
$dbc = mysqli_query($mysqli,"UPDATE info
SET url = 'mysqli_real_escape_string($url)'
WHERE user_id = '$user_id'");
Hi
This is a doubt on mysql select query
let me axplain my doubt with a simple example
consider this is my query
SELECT dbCountry from tableCountry
tableCountry has fields dbCuntryId dbCountry and dbState
I have the result as
dbCountry
india
america
england
kenya
pakisthan
I need the result as
1 india
2 america
3 england
4 kenya
5 pakisthan
the numbers 12345 must be generated with the increase in data and itis not a autoincrement id
How can i get it
is it something like loop