mysql

PHP function to sanitize all data

Is it a good, or stupid idea to sanitize all the data that could be sqlinjected? I wrote a function that should do it, but I've never seen it done and was wondering if it was a poor idea. The function I wrote: function sanitizeData() { $_SERVER['HTTP_USER_AGENT'] = mysql_real_escape_string($_SERVER['HTTP_USER_AGENT']); foreach(...

mySQL fetch column based on another column in PHP

I'm trying to write my first PHP script with mySQL and I desperately need some help. I'm sure this is relatively simple, but if I have one field in my table (username, for example), and I want to fetch another field (name, for example), that is in the same row as the given username, how do I do that? Again, I'm sure this is easy, but I'...

In MySQL, how do I insert only when row doesn't exist and update only when existing version is less

I am looking for a way to only insert when the row does not exist in MySQL, and update when the row exists AND the version of the existing row is less than (or equal to) the version of the new row. For example, the table is defined as: CREATE TABLE documents ( id VARCHAR(64) NOT NULL, version BIGINT UNSIGNED NOT NULL, data BLOB,...

PHP-driven exhaustive stats - server-side text files or MySQL tables?

I've got a gaming-oriented website with 200+ users. The site has a large database tracking user plays, and one of the motivations for continued participation is the extensive statistics and rankings (S&R) with which the site provides the user. As the list of S&Rs tracked has grown, some of the more intricate calculations have been moved...

Fluent NHibernate and MySQL cast syntax?

I have a table in MySQL which has a string column 'Id' of the form "Xnnnn" where nnnn is a number. I want to find the largest nnnn defined. So I have: var c = s.CreateCriteria(typeof(Item)) .AddOrder(Order.Desc( Projections.Cast( NHibernateUtil.Int32, Projections.SqlFunction("substring", NHibernateUtil.String, ...

creating database in oracle10g

In mysql i can create a new database so easily just by writing a command. Mysql>create database database_name; In oracle 10g the default database name is XE. Can anybody tell command to create a new database other than XE ? I am using Linux(fedora-12). ...

MySql: What is the structure for "IF" formula? Please give example.

I try to use formula "IF" in view but dont know what the structure. Basically I try to divide two group of number. 0,1,2,3,4 after "IF" = 0 and 5,6,7,8,9 after "IF" = 1. Here is an example of my database: Row 1 / Column A = 8 column B = 1 column C = 2 Column D = 5 Column E = 7 Column F = 9 ...

Best data access methods for PHP/Codeigniter/jQuery/MySQL

I'm originally a .NET dev by heart so I've always been use to having ADO.net and LINQ for strongly typed, easy data access into gridviews and other .net controls. In trying to learn PHP and MySQL with CodeIgniter and a dash of jQuery, but I'm having a hard time visualizing my data access methods. I want to use a PHP or jquery grid for ...

Auto-Sending an email if a variable equals 1

Hello, I am trying to use the code below to do the following; In a MySQL table called submission, check to see if subcheck = 1 for the row where submissionid = $submissionid. If the answer to #1 above is yes, then take the email field from a MySQL table called "login" from the row where username = $submittor', and then email $comment ...

Want to develop a webapp for searching flights but dont know where to find the databases

Hi, i want to develop a webapp like this: http://www.flights.com/ where you find flights, now i see that are many sites likes this that makes me suppose that there are free databases that contains the data. Where can i find one? Thanks! ...

MySQL replace spaces.

The contents is " hello world hello. <a href="#">hello</a> " How to replace space before "hello" to &nbsp;,and not replace the space between a and href. ...

Rails saving datetime to MySQL database

I have a simple function within my model to set a completed datetime column in a database. this function worked until I tried to change the default rails format for datetime. After reading up on the issues with mysql datetime format and rails I decided to take out the formating code I had in the environment.rb It still does not save t...

I am unable to search tree in php mysql

table structure userID SponserID 102 200 201 102 202 102 203 201 all users have parend id means sponser ID how to find all records which are which are userd of 102 pls help me ...

MySQL Count Items In Category

I don't understand MySQL very well, here are the table structures I am using. users id | first_name | last_name | username | password categories id | user_id | name | description links id | user_id | category_id | name | url | description | date_added | hit_counter I am trying to return a result set like this, to...

Special character in database.yml for password.

Hi All, I have my database password starting with a '*'. When i put this on my production server i get following error: - syntax error on line 17, col 25: ` password: *---------'.Exception class:ArgumentError. Thanks, Anubhaw ...

MySQL - Displaying results from a sub-query in a single row

I have two tables, products and category. A product can be in multiple categories. product (<product_id>, name, desc, price) category (<category_id>, slug, display_name) product_category(<category_id>, <product_id>) Product have a N:M relationship with category. I would like a query which show the categories of the product in a single...

XAMPP MySQL - Setting ft_min_word_len

I have XAMPP installed on my computer, and am using MySQL through it on localhost for a personal project. I am trying to set the ft_min_word_len variable for fulltext searches in boolean mode to 2 from the default of 4. I've tried (after stopping MySQL from the XAMPP control panel): Opening Shell from the XAMPP control panel, and typ...

Setting the "name" of the "sender" of an email

Hello, The code below is supposed to send out an email if a comment is made on a submission where a certain condition is met (subcheck = 1). It works fairly well. However, the "name" of the sender that shows up is two 7-digit numbers separated by a dot. How could I make the name of the sender something else, like [email protected] ...

Sort characters in strings with mysql?

I'm wondering how I can sort the characters in a string from a MySQL result. A function I could call on a string like 'letter', which would return the string 'eelrtt'. All characters would be sorted in alphabetical order. I couldn't find a function in the MySQL docs, am I missing something or is this something that needs to be done manu...

join tables and return multiple rows with same main id as single rows

Hi to al I have two tables need to join and then the multiple row result with the same crb_pi_id from table2, will combine and return as single rows. it is possible? I used that result on printable report. Thanks in advance. table1 : crb_pi_id,name,tel_no 1,john,1111111 2,paul,2222222 table2 : crb_pd_id,crb_pi_id,account_name,amo...